|
@@ -8,6 +8,7 @@ import com.caimei.model.dto.ProductSaveDto;
|
|
import com.caimei.model.po.AuthImportPo;
|
|
import com.caimei.model.po.AuthImportPo;
|
|
import com.caimei.model.po.CmBrandAuthPo;
|
|
import com.caimei.model.po.CmBrandAuthPo;
|
|
import com.caimei.model.po.ProductParamPo;
|
|
import com.caimei.model.po.ProductParamPo;
|
|
|
|
+import com.caimei.model.vo.AuthFormVo;
|
|
import com.caimei.model.vo.AuthVo;
|
|
import com.caimei.model.vo.AuthVo;
|
|
import com.caimei.model.vo.ProductFormVo;
|
|
import com.caimei.model.vo.ProductFormVo;
|
|
import com.caimei.service.AuthProductService;
|
|
import com.caimei.service.AuthProductService;
|
|
@@ -20,8 +21,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
-import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -140,7 +141,24 @@ public class AuthServiceImpl implements AuthService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResponseJson saveAuth(Integer authId, Integer authUserId, String authParty, Integer createBy) {
|
|
|
|
|
|
+ public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
|
|
|
|
+ if (null == authId) {
|
|
|
|
+ return ResponseJson.error("参数异常,机构id不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ CmBrandAuthPo auth = authMapper.getAuthById(authId);
|
|
|
|
+ AuthFormVo authFormVo = new AuthFormVo();
|
|
|
|
+ authFormVo.setAuthId(auth.getId());
|
|
|
|
+ BeanUtils.copyProperties(auth, authFormVo);
|
|
|
|
+ List<String> bannerList = authMapper.getBannerList(authId);
|
|
|
|
+ authFormVo.setBannerList(bannerList);
|
|
|
|
+ return ResponseJson.success(authFormVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson saveAuth(CmBrandAuthPo auth, List<String> bannerList, boolean importFlag) {
|
|
|
|
+ Integer authId = auth.getId();
|
|
|
|
+ Integer authUserId = auth.getAuthUserId();
|
|
|
|
+ String authParty = auth.getAuthParty();
|
|
if (null == authUserId) {
|
|
if (null == authUserId) {
|
|
return ResponseJson.error("参数异常,请输入供应商用户id");
|
|
return ResponseJson.error("参数异常,请输入供应商用户id");
|
|
}
|
|
}
|
|
@@ -151,32 +169,35 @@ public class AuthServiceImpl implements AuthService {
|
|
if (null != authIdByAuthParty && !authIdByAuthParty.equals(authId)) {
|
|
if (null != authIdByAuthParty && !authIdByAuthParty.equals(authId)) {
|
|
return ResponseJson.error("参数异常,该授权机构已存在,请重新输入", null);
|
|
return ResponseJson.error("参数异常,该授权机构已存在,请重新输入", null);
|
|
}
|
|
}
|
|
- if (null == createBy) {
|
|
|
|
|
|
+ if (null == auth.getCreateBy()) {
|
|
return ResponseJson.error("参数异常,请输入创建人id");
|
|
return ResponseJson.error("参数异常,请输入创建人id");
|
|
}
|
|
}
|
|
- /*
|
|
|
|
- 组装授权数据
|
|
|
|
- */
|
|
|
|
- CmBrandAuthPo auth = new CmBrandAuthPo();
|
|
|
|
- auth.setAuthUserId(authUserId);
|
|
|
|
- auth.setAuthParty(authParty);
|
|
|
|
|
|
+ if (!importFlag) {
|
|
|
|
+ if (null == auth.getProvinceId() || null == auth.getCityId() || null == auth.getTownId() || StringUtils.isEmpty(auth.getAddress()) || StringUtils.isEmpty(auth.getLonAndLat())) {
|
|
|
|
+ return ResponseJson.error("参数异常,地址信息异常");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(auth.getLogo())) {
|
|
|
|
+ return ResponseJson.error("参数异常,请上传机构logo");
|
|
|
|
+ }
|
|
|
|
+ if (null == bannerList || bannerList.size() <= 0) {
|
|
|
|
+ return ResponseJson.error("参数异常,请上传轮播图");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// 保存品牌授权信息,上线状态默认为“待上线”,审核状态为“待审核”
|
|
// 保存品牌授权信息,上线状态默认为“待上线”,审核状态为“待审核”
|
|
auth.setStatus(2);
|
|
auth.setStatus(2);
|
|
auth.setAuditStatus(2);
|
|
auth.setAuditStatus(2);
|
|
- if (null == authId) {
|
|
|
|
- auth.setCreateBy(createBy);
|
|
|
|
- auth.setCreateTime(new Date());
|
|
|
|
- } else {
|
|
|
|
- auth.setId(authId);
|
|
|
|
- }
|
|
|
|
/*
|
|
/*
|
|
保存授权
|
|
保存授权
|
|
*/
|
|
*/
|
|
- if (null == authId) {
|
|
|
|
- authMapper.insertAuth(auth);
|
|
|
|
- } else {
|
|
|
|
- authMapper.updateAuthByAuthId(auth);
|
|
|
|
- }
|
|
|
|
|
|
+ if (null == authId) {
|
|
|
|
+ authMapper.insertAuth(auth);
|
|
|
|
+ } else {
|
|
|
|
+ authMapper.updateAuthByAuthId(auth);
|
|
|
|
+ // 删除原有的轮播图
|
|
|
|
+ authMapper.deleteBanner(auth.getId());
|
|
|
|
+ }
|
|
|
|
+ // 保存轮播图
|
|
|
|
+ bannerList.forEach(banner-> authMapper.insertBanner(auth.getId(), banner));
|
|
return ResponseJson.success("保存品牌授权成功", auth);
|
|
return ResponseJson.success("保存品牌授权成功", auth);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -479,7 +500,11 @@ public class AuthServiceImpl implements AuthService {
|
|
Integer authId = authMapper.getAuthIdByAuthParty(authParty, authUserId);
|
|
Integer authId = authMapper.getAuthIdByAuthParty(authParty, authUserId);
|
|
// 保存授权机构
|
|
// 保存授权机构
|
|
if (null == authId) {
|
|
if (null == authId) {
|
|
- ResponseJson responseJson = saveAuth(null, authUserId, authParty, createBy);
|
|
|
|
|
|
+ CmBrandAuthPo auth = new CmBrandAuthPo();
|
|
|
|
+ auth.setAuthUserId(authUserId);
|
|
|
|
+ auth.setAuthParty(authParty);
|
|
|
|
+ auth.setCreateBy(createBy);
|
|
|
|
+ ResponseJson responseJson = saveAuth(auth, null, true);
|
|
CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
|
|
CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
|
|
authId = authPo.getId();
|
|
authId = authPo.getId();
|
|
}
|
|
}
|