Browse Source

积分规则相关接口

feature/teamB_zz_wgh
Jackwang 3 years ago
parent
commit
a2eb09de03
  1. 45
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/CategorydetailResultDTO.java
  2. 32
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddcategoryFormDTO.java
  3. 44
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddruleFormDTO.java
  4. 36
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4applyFormDTO.java
  5. 27
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4treeFormDTO.java
  6. 41
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointAddRuleEnum.java
  7. 87
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java
  8. 46
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java
  9. 62
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java
  10. 70
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java
  11. 56
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml

45
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/CategorydetailResultDTO.java

@ -0,0 +1,45 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-06-15 10:44
**/
@Data
public class CategorydetailResultDTO implements Serializable {
/**
*类别ID
*/
private String id;
/**
*类别名
*/
private String categoryName;
/**
*上级类别ID
*/
private String pid;
/**
*上级类别名
*/
private String parentCategoryName;
/**
*创建时间
*/
private String createdTime;
/**
*修改时间
*/
private String updatedTime;
}

32
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddcategoryFormDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-06-15 11:12
**/
@Data
public class AddcategoryFormDTO implements Serializable {
/**
*类别名称
*/
@NotNull(message = "类别名称不可为空")
private String categoryName;
/**
*上级类别ID
*/
@NotNull(message = "上级类别不可为空")
private String pid;
private String customerId;
}

44
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddruleFormDTO.java

@ -0,0 +1,44 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-06-15 11:12
**/
@Data
public class AddruleFormDTO implements Serializable {
/**
*积分规则名称
*/
@NotNull(message = "积分规则名称不可为空")
private String ruleName;
/**
*上级类别ID
*/
@NotNull(message = "上级类别不可为空")
private String pid;
/**
*分值整数可以为负数(表示减分)
*/
@NotNull(message = "分值不可为空")
private Integer pointValue;
/**
*允许申请0不允许申请1
*/
@NotNull(message = "申请标记不可为空")
private String applyFlag;
private String customerId;
}

36
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4applyFormDTO.java

@ -0,0 +1,36 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-06-15 16:23
**/
@Data
public class List4applyFormDTO implements Serializable {
/**
*允许申请0不允许申请1
*/
private String applyFlag;
/**
*类别
*/
@NotNull(message = "类别不可为空")
private String categoryCode;
/**
* 记录类型;分类:category规则:rule
*/
private String type;
private String customerId;
}

27
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4treeFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-06-15 10:10
**/
@Data
public class List4treeFormDTO implements Serializable {
/**
* 类别名称
*/
private String categoryName;
/**
* 规则名称
*/
private String ruleName;
private String customerId;
}

41
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointAddRuleEnum.java

