Commit a4ef6182 by songyinghui

feat: 分组参数校验

parent b2dc2714
...@@ -8,6 +8,8 @@ public enum HaoBanErrCode { ...@@ -8,6 +8,8 @@ public enum HaoBanErrCode {
ERR_0001("10100001", "参数没有传"), ERR_0001("10100001", "参数没有传"),
ERR_10012("10012","企业微信不存在"), ERR_10012("10012","企业微信不存在"),
ERR_OTHER("9999","业务异常"), ERR_OTHER("9999","业务异常"),
ERR_100033("100033", "活码分组已经被关联,不可删除")
; ;
private String code; private String code;
......
...@@ -9,6 +9,7 @@ import com.gic.haoban.manage.api.dto.hm.HmGroupDTO; ...@@ -9,6 +9,7 @@ import com.gic.haoban.manage.api.dto.hm.HmGroupDTO;
import com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO; import com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO;
import com.gic.haoban.manage.api.enums.hm.HmGroupStatus; import com.gic.haoban.manage.api.enums.hm.HmGroupStatus;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService; import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
import com.gic.haoban.manage.service.errorcode.HaoBanErrCode;
import com.gic.haoban.manage.service.pojo.bo.hm.HmGroupSettingBO; import com.gic.haoban.manage.service.pojo.bo.hm.HmGroupSettingBO;
import com.gic.haoban.manage.service.pojo.qo.HmGroupInfoQO; import com.gic.haoban.manage.service.pojo.qo.HmGroupInfoQO;
import com.gic.haoban.manage.service.service.hm.HmGroupService; import com.gic.haoban.manage.service.service.hm.HmGroupService;
...@@ -43,11 +44,12 @@ public class HmGroupApiServiceImpl implements HmGroupApiService { ...@@ -43,11 +44,12 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
@Override @Override
public ServiceResponse<Long> saveOrUpdateHmGroupSetting(HmGroupDTO hmGroupDTO) { public ServiceResponse<Long> saveOrUpdateHmGroupSetting(HmGroupDTO hmGroupDTO) {
log.info("[saveOrUpdateHmGroupSetting] params:{}", JSON.toJSONString(hmGroupDTO));
if (StringUtils.isBlank(hmGroupDTO.getGroupName())) { if (StringUtils.isBlank(hmGroupDTO.getGroupName())) {
return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_5.getCode() + "", HaoBanErrCodeCommon.ERR_5.getMsg()); return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_5.getCode() + "", HaoBanErrCodeCommon.ERR_5.getMsg());
} }
if (StringUtils.equals(DEFAULT_GROUP_NAME, hmGroupDTO.getGroupName())) { if (StringUtils.equals(DEFAULT_GROUP_NAME, hmGroupDTO.getGroupName())) {
return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_5.getCode() + "", HaoBanErrCodeCommon.ERR_5.getMsg()); return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_9.getCode() + "", HaoBanErrCodeCommon.ERR_9.getMsg());
} }
HmGroupInfoQO groupInfoQo = new HmGroupInfoQO(); HmGroupInfoQO groupInfoQo = new HmGroupInfoQO();
groupInfoQo.setGroupName(hmGroupDTO.getGroupName()); groupInfoQo.setGroupName(hmGroupDTO.getGroupName());
...@@ -97,7 +99,7 @@ public class HmGroupApiServiceImpl implements HmGroupApiService { ...@@ -97,7 +99,7 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
Page<HmGroupDTO> groupDtoPage = PageUtil.changeToCurrentPage(groupSettingPage, HmGroupDTO.class); Page<HmGroupDTO> groupDtoPage = PageUtil.changeToCurrentPage(groupSettingPage, HmGroupDTO.class);
List<HmGroupDTO> result = new ArrayList<>(); List<HmGroupDTO> result = new ArrayList<>();
// todo query 活码 默认分组的总数 // todo query 活码 默认分组的总数
result.add(buildDefault(null)); result.add(buildDefault(0));
if (CollectionUtils.isNotEmpty(groupDtoPage.getResult())) { if (CollectionUtils.isNotEmpty(groupDtoPage.getResult())) {
groupDtoPage.getResult().forEach(item -> item.setDefaultFlag(0)); groupDtoPage.getResult().forEach(item -> item.setDefaultFlag(0));
result.addAll(groupDtoPage.getResult()); result.addAll(groupDtoPage.getResult());
...@@ -126,9 +128,11 @@ public class HmGroupApiServiceImpl implements HmGroupApiService { ...@@ -126,9 +128,11 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
} }
HmGroupSettingBO groupSettingBo = groupService.queryGroupSettingDetail(groupDTO.getGroupId()); HmGroupSettingBO groupSettingBo = groupService.queryGroupSettingDetail(groupDTO.getGroupId());
if (groupSettingBo == null if (groupSettingBo == null
|| !HmGroupStatus.ENABLE.getCode().equals(groupSettingBo.getStatus()) || !HmGroupStatus.ENABLE.getCode().equals(groupSettingBo.getStatus())){
|| groupSettingBo.getReferNum() != 0) { return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_8.getCode() + "", HaoBanErrCodeCommon.ERR_8.getMsg());
return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_5.getCode() + "", HaoBanErrCodeCommon.ERR_5.getMsg()); }
if (groupSettingBo.getReferNum() != null && groupSettingBo.getReferNum() > 0){
return ServiceResponse.failure(HaoBanErrCode.ERR_100033.getCode(), HaoBanErrCode.ERR_100033.getMsg());
} }
groupService.deleteGroupSetting(groupDTO); groupService.deleteGroupSetting(groupDTO);
return ServiceResponse.success(Boolean.TRUE); return ServiceResponse.success(Boolean.TRUE);
......
...@@ -47,7 +47,7 @@ public class HmGroupController extends WebBaseController { ...@@ -47,7 +47,7 @@ public class HmGroupController extends WebBaseController {
if (serviceResponse.isSuccess()){ if (serviceResponse.isSuccess()){
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
return RestResponse.failure(serviceResponse.getCode()+"", serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
@RequestMapping(path = "/list") @RequestMapping(path = "/list")
...@@ -80,7 +80,7 @@ public class HmGroupController extends WebBaseController { ...@@ -80,7 +80,7 @@ public class HmGroupController extends WebBaseController {
if (serviceResponse.isSuccess()){ if (serviceResponse.isSuccess()){
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
return RestResponse.failure(serviceResponse.getCode()+"", serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
@RequestMapping(path = "/delete", method = RequestMethod.POST) @RequestMapping(path = "/delete", method = RequestMethod.POST)
...@@ -97,7 +97,7 @@ public class HmGroupController extends WebBaseController { ...@@ -97,7 +97,7 @@ public class HmGroupController extends WebBaseController {
if (serviceResponse.isSuccess()){ if (serviceResponse.isSuccess()){
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
return RestResponse.failure(serviceResponse.getCode()+"", serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
@RequestMapping(path = "/refer/count") @RequestMapping(path = "/refer/count")
......
...@@ -124,7 +124,14 @@ public enum HaoBanErrCode { ...@@ -124,7 +124,14 @@ public enum HaoBanErrCode {
ERR_100032(100032, "代理不能设置导购编辑权限"), ERR_100032(100032, "代理不能设置导购编辑权限"),
ERR_100007(100007, "无门店权限"), ERR_100007(100007, "无门店权限"),
ERR_DEFINE(-888, "自定义错误"), ERR_DEFINE(-888, "自定义错误"),
ERR_OTHER(-999, "未知错误code"); ERR_OTHER(-999, "未知错误code"),
/**
* 活码相关
*
*/
ERR_100033(100033, "分组被关联,不可删除"),
;
private int code; private int code;
private String msg; private String msg;
......
package com.gic.haoban.manage.web.vo.hm; package com.gic.haoban.manage.web.vo.hm;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
...@@ -12,7 +13,9 @@ import java.io.Serializable; ...@@ -12,7 +13,9 @@ import java.io.Serializable;
**/ **/
public class HmGroupSettingVO implements Serializable { public class HmGroupSettingVO implements Serializable {
private static final long serialVersionUID = -371589430652512397L;
@NotEmpty(message = "活码分组名字不能为空") @NotEmpty(message = "活码分组名字不能为空")
@Length(max = 10, message = "分组名称最多10个字符")
private String groupName; private String groupName;
private Long groupId; private Long groupId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment