修改标签组名排重
This commit is contained in:
@@ -31,7 +31,7 @@ public interface LabelGroupService {
|
||||
* 修改标签组信息
|
||||
* @param dto 修改内容
|
||||
*/
|
||||
void updateLabelGroup(LabelGroupUpdateDTO dto);
|
||||
void updateLabelGroup(LabelGroupUpdateDTO dto) throws ApiException;
|
||||
|
||||
/**
|
||||
* 删除标签组
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.cool.store.service.LabelGroupService;
|
||||
import com.cool.store.vo.LabelGroupListVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -50,8 +51,7 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
||||
public void addLabelGroup(LabelGroupAddDTO dto) throws ApiException {
|
||||
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
||||
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
|
||||
List<HyPartnerLabelGroupDO> existLabelGroup = labelGroupMapper.selectSelective(labelGroupDO);
|
||||
if (existLabelGroup != null && existLabelGroup.size() > 0) {
|
||||
if (whetherGroupDuplicated(labelGroupDO)) {
|
||||
throw new ApiException(ErrorCodeEnum.LABEL_GROUP_EXIST);
|
||||
}
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
@@ -67,8 +67,12 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
||||
* @param dto 修改内容
|
||||
*/
|
||||
@Override
|
||||
public void updateLabelGroup(LabelGroupUpdateDTO dto) {
|
||||
public void updateLabelGroup(LabelGroupUpdateDTO dto) throws ApiException {
|
||||
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
||||
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
|
||||
if (whetherGroupDuplicated(labelGroupDO)) {
|
||||
throw new ApiException(ErrorCodeEnum.LABEL_GROUP_EXIST);
|
||||
}
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelGroupDO.setId(dto.getId());
|
||||
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
|
||||
@@ -112,4 +116,9 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
||||
return labelMapper.whetherGroupInUse(id);
|
||||
}
|
||||
|
||||
private Boolean whetherGroupDuplicated(HyPartnerLabelGroupDO labelGroupDO) {
|
||||
List<HyPartnerLabelGroupDO> hyPartnerLabelGroupDOS = labelGroupMapper.selectSelective(labelGroupDO);
|
||||
return hyPartnerLabelGroupDOS != null && hyPartnerLabelGroupDOS.size() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class LabelGroupController {
|
||||
|
||||
@ApiOperation("修改标签组")
|
||||
@PostMapping({"/edit"})
|
||||
public ResponseResult updateLabelGroup(@RequestBody LabelGroupUpdateDTO dto) {
|
||||
public ResponseResult updateLabelGroup(@RequestBody LabelGroupUpdateDTO dto) throws ApiException {
|
||||
labelGroupService.updateLabelGroup(dto);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user