Browse Source

分类

dev_shibei_match
yinzuomei 4 years ago
parent
commit
005487aeba
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 47
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/EditGuideCategoryFormDTO.java
  3. 56
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCateOrderFormDTO.java
  4. 65
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java
  5. 34
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java
  6. 40
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java
  7. 59
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java
  8. 41
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -74,6 +74,7 @@ public enum EpmetErrorCode {
AREA_CODE_ALREADY_EXISTS(8208,"组织区划已被占用,请重新选择"), AREA_CODE_ALREADY_EXISTS(8208,"组织区划已被占用,请重新选择"),
AGENCY_NAME_ALREADY_EXISTS(8209,"当前组织名称已存在,请重新修改"), AGENCY_NAME_ALREADY_EXISTS(8209,"当前组织名称已存在,请重新修改"),
SET_PARENT_AREA_CODE(8210,"请先设置上级组织区划"), SET_PARENT_AREA_CODE(8210,"请先设置上级组织区划"),
HAVE_GUIDE_CANNOT_DEL(8211,"当前分类已经存在办事指南,不允许删除"),
REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"),
THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"),

47
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/EditGuideCategoryFormDTO.java

@ -0,0 +1,47 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 编辑禁用删除统一入参
* @Author yinzuomei
* @Date 2021/9/8 4:15 下午
*/
@Data
public class EditGuideCategoryFormDTO implements Serializable {
private static final long serialVersionUID = -6853534660181580456L;
public interface AddUserInternalGroup {
}
public interface StatusGroup {
}
public interface UpdateInfoGroup extends CustomerClientShowGroup {
}
public interface DelGroup {
}
@NotBlank(message = "当前操作人id不能为空", groups = AddUserInternalGroup.class)
private String staffId;
@NotBlank(message = "客户id不能为空",groups = DelGroup.class)
private String customerId;
@NotBlank(message = "id不能为空", groups = AddUserInternalGroup.class)
private String id;
@NotBlank(message = "status不能为空", groups = StatusGroup.class)
private String status;
@NotBlank(message = "分类名称不能为空不能为空", groups = UpdateInfoGroup.class)
@Length(max = 10, message = "分类名称最多填入10个字", groups = UpdateInfoGroup.class)
private String categoryName;
}

56
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCateOrderFormDTO.java

@ -0,0 +1,56 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.List;
/**
* @Description 分类排序入参DTO
* @Author yinzuomei
* @Date 2021/9/8 4:03 下午
*/
@Data
public class GuideCateOrderFormDTO implements Serializable {
private static final long serialVersionUID = 8671295475212569124L;
public interface AddUserInternalGroup {
}
@NotBlank(message = "当前操作人id不能为空", groups = AddUserInternalGroup.class)
private String staffId;
@NotEmpty(message = "顺序不能为空", groups = {AddUserInternalGroup.class})
private List<OrderIndexDTO> orderList;
/**
* 排序索引号dto
*/
public static class OrderIndexDTO {
private String id;
private Integer orderIndex;
public OrderIndexDTO() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getOrderIndex() {
return orderIndex;
}
public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}
}
}

65
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java

@ -21,12 +21,13 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.GuideCategoryDTO; import com.epmet.dto.GuideCategoryDTO;
import com.epmet.dto.form.EditGuideCategoryFormDTO;
import com.epmet.dto.form.GuideCateOrderFormDTO;
import com.epmet.dto.form.GuideCategoryDropDownFormDTO; import com.epmet.dto.form.GuideCategoryDropDownFormDTO;
import com.epmet.dto.form.GuideCategoryPageFormDTO; import com.epmet.dto.form.GuideCategoryPageFormDTO;
import com.epmet.dto.result.GuideDictResDTO; import com.epmet.dto.result.GuideDictResDTO;
@ -81,17 +82,58 @@ public class GuideCategoryController {
} }
/**
* 保存排序
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @author yinzuomei
* @date 2021/9/8 4:09 下午
*/
@PostMapping("saveorder")
public Result saveOrder(@LoginUser TokenDto tokenDto,@RequestBody GuideCateOrderFormDTO formDTO){
formDTO.setStaffId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO,GuideCateOrderFormDTO.AddUserInternalGroup.class);
guideCategoryService.saveOrder(formDTO);
return new Result();
}
/**
* 禁用或者启用分类
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @author yinzuomei
* @date 2021/9/8 4:19 下午
*/
@PostMapping("disable")
public Result disable(@LoginUser TokenDto tokenDto,@RequestBody EditGuideCategoryFormDTO formDTO){
formDTO.setStaffId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO,EditGuideCategoryFormDTO.AddUserInternalGroup.class,EditGuideCategoryFormDTO.StatusGroup.class);
guideCategoryService.disableGuideCategory(formDTO);
return new Result();
}
/**
* 删除分类已经存在指南的不允许删除给予提示
*
@GetMapping("{id}") * @param tokenDto
public Result<GuideCategoryDTO> get(@PathVariable("id") String id){ * @param formDTO
GuideCategoryDTO data = guideCategoryService.get(id); * @return com.epmet.commons.tools.utils.Result
return new Result<GuideCategoryDTO>().ok(data); * @author yinzuomei
* @date 2021/9/8 4:45 下午
*/
@PostMapping("delete")
public Result delete(@LoginUser TokenDto tokenDto,@RequestBody EditGuideCategoryFormDTO formDTO){
formDTO.setStaffId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO,EditGuideCategoryFormDTO.AddUserInternalGroup.class,EditGuideCategoryFormDTO.DelGroup.class);
guideCategoryService.delete(formDTO);
return new Result();
} }
@PostMapping @PostMapping
public Result save(@RequestBody GuideCategoryDTO dto){ public Result save(@RequestBody GuideCategoryDTO dto){
//效验数据 //效验数据
@ -108,12 +150,5 @@ public class GuideCategoryController {
return new Result(); return new Result();
} }
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
guideCategoryService.delete(ids);
return new Result();
}
} }

34
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java

@ -55,4 +55,38 @@ public interface GuideCategoryDao extends BaseDao<GuideCategoryEntity> {
* @date 2021/9/8 3:15 下午 * @date 2021/9/8 3:15 下午
*/ */
List<GuideDictResDTO> selectCategoryDict(@Param("customerId") String customerId, @Param("queryOrigin") String queryOrigin); List<GuideDictResDTO> selectCategoryDict(@Param("customerId") String customerId, @Param("queryOrigin") String queryOrigin);
/**
* 保存排序
*
* @param id
* @param orderIndex
* @param staffId
* @return int
* @author yinzuomei
* @date 2021/9/8 4:11 下午
*/
int updateOrder(@Param("id") String id, @Param("orderIndex") Integer orderIndex, @Param("staffId") String staffId);
/**
* 启用或者禁用
*
* @param id
* @param status
* @param staffId
* @return int
* @author yinzuomei
* @date 2021/9/8 4:22 下午
*/
int updateStatus(@Param("id") String id, @Param("status")String status, @Param("staffId")String staffId);
/**
* 查询这个分类下的项目数
*
* @param id
* @return int
* @author yinzuomei
* @date 2021/9/8 4:36 下午
*/
int selectGuideTotal(@Param("id") String id,@Param("customerId") String customerId);
} }

40
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java

@ -20,13 +20,14 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.GuideCategoryDTO; import com.epmet.dto.GuideCategoryDTO;
import com.epmet.dto.form.EditGuideCategoryFormDTO;
import com.epmet.dto.form.GuideCateOrderFormDTO;
import com.epmet.dto.form.GuideCategoryDropDownFormDTO; import com.epmet.dto.form.GuideCategoryDropDownFormDTO;
import com.epmet.dto.form.GuideCategoryPageFormDTO; import com.epmet.dto.form.GuideCategoryPageFormDTO;
import com.epmet.dto.result.GuideDictResDTO; import com.epmet.dto.result.GuideDictResDTO;
import com.epmet.entity.GuideCategoryEntity; import com.epmet.entity.GuideCategoryEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 指南分类 * 指南分类
@ -57,24 +58,25 @@ public interface GuideCategoryService extends BaseService<GuideCategoryEntity> {
List<GuideDictResDTO> getCategory(GuideCategoryDropDownFormDTO formDTO); List<GuideDictResDTO> getCategory(GuideCategoryDropDownFormDTO formDTO);
/** /**
* 默认查询 * 保存排序
* *
* @param params * @param formDTO
* @return java.util.List<GuideCategoryDTO> * @return void
* @author generator * @author yinzuomei
* @date 2021-09-06 * @date 2021/9/8 4:09 下午
*/ */
List<GuideCategoryDTO> list(Map<String, Object> params); void saveOrder(GuideCateOrderFormDTO formDTO);
/** /**
* 单条查询 * 启用或者禁用分类
* *
* @param id * @param formDTO
* @return GuideCategoryDTO * @return int
* @author generator * @author yinzuomei
* @date 2021-09-06 * @date 2021/9/8 4:20 下午
*/ */
GuideCategoryDTO get(String id); void disableGuideCategory(EditGuideCategoryFormDTO formDTO);
/** /**
* 默认保存 * 默认保存
@ -97,12 +99,12 @@ public interface GuideCategoryService extends BaseService<GuideCategoryEntity> {
void update(GuideCategoryDTO dto); void update(GuideCategoryDTO dto);
/** /**
* 批量删除 * 删除分类存在办事指南的不允许删除给予提示
* *
* @param ids * @param formDTO
* @return void * @return void
* @author generator * @author yinzuomei
* @date 2021-09-06 * @date 2021/9/8 4:34 下午
*/ */
void delete(String[] ids); void delete(EditGuideCategoryFormDTO formDTO);
} }

