diff --git a/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysSimpleDictDTO.java b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysSimpleDictDTO.java index 493c0f1cf..4ff6d87c6 100644 --- a/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysSimpleDictDTO.java +++ b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysSimpleDictDTO.java @@ -28,4 +28,6 @@ public class SysSimpleDictDTO implements Serializable { @ApiModelProperty(value = "字典值") private String dictValue; -} \ No newline at end of file + @ApiModelProperty(value = "备注") + private String remark; +} diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java index b3f79c64a..5b5a69ffa 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java @@ -134,7 +134,7 @@ public class SysDictServiceImpl extends BaseServiceImpl sdWrapper = new QueryWrapper<>(); - sdWrapper.select("dict_value", "dict_name"); + sdWrapper.select("dict_value", "dict_name","remark"); sdWrapper.eq("dict_type", dictType); sdWrapper.ne("dict_value", ""); sdWrapper.isNotNull("dict_value"); diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java index e30fba46a..fe63c4596 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java @@ -145,4 +145,15 @@ public class RedisKeys { public static String getEventsCategoryKey() { return rootPrefix.concat("options:category:events"); } + + /** + * @param ruleCode 积分规则编码 + * @return java.lang.String + * @Author yinzuomei + * @Description 积分规则 + * @Date 2019/12/12 10:02 + **/ + public static String getPointsRuleKey(String ruleCode) { + return rootPrefix.concat("points:rule:").concat(ruleCode); + } } diff --git a/esua-epdc/epdc-gateway/src/main/resources/application.yml b/esua-epdc/epdc-gateway/src/main/resources/application.yml index 3908b03c0..fec4b9a67 100644 --- a/esua-epdc/epdc-gateway/src/main/resources/application.yml +++ b/esua-epdc/epdc-gateway/src/main/resources/application.yml @@ -146,9 +146,9 @@ spring: - Path=${server.servlet.context-path}/kpi/** filters: - StripPrefix=1 - #绩效考核模块 - - id: epdc-kpi-server - uri: @gateway.routes.epdc-kpi-server.uri@ + #积分管理 + - id: epdc-points-server + uri: @gateway.routes.epdc-points-server.uri@ order: 17 predicates: - Path=${server.servlet.context-path}/points/** diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml b/esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml index 73ab0b2b7..6beca7732 100644 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml @@ -11,5 +11,12 @@ epdc-points-client jar + + + com.esua.epdc + epdc-commons-tools + 1.0.0 + + diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/rule/PointsRuleDTO.java b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/rule/PointsRuleDTO.java new file mode 100644 index 000000000..d1c0f57a7 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/rule/PointsRuleDTO.java @@ -0,0 +1,122 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto.rule; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@Data +public class PointsRuleDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 规则编码 + */ + private String ruleCode; + + /** + * 规则描述 + */ + private String ruleDesc; + + /** + * 积分值 + */ + private Integer points; + + /** + * 规则操作类型(0-减积分,1-加积分) + */ + private String operationType; + + /** + * 可用标记(0-不可用,1-可用) + */ + private String available; + + /** + * 积分行为编码 + */ + private String behaviorCode; + + /** + * 积分行为描述 + */ + private String behaviorDesc; + + /** + * 积分是否有上限限制(0-否,1-是) + */ + private String upperLimitFlag; + + /** + * 限制时限(0-分钟,1-小时,2-日,3-月,4-年) + */ + private String limitTimeType; + + /** + * 积分上限值 + */ + private Integer upperLimitVal; + + /** + * 删除标记 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/enums/PointsRuleEnum.java b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/enums/PointsRuleEnum.java new file mode 100644 index 000000000..d1af4767e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/enums/PointsRuleEnum.java @@ -0,0 +1,44 @@ +package com.elink.esua.epdc.enums; + +/** + * @Auther: yinzuomei + * @Date: 2019/12/12 15:04 + * @Description: 积分规则表枚举类 + */ +public enum PointsRuleEnum { + /** + * 规则操作类型(0-减积分,1-加积分) + */ + OPERATION_TYPE_ADD("1"), + OPERATION_TYPE_SUBSTRACT("0"), + + /** + * 可用标记(0-不可用,1-可用) + */ + AVAILABLE_TRUE("1"), + AVAILABLE_FALSE("0"), + + /** + * 积分是否有上限限制(0-否,1-是) + */ + UPPER_LIMIT_FLAG_TRUE("1"), + UPPER_LIMIT_FLAG_FALSE("0"), + /** + * 限制时限(0-分钟,1-小时,2-日,3-月,4-年) + */ + LIMIT_TIME_MINUTE("0"), + LIMIT_TIME_HOUR("1"), + LIMIT_TIME_DAY("2"), + LIMIT_TIME_MONTH("3"), + LIMIT_TIME_YEAR("4"); + + private String value; + + PointsRuleEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml b/esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml index 7e5d60b54..b2d5dc3ab 100644 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml @@ -78,6 +78,29 @@ dockerfile-maven-plugin + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + **/application*.yml + **/*.properties + logback-spring.xml + registry.conf + + + + ${basedir}/src/main/resources + + **/application*.yml + **/*.properties + logback-spring.xml + registry.conf + + + @@ -90,7 +113,7 @@ dev - 9060 + 9070 2 47.104.224.45 @@ -98,7 +121,7 @@ elink@888 - + root shibei@888 @@ -115,7 +138,7 @@ test - 9060 + 9070 2 47.104.224.45 @@ -123,7 +146,7 @@ elink@888 - + epdc elink888 @@ -140,7 +163,7 @@ prod - 9060 + 9070 2 47.104.224.45 @@ -148,7 +171,7 @@ elink@888 - + epdc elink888 diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/DemoController.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/DemoController.java deleted file mode 100644 index 48e87c871..000000000 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/DemoController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.elink.esua.epdc.controller; - -import com.elink.esua.epdc.commons.tools.utils.Result; -import com.elink.esua.epdc.dto.DemoDto; -import com.elink.esua.epdc.feign.DemoFeignClient; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * - * @author yujintao - * @email yujintao@elink-cn.com - * @date 2019/8/23 10:59 - */ -@RestController -@RequestMapping("demo") -public class DemoController { - - - @Autowired - private DemoFeignClient demoFeignClient; - - - @GetMapping("listAll") - public Result> listDemo(){ - Result> listResult = demoFeignClient.listDemo(); - return listResult; - } -} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/controller/PointsRuleController.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/controller/PointsRuleController.java new file mode 100644 index 000000000..290324bda --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/controller/PointsRuleController.java @@ -0,0 +1,92 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.dto.rule.PointsRuleDTO; +import com.elink.esua.epdc.modules.rule.excel.PointsRuleExcel; +import com.elink.esua.epdc.modules.rule.service.PointsRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@RestController +@RequestMapping("pointsrule") +public class PointsRuleController { + + @Autowired + private PointsRuleService pointsRuleService; + + @GetMapping("page") + public Result> page(@RequestParam Map params) { + PageData page = pointsRuleService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id) { + PointsRuleDTO data = pointsRuleService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody PointsRuleDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + return pointsRuleService.save(dto); + } + + @PutMapping + public Result update(@RequestBody PointsRuleDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + return pointsRuleService.update(dto); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + pointsRuleService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = pointsRuleService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, PointsRuleExcel.class); + } + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/dao/PointsRuleDao.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/dao/PointsRuleDao.java new file mode 100644 index 000000000..558b37d89 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/dao/PointsRuleDao.java @@ -0,0 +1,34 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@Mapper +public interface PointsRuleDao extends BaseDao { + + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/entity/PointsRuleEntity.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/entity/PointsRuleEntity.java new file mode 100644 index 000000000..488900d8a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/entity/PointsRuleEntity.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_points_rule") +public class PointsRuleEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 规则编码 + */ + private String ruleCode; + + /** + * 规则描述 + */ + private String ruleDesc; + + /** + * 积分值 + */ + private Integer points; + + /** + * 规则操作类型(0-减积分,1-加积分) + */ + private String operationType; + + /** + * 可用标记(0-不可用,1-可用) + */ + private String available; + + /** + * 积分行为编码 + */ + private String behaviorCode; + + /** + * 积分行为描述 + */ + private String behaviorDesc; + + /** + * 积分是否有上限限制(0-否,1-是) + */ + private String upperLimitFlag; + + /** + * 限制时限(0-分钟,1-小时,2-日,3-月,4-年) + */ + private String limitTimeType; + + /** + * 积分上限值 + */ + private Integer upperLimitVal; + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/excel/PointsRuleExcel.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/excel/PointsRuleExcel.java new file mode 100644 index 000000000..3342faeae --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/excel/PointsRuleExcel.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@Data +public class PointsRuleExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "规则编码") + private String ruleCode; + + @Excel(name = "规则描述") + private String ruleDesc; + + @Excel(name = "积分值") + private Integer points; + + @Excel(name = "规则操作类型(0-减积分,1-加积分)") + private String operationType; + + @Excel(name = "可用标记(0-不可用,1-可用)") + private String available; + + @Excel(name = "积分行为编码") + private String behaviorCode; + + @Excel(name = "积分行为描述") + private String behaviorDesc; + + @Excel(name = "积分是否有上限限制(0-否,1-是)") + private String upperLimitFlag; + + @Excel(name = "限制时限(0-分钟,1-小时,2-日,3-月,4-年)") + private String limitTimeType; + + @Excel(name = "积分上限值") + private Integer upperLimitVal; + + @Excel(name = "删除标记") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/redis/PointsRuleRedis.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/redis/PointsRuleRedis.java new file mode 100644 index 000000000..dd7028f6f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/redis/PointsRuleRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.redis; + +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@Component +public class PointsRuleRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/PointsRuleService.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/PointsRuleService.java new file mode 100644 index 000000000..d5472c745 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/PointsRuleService.java @@ -0,0 +1,97 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.rule.PointsRuleDTO; +import com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity; + +import java.util.List; +import java.util.Map; + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +public interface PointsRuleService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2019-12-11 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2019-12-11 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return PointsRuleDTO + * @author generator + * @date 2019-12-11 + */ + PointsRuleDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2019-12-11 + */ + Result save(PointsRuleDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2019-12-11 + */ + Result update(PointsRuleDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2019-12-11 + */ + void delete(String[] ids); + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/impl/PointsRuleServiceImpl.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/impl/PointsRuleServiceImpl.java new file mode 100644 index 000000000..c32bdaf86 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/impl/PointsRuleServiceImpl.java @@ -0,0 +1,178 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.rule.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.redis.RedisKeys; +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.rule.PointsRuleDTO; +import com.elink.esua.epdc.enums.PointsRuleEnum; +import com.elink.esua.epdc.modules.rule.dao.PointsRuleDao; +import com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity; +import com.elink.esua.epdc.modules.rule.redis.PointsRuleRedis; +import com.elink.esua.epdc.modules.rule.service.PointsRuleService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 积分规则表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-11 + */ +@Service +public class PointsRuleServiceImpl extends BaseServiceImpl implements PointsRuleService { + + @Autowired + private PointsRuleRedis pointsRuleRedis; + + @Autowired + private RedisUtils redisUtils; + + @Override + public PageData page(Map params) { + String ruleDesc = (String) params.get("ruleDesc"); + String behaviorCode = (String) params.get("behaviorCode"); + String behaviorDesc = (String) params.get("behaviorDesc"); + String ruleCode = (String) params.get("ruleCode"); + String operationType = (String) params.get("operationType"); + String available = (String) params.get("available"); + String upperLimitFlag = (String) params.get("upperLimitFlag"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(ruleDesc), "RULE_DESC", ruleDesc.trim()) + .like(StringUtils.isNotBlank(behaviorDesc), "BEHAVIOR_DESC", behaviorDesc.trim()) + .like(StringUtils.isNotBlank(ruleCode), "RULE_CODE", ruleCode.trim()) + .eq(StringUtils.isNotBlank(operationType), "OPERATION_TYPE", operationType) + .eq(StringUtils.isNotBlank(available), "AVAILABLE", available) + .eq(StringUtils.isNotBlank(upperLimitFlag), "UPPER_LIMIT_FLAG", upperLimitFlag) + .eq(StringUtils.isNotBlank(behaviorCode), "BEHAVIOR_CODE", behaviorCode) + .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), + "DATE_FORMAT(CREATED_TIME, '%Y-%m-%d' )", + startTime, + endTime); + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + wrapper + ); + return getPageData(page, PointsRuleDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, PointsRuleDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public PointsRuleDTO get(String id) { + PointsRuleEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, PointsRuleDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result save(PointsRuleDTO dto) { + Result checkResult = checkPointsRuleDTO(dto); + if (!checkResult.success()) { + return checkResult; + } + dto.setAvailable(PointsRuleEnum.AVAILABLE_TRUE.value());//可用标记(0-不可用,1-可用) 新增时默认可用 + PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); + insert(entity); + String pointsRuleKey = RedisKeys.getPointsRuleKey(dto.getRuleCode()); + redisUtils.set(pointsRuleKey, entity); + return new Result(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result update(PointsRuleDTO dto) { + Result checkResult = checkPointsRuleDTO(dto); + if (!checkResult.success()) { + return checkResult; + } + PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); + updateById(entity); + String pointsRuleKey = RedisKeys.getPointsRuleKey(dto.getRuleCode()); + redisUtils.set(pointsRuleKey, entity); + return new Result(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.in(FieldConstant.ID, ids); + List pointsRuleEntityList = baseDao.selectList(wrapper); + for (PointsRuleEntity pointsRuleEntity : pointsRuleEntityList) { + String pointsRuleKey = RedisKeys.getPointsRuleKey(pointsRuleEntity.getRuleCode()); + redisUtils.delete(pointsRuleKey); + } + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @param dto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @Author yinzuomei + * @Description 校验界面提交数据 + * @Date 2019/12/11 17:56 + **/ + public Result checkPointsRuleDTO(PointsRuleDTO dto) { + //规则有上限值:积分值不能大于上限值 + if (PointsRuleEnum.UPPER_LIMIT_FLAG_TRUE.value().equals(dto.getUpperLimitFlag()) + && dto.getPoints() > dto.getUpperLimitVal()) { + return new Result().error("积分值不能大于上限值"); + } + //校验规则编码是否唯一 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("RULE_CODE", dto.getRuleCode()) + .ne(StringUtils.isNotBlank(dto.getId()), FieldConstant.ID, dto.getId()); + List list = baseDao.selectList(wrapper); + if (CollUtil.isNotEmpty(list)) { + return new Result().error("规则编码已存在"); + } + return new Result(); + } +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml index e357d9282..48658aa4c 100644 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml @@ -2,7 +2,7 @@ - + - + @@ -156,4 +156,4 @@ - \ No newline at end of file + diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/rule/PointsRuleDao.xml b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/rule/PointsRuleDao.xml new file mode 100644 index 000000000..40e8d530f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/rule/PointsRuleDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +