标签组删除逻辑修改
This commit is contained in:
@@ -86,7 +86,9 @@ public enum ErrorCodeEnum {
|
|||||||
INSPECTION_INFO_NOT_EXIST(600005, "稽核信息不存在!", null),
|
INSPECTION_INFO_NOT_EXIST(600005, "稽核信息不存在!", null),
|
||||||
OPEN_AREA_NULL(600006,"归属地区不能为空",null),
|
OPEN_AREA_NULL(600006,"归属地区不能为空",null),
|
||||||
|
|
||||||
OUTBOUND_NUMBER_EXIST(110001, "手机号已存在!", null);
|
OUTBOUND_NUMBER_EXIST(110001, "手机号已存在!", null),
|
||||||
|
|
||||||
|
LABEL_GROUP_IN_USE(120001, "请勿删除仍在使用的标签组!", null);
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
select <include refid="Base_Column_List"></include>
|
select <include refid="Base_Column_List"></include>
|
||||||
from hy_partner_label_group
|
from hy_partner_label_group
|
||||||
where deleted = 0
|
where deleted = 0
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
@@ -191,7 +190,7 @@
|
|||||||
SELECT t1.id, t1.label_group_name, t2.`name` AS editName, t2.mobile AS editMobile, t1.edit_date
|
SELECT t1.id, t1.label_group_name, t2.`name` AS editName, t2.mobile AS editMobile, t1.edit_date
|
||||||
FROM hy_partner_label_group t1
|
FROM hy_partner_label_group t1
|
||||||
LEFT JOIN enterprise_user t2 ON t1.edit_user_id = t2.user_id
|
LEFT JOIN enterprise_user t2 ON t1.edit_user_id = t2.user_id
|
||||||
WHERE t1.deleted = 0 AND t2.deleted = 0
|
WHERE t1.deleted = 0
|
||||||
<if test="labelGroupName != null and labelGroupName != ''">
|
<if test="labelGroupName != null and labelGroupName != ''">
|
||||||
AND t1.label_group_name LIKE CONCAT('%', #{labelGroupName}, '%')
|
AND t1.label_group_name LIKE CONCAT('%', #{labelGroupName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.cool.store.dto.label.LabelGroupAddDTO;
|
|||||||
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupListDTO;
|
import com.cool.store.dto.label.LabelGroupListDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
||||||
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.vo.LabelGroupListVo;
|
import com.cool.store.vo.LabelGroupListVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -36,7 +37,7 @@ public interface LabelGroupService {
|
|||||||
* 删除标签组
|
* 删除标签组
|
||||||
* @param dto 待删除标签组信息
|
* @param dto 待删除标签组信息
|
||||||
*/
|
*/
|
||||||
void deleteLabelGroup(LabelGroupDeleteDTO dto);
|
void deleteLabelGroup(LabelGroupDeleteDTO dto) throws ApiException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有标签组
|
* 获取所有标签组
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
|||||||
import com.cool.store.dto.label.LabelGroupListDTO;
|
import com.cool.store.dto.label.LabelGroupListDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
||||||
import com.cool.store.entity.HyPartnerLabelGroupDO;
|
import com.cool.store.entity.HyPartnerLabelGroupDO;
|
||||||
|
import com.cool.store.enums.ErrorCodeEnum;
|
||||||
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.mapper.HyPartnerLabelGroupMapper;
|
import com.cool.store.mapper.HyPartnerLabelGroupMapper;
|
||||||
|
import com.cool.store.mapper.HyPartnerLabelMapper;
|
||||||
import com.cool.store.service.LabelGroupService;
|
import com.cool.store.service.LabelGroupService;
|
||||||
import com.cool.store.vo.LabelGroupListVo;
|
import com.cool.store.vo.LabelGroupListVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -25,6 +28,9 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private HyPartnerLabelGroupMapper labelGroupMapper;
|
private HyPartnerLabelGroupMapper labelGroupMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HyPartnerLabelMapper labelMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签组信息列表
|
* 查询标签组信息列表
|
||||||
* @param dto 查询条件
|
* @param dto 查询条件
|
||||||
@@ -33,7 +39,7 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
public List<LabelGroupListVo> getLabelGroupList(LabelGroupListDTO dto) {
|
public List<LabelGroupListVo> getLabelGroupList(LabelGroupListDTO dto) {
|
||||||
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
||||||
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
|
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
|
||||||
return this.labelGroupMapper.getLabelGroupList(labelGroupDO);
|
return labelGroupMapper.getLabelGroupList(labelGroupDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +55,7 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
labelGroupDO.setEditDate(new Date());
|
labelGroupDO.setEditDate(new Date());
|
||||||
labelGroupDO.setCreateUserId(userId);
|
labelGroupDO.setCreateUserId(userId);
|
||||||
labelGroupDO.setUpdateUserId(userId);
|
labelGroupDO.setUpdateUserId(userId);
|
||||||
this.labelGroupMapper.insertSelective(labelGroupDO);
|
labelGroupMapper.insertSelective(labelGroupDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +71,7 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
labelGroupDO.setEditUserId(userId);
|
labelGroupDO.setEditUserId(userId);
|
||||||
labelGroupDO.setEditDate(new Date());
|
labelGroupDO.setEditDate(new Date());
|
||||||
labelGroupDO.setUpdateUserId(userId);
|
labelGroupDO.setUpdateUserId(userId);
|
||||||
this.labelGroupMapper.updateByPrimaryKeySelective(labelGroupDO);
|
labelGroupMapper.updateByPrimaryKeySelective(labelGroupDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,13 +79,16 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
* @param dto 待删除标签组信息
|
* @param dto 待删除标签组信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteLabelGroup(LabelGroupDeleteDTO dto) {
|
public void deleteLabelGroup(LabelGroupDeleteDTO dto) throws ApiException {
|
||||||
|
if (whetherGroupInUse(dto.getId())) {
|
||||||
|
throw new ApiException(ErrorCodeEnum.LABEL_GROUP_IN_USE);
|
||||||
|
}
|
||||||
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
||||||
String userId = CurrentUserHolder.getUserId();
|
String userId = CurrentUserHolder.getUserId();
|
||||||
labelGroupDO.setId(dto.getId());
|
labelGroupDO.setId(dto.getId());
|
||||||
labelGroupDO.setDeleted(Boolean.TRUE);
|
labelGroupDO.setDeleted(Boolean.TRUE);
|
||||||
labelGroupDO.setUpdateUserId(userId);
|
labelGroupDO.setUpdateUserId(userId);
|
||||||
this.labelGroupMapper.updateByPrimaryKeySelective(labelGroupDO);
|
labelGroupMapper.updateByPrimaryKeySelective(labelGroupDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +97,15 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
@Override
|
@Override
|
||||||
public List<LabelGroupListVo> getAllLabelGroupList() {
|
public List<LabelGroupListVo> getAllLabelGroupList() {
|
||||||
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
||||||
return this.labelGroupMapper.getLabelGroupList(labelGroupDO);
|
return labelGroupMapper.getLabelGroupList(labelGroupDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 某个标签组内是否有未删除的标签
|
||||||
|
* @param id 标签组 id
|
||||||
|
*/
|
||||||
|
private Boolean whetherGroupInUse(Long id) {
|
||||||
|
return labelMapper.whetherGroupInUse(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.cool.store.dto.label.LabelGroupAddDTO;
|
|||||||
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupListDTO;
|
import com.cool.store.dto.label.LabelGroupListDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
||||||
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.response.ResponseResult;
|
import com.cool.store.response.ResponseResult;
|
||||||
import com.cool.store.service.LabelGroupService;
|
import com.cool.store.service.LabelGroupService;
|
||||||
import com.cool.store.vo.LabelGroupListVo;
|
import com.cool.store.vo.LabelGroupListVo;
|
||||||
@@ -34,35 +35,35 @@ public class LabelGroupController {
|
|||||||
@PostMapping({"/list"})
|
@PostMapping({"/list"})
|
||||||
public ResponseResult<PageInfo<LabelGroupListVo>> getLabelGroupList(@RequestBody LabelGroupListDTO dto) {
|
public ResponseResult<PageInfo<LabelGroupListVo>> getLabelGroupList(@RequestBody LabelGroupListDTO dto) {
|
||||||
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
||||||
List<LabelGroupListVo> result = this.labelGroupService.getLabelGroupList(dto);
|
List<LabelGroupListVo> result = labelGroupService.getLabelGroupList(dto);
|
||||||
return ResponseResult.success(new PageInfo<>(result));
|
return ResponseResult.success(new PageInfo<>(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增标签组")
|
@ApiOperation("新增标签组")
|
||||||
@PostMapping({"/add"})
|
@PostMapping({"/add"})
|
||||||
public ResponseResult addLabelGroup(@RequestBody LabelGroupAddDTO dto) {
|
public ResponseResult addLabelGroup(@RequestBody LabelGroupAddDTO dto) {
|
||||||
this.labelGroupService.addLabelGroup(dto);
|
labelGroupService.addLabelGroup(dto);
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改标签组")
|
@ApiOperation("修改标签组")
|
||||||
@PostMapping({"/edit"})
|
@PostMapping({"/edit"})
|
||||||
public ResponseResult updateLabelGroup(@RequestBody LabelGroupUpdateDTO dto) {
|
public ResponseResult updateLabelGroup(@RequestBody LabelGroupUpdateDTO dto) {
|
||||||
this.labelGroupService.updateLabelGroup(dto);
|
labelGroupService.updateLabelGroup(dto);
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除标签组")
|
@ApiOperation("删除标签组")
|
||||||
@PostMapping({"/delete"})
|
@PostMapping({"/delete"})
|
||||||
public ResponseResult deleteLabelGroup(@RequestBody LabelGroupDeleteDTO dto) {
|
public ResponseResult deleteLabelGroup(@RequestBody LabelGroupDeleteDTO dto) throws ApiException {
|
||||||
this.labelGroupService.deleteLabelGroup(dto);
|
labelGroupService.deleteLabelGroup(dto);
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取所有标签组")
|
@ApiOperation("获取所有标签组")
|
||||||
@PostMapping({"/allList"})
|
@PostMapping({"/allList"})
|
||||||
public ResponseResult<List<LabelGroupListVo>> deleteLabelGroup() {
|
public ResponseResult<List<LabelGroupListVo>> deleteLabelGroup() {
|
||||||
return ResponseResult.success(this.labelGroupService.getAllLabelGroupList());
|
return ResponseResult.success(labelGroupService.getAllLabelGroupList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user