@ -0,0 +1,41 @@
package com.epmet.common.enu;
/**
* @describe: 积分规则枚举类
* @author wangtong
* @date 2022/6/15 13:54
*/
public enum PointAddRuleEnum {
CATEGORY_TYPE("category", "分类"),
RULE_TYPE("rule", "规则"),
APPLY_ALLOW("0", "允许"),
APPLY_BAN("1", "禁止"),
;
private String code;
private String desc;
PointAddRuleEnum(String code, String name) {
this.code = code;
this.desc = name;
}
public static PointAddRuleEnum getEnum(String code) {
PointAddRuleEnum[] values = PointAddRuleEnum.values();
for (PointAddRuleEnum value : values) {
if (code != null && value.getCode().equals(code)) {
return value;
}
}
return null;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

87
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java

@ -1,15 +1,22 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.aop.NoRepeatSubmit;
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.utils.ExcelUtils; import com.epmet.commons.tools.utils.ExcelUtils;
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.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.UpdateGroup;
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.dto.CategorydetailResultDTO;
import com.epmet.dto.PointAdditiveRuleDTO; import com.epmet.dto.PointAdditiveRuleDTO;
import com.epmet.dto.form.AddcategoryFormDTO;
import com.epmet.dto.form.AddruleFormDTO;
import com.epmet.dto.form.List4applyFormDTO;
import com.epmet.dto.form.List4treeFormDTO;
import com.epmet.excel.PointAdditiveRuleExcel; import com.epmet.excel.PointAdditiveRuleExcel;
import com.epmet.service.PointAdditiveRuleService; import com.epmet.service.PointAdditiveRuleService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,7 +34,7 @@ import java.util.Map;
* @since v1.0.0 2022-06-15 * @since v1.0.0 2022-06-15
*/ */
@RestController @RestController
@RequestMapping("pointAdditiveRule") @RequestMapping("additiverule")
public class PointAdditiveRuleController { public class PointAdditiveRuleController {
@Autowired @Autowired
@ -77,6 +84,82 @@ public class PointAdditiveRuleController {
ExcelUtils.exportExcelToTarget(response, null, list, PointAdditiveRuleExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, PointAdditiveRuleExcel.class);
} }
/**
* @describe: 查询积分类别规则列表
* @author wangtong
* @date 2022/6/15 10:11
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("list4tree")
public Result<List<PointAdditiveRuleDTO>> list4tree(@LoginUser TokenDto tokenDto, @RequestBody List4treeFormDTO dto){
dto.setCustomerId(tokenDto.getCustomerId());
return pointAdditiveRuleService.list4tree(dto);
}
/**
* @describe: 查询下级类别简要信息
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
@PostMapping("subcategory/listbrief/{categoryId}")
public Result<List<PointAdditiveRuleDTO>> listbrief(@PathVariable("categoryId") String categoryId){
return pointAdditiveRuleService.listbrief(categoryId);
}
/**
* @describe: 查询积分类别详情
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
@PostMapping("categorydetail/{categoryId}")
public Result<CategorydetailResultDTO> categorydetail(@PathVariable("categoryId") String categoryId){
return pointAdditiveRuleService.categorydetail(categoryId);
}
/**
* @describe: 添加积分类别
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
@PostMapping("addcategory")
public Result addcategory(@LoginUser TokenDto tokenDto,@RequestBody AddcategoryFormDTO dto){
ValidatorUtils.validateEntity(dto);
dto.setCustomerId(tokenDto.getCustomerId());
return pointAdditiveRuleService.addcategory(dto);
}
/**
* @describe: 添加积分规则
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
@PostMapping("addrule")
public Result addrule(@LoginUser TokenDto tokenDto,@RequestBody AddruleFormDTO dto){
ValidatorUtils.validateEntity(dto);
dto.setCustomerId(tokenDto.getCustomerId());
return pointAdditiveRuleService.addrule(dto);
}
/**
* @describe: [附加积分]获取允许申请的积分类别
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
@PostMapping("list4apply")
public Result<List<PointAdditiveRuleDTO>> list4apply(@LoginUser TokenDto tokenDto,@RequestBody List4applyFormDTO dto){
ValidatorUtils.validateEntity(dto);
dto.setCustomerId(tokenDto.getCustomerId());
return pointAdditiveRuleService.list4apply(dto);
}
} }

46
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java

@ -1,8 +1,15 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CategorydetailResultDTO;
import com.epmet.dto.PointAdditiveRuleDTO;
import com.epmet.dto.form.List4applyFormDTO;
import com.epmet.dto.form.List4treeFormDTO;
import com.epmet.entity.PointAdditiveRuleEntity; import com.epmet.entity.PointAdditiveRuleEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 附加积分规则 * 附加积分规则
@ -12,5 +19,40 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface PointAdditiveRuleDao extends BaseDao<PointAdditiveRuleEntity> { public interface PointAdditiveRuleDao extends BaseDao<PointAdditiveRuleEntity> {
} /**
* @describe: 查询下级类别简要信息
* @author wangtong
* @date 2022/6/15 10:30
* @params [categoryId]
* @return java.util.List<com.epmet.dto.PointAdditiveRuleDTO>
*/
List<PointAdditiveRuleDTO> selectListbrief(@Param("categoryId") String categoryId);
/**
* @describe: 查询积分类别详情
* @author wangtong
* @date 2022/6/15 10:52
* @params [categoryId]
* @return com.epmet.dto.CategorydetailResultDTO
*/
CategorydetailResultDTO selectCategorydetail(@Param("categoryId") String categoryId);
/**
* @describe: [附加积分]获取允许申请的积分类别
* @author wangtong
* @date 2022/6/15 16:29
* @params [dto]
* @return java.util.List<com.epmet.dto.PointAdditiveRuleDTO>
*/
List<PointAdditiveRuleDTO> selectList4apply(List4applyFormDTO dto);
/**
* @describe: 查询积分类别规则列表
* @author wangtong
* @date 2022/6/15 16:43
* @params [dto]
* @return java.util.List<com.epmet.dto.PointAdditiveRuleDTO>
*/
List<PointAdditiveRuleDTO> selectList4tree(List4treeFormDTO dto);
}

62
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java

@ -2,7 +2,13 @@ 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.commons.tools.utils.Result;
import com.epmet.dto.CategorydetailResultDTO;
import com.epmet.dto.PointAdditiveRuleDTO; import com.epmet.dto.PointAdditiveRuleDTO;
import com.epmet.dto.form.AddcategoryFormDTO;
import com.epmet.dto.form.AddruleFormDTO;
import com.epmet.dto.form.List4applyFormDTO;
import com.epmet.dto.form.List4treeFormDTO;
import com.epmet.entity.PointAdditiveRuleEntity; import com.epmet.entity.PointAdditiveRuleEntity;
import java.util.List; import java.util.List;
@ -75,4 +81,58 @@ public interface PointAdditiveRuleService extends BaseService<PointAdditiveRuleE
* @date 2022-06-15 * @date 2022-06-15
*/ */
void delete(String[] ids); void delete(String[] ids);
}
/**
* @describe: 查询下级类别简要信息
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
Result<List<PointAdditiveRuleDTO>> listbrief(String categoryId);
/**
* @describe: 查询积分类别详情
* @author wangtong
* @date 2022/6/15 10:49
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CategorydetailResultDTO>
*/
Result<CategorydetailResultDTO> categorydetail(String categoryId);
/**
* @describe: 添加积分类别
* @author wangtong
* @date 2022/6/15 11:14
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
Result addcategory(AddcategoryFormDTO dto);
/**
* @describe: 添加积分规则
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
Result addrule(AddruleFormDTO dto);
/**
* @describe: [附加积分]获取允许申请的积分类别
* @author wangtong
* @date 2022/6/15 10:23
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
Result<List<PointAdditiveRuleDTO>> list4apply(List4applyFormDTO dto);
/**
* @describe: 查询积分类别规则列表
* @author wangtong
* @date 2022/6/15 10:11
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
Result<List<PointAdditiveRuleDTO>> list4tree(List4treeFormDTO dto);
}

70
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java

@ -2,12 +2,20 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.common.enu.PointAddRuleEnum;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
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.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.PointAdditiveRuleDao; import com.epmet.dao.PointAdditiveRuleDao;
import com.epmet.dto.CategorydetailResultDTO;
import com.epmet.dto.PointAdditiveRuleDTO; import com.epmet.dto.PointAdditiveRuleDTO;
import com.epmet.dto.form.AddcategoryFormDTO;
import com.epmet.dto.form.AddruleFormDTO;
import com.epmet.dto.form.List4applyFormDTO;
import com.epmet.dto.form.List4treeFormDTO;
import com.epmet.entity.PointAdditiveRuleEntity; import com.epmet.entity.PointAdditiveRuleEntity;
import com.epmet.redis.PointAdditiveRuleRedis; import com.epmet.redis.PointAdditiveRuleRedis;
import com.epmet.service.PointAdditiveRuleService; import com.epmet.service.PointAdditiveRuleService;
@ -84,4 +92,64 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl<PointAdditiveR
baseDao.deleteBatchIds(Arrays.asList(ids)); baseDao.deleteBatchIds(Arrays.asList(ids));
} }
} @Override
public Result<List<PointAdditiveRuleDTO>> listbrief(String categoryId) {
List<PointAdditiveRuleDTO> result = baseDao.selectListbrief(categoryId);
return new Result<List<PointAdditiveRuleDTO>>().ok(result);
}
@Override
public Result<CategorydetailResultDTO> categorydetail(String categoryId) {
CategorydetailResultDTO result = baseDao.selectCategorydetail(categoryId);
return new Result<CategorydetailResultDTO>().ok(result);
}
@Override
public Result addcategory(AddcategoryFormDTO dto) {
PointAdditiveRuleEntity entity = new PointAdditiveRuleEntity();
entity.setCustomerId(dto.getCustomerId());
entity.setType(PointAddRuleEnum.CATEGORY_TYPE.getCode());
entity.setApplyFlag(PointAddRuleEnum.APPLY_ALLOW.getCode());
entity.setCategoryName(dto.getCategoryName());
entity.setPid(dto.getPid());
if(!NumConstant.ZERO_STR.equals(dto.getPid())){
PointAdditiveRuleEntity parentEntity = baseDao.selectById(dto.getPid());
entity.setPids(parentEntity.getPids()+":"+parentEntity.getId());
entity.setCategoryCode(parentEntity.getCategoryCode());
}
insert(entity);
return new Result().ok("新增成功!");
}
@Override
public Result addrule(AddruleFormDTO dto) {
PointAdditiveRuleEntity entity = new PointAdditiveRuleEntity();
entity.setCustomerId(dto.getCustomerId());
entity.setType(PointAddRuleEnum.RULE_TYPE.getCode());
entity.setRuleName(dto.getRuleName());
entity.setApplyFlag(dto.getApplyFlag());
entity.setPointValue(dto.getPointValue());
entity.setPid(dto.getPid());
if(!NumConstant.ZERO_STR.equals(dto.getPid())){
PointAdditiveRuleEntity parentEntity = baseDao.selectById(dto.getPid());
entity.setCategoryCode(parentEntity.getCategoryCode());
entity.setPids(parentEntity.getPids()+":"+parentEntity.getId());
}
insert(entity);
return new Result().ok("新增成功!");
}
@Override
public Result<List<PointAdditiveRuleDTO>> list4apply(List4applyFormDTO dto) {
dto.setType(PointAddRuleEnum.CATEGORY_TYPE.getCode());
List<PointAdditiveRuleDTO> result = baseDao.selectList4apply(dto);
return new Result<List<PointAdditiveRuleDTO>>().ok(result);
}
@Override
public Result<List<PointAdditiveRuleDTO>> list4tree(List4treeFormDTO dto) {
List<PointAdditiveRuleDTO> result = baseDao.selectList4tree(dto);
return new Result<List<PointAdditiveRuleDTO>>().ok(result);
}
}

56
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml

@ -21,6 +21,60 @@
<result property="updatedBy" column="UPDATED_BY"/> <result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/> <result property="updatedTime" column="UPDATED_TIME"/>
</resultMap> </resultMap>
<select id="selectListbrief" resultType="com.epmet.dto.PointAdditiveRuleDTO">
select id,
CATEGORY_NAME
from point_additive_rule
where type = 'category'
and DEL_FLAG='0'
and pid = #{categoryId}
order by UPDATED_TIME desc
</select>
<select id="selectCategorydetail" resultType="com.epmet.dto.CategorydetailResultDTO">
select c.id,
c.CATEGORY_NAME as categoryName,
p.id as pid,
p.CATEGORY_NAME as parentCategoryName,
c.CREATED_TIME,
c.UPDATED_TIME
from point_additive_rule c
left join point_additive_rule p on c.PID = p.id and p.DEL_FLAG='0'
where c.type='category'
and c.DEL_FLAG='0'
and c.id = #{categoryId}
</select>
<select id="selectList4apply" resultType="com.epmet.dto.PointAdditiveRuleDTO">
select id,
RULE_NAME,
POINT_VALUE
from point_additive_rule
where DEL_FLAG='0'
and CATEGORY_CODE=#{categoryCode}
<if test="applyFlag != null and applyFlag != ''">
and APPLY_FLAG= #{applyFlag}
</if>
and TYPE=#{type}
and CUSTOMER_ID=#{customerId}
order by UPDATED_TIME desc
</select>
<select id="selectList4tree" resultType="com.epmet.dto.PointAdditiveRuleDTO">
select id,
type,
CATEGORY_NAME,
RULE_NAME,
APPLY_FLAG,
POINT_VALUE
from point_additive_rule
where DEL_FLAG='0'
<if test="categoryName != null and categoryName != ''">
and CATEGORY_NAME= #{categoryName}
</if>
<if test="ruleName != null and ruleName != ''">
and RULE_NAME= #{ruleName}
</if>
and CUSTOMER_ID=#{customerId}
order by UPDATED_TIME desc
</select>
</mapper> </mapper>

Loading…
Cancel
Save