59
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java

@ -21,10 +21,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.GuideCategoryDao; import com.epmet.dao.GuideCategoryDao;
import com.epmet.dto.GuideCategoryDTO; import com.epmet.dto.GuideCategoryDTO;
import com.epmet.dto.form.EditGuideCategoryFormDTO;
import com.epmet.dto.form.GuideCateOrderFormDTO;
import com.epmet.dto.form.GuideCategoryDropDownFormDTO; import com.epmet.dto.form.GuideCategoryDropDownFormDTO;
import com.epmet.dto.form.GuideCategoryPageFormDTO; import com.epmet.dto.form.GuideCategoryPageFormDTO;
import com.epmet.dto.result.GuideDictResDTO; import com.epmet.dto.result.GuideDictResDTO;
@ -36,7 +40,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -117,12 +120,33 @@ public class GuideCategoryServiceImpl extends BaseServiceImpl<GuideCategoryDao,
return list; return list;
} }
/**
* 保存排序
*
* @param formDTO
* @return void
* @author yinzuomei
* @date 2021/9/8 4:09 下午
*/
@Transactional
@Override @Override
public List<GuideCategoryDTO> list(Map<String, Object> params) { public void saveOrder(GuideCateOrderFormDTO formDTO) {
List<GuideCategoryEntity> entityList = baseDao.selectList(getWrapper(params)); for (GuideCateOrderFormDTO.OrderIndexDTO idx : formDTO.getOrderList()) {
baseDao.updateOrder(idx.getId(), idx.getOrderIndex(),formDTO.getStaffId());
}
}
return ConvertUtils.sourceToTarget(entityList, GuideCategoryDTO.class); /**
* 启用或者禁用分类
*
* @param formDTO
* @return int
* @author yinzuomei
* @date 2021/9/8 4:20 下午
*/
@Override
public void disableGuideCategory(EditGuideCategoryFormDTO formDTO) {
baseDao.updateStatus(formDTO.getId(), formDTO.getStatus(),formDTO.getStaffId());
} }
private QueryWrapper<GuideCategoryEntity> getWrapper(Map<String, Object> params){ private QueryWrapper<GuideCategoryEntity> getWrapper(Map<String, Object> params){
@ -134,12 +158,6 @@ public class GuideCategoryServiceImpl extends BaseServiceImpl<GuideCategoryDao,
return wrapper; return wrapper;
} }
@Override
public GuideCategoryDTO get(String id) {
GuideCategoryEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, GuideCategoryDTO.class);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(GuideCategoryDTO dto) { public void save(GuideCategoryDTO dto) {
@ -154,11 +172,22 @@ public class GuideCategoryServiceImpl extends BaseServiceImpl<GuideCategoryDao,
updateById(entity); updateById(entity);
} }
/**
* 删除分类存在办事指南的不允许删除给予提示
*
* @param formDTO
* @return void
* @author yinzuomei
* @date 2021/9/8 4:34 下午
*/
@Override @Override
@Transactional(rollbackFor = Exception.class) public void delete(EditGuideCategoryFormDTO formDTO) {
public void delete(String[] ids) { // 存在指南的分类不允许删除
// 逻辑删除(@TableLogic 注解) if(baseDao.selectGuideTotal(formDTO.getId(),formDTO.getCustomerId())>0){
baseDao.deleteBatchIds(Arrays.asList(ids)); throw new RenException(EpmetErrorCode.HAVE_GUIDE_CANNOT_DEL.getCode(),EpmetErrorCode.HAVE_GUIDE_CANNOT_DEL.getMsg());
}
baseDao.deleteById(formDTO.getId());
} }
} }

41
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml

@ -49,4 +49,45 @@
ORDER BY ORDER BY
temp.sort ASC temp.sort ASC
</select> </select>
<!-- 保存排序-->
<update id="updateOrder" parameterType="map">
update guide_category
set SORT=#{orderIndex},
UPDATED_BY=#{staffId},
UPDATED_TIME=NOW()
where id=#{id}
and del_flag='0'
</update>
<!-- 启用或者禁用-->
<update id="updateStatus" parameterType="map">
update guide_category
set status=#{status},
UPDATED_BY=#{staffId},
UPDATED_TIME=NOW()
where id=#{id}
and del_flag='0'
</update>
<!-- 查询分类下的办事指南数量-->
<select id="selectGuideTotal" parameterType="map" resultType="int">
SELECT
count( id ) AS total
FROM
guide g
WHERE
g.DEL_FLAG = '0'
AND g.CUSTOMER_ID = #{customerId}
AND g.CATEGORY_CODE =(
SELECT
gc.CATEGORY_CODE
FROM
guide_category gc
WHERE
gc.DEL_FLAG = '0'
AND gc.id = #{id}
)
</select>
</mapper> </mapper>
Loading…
Cancel
Save