Browse Source

积分管理-积分规则设置

feature/dangjian
尹作梅 6 years ago
parent
commit
1f276f35dd
  1. 2
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysSimpleDictDTO.java
  2. 2
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java
  3. 11
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java
  4. 6
      esua-epdc/epdc-gateway/src/main/resources/application.yml
  5. 7
      esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml
  6. 122
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/rule/PointsRuleDTO.java
  7. 44
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/enums/PointsRuleEnum.java
  8. 35
      esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml
  9. 33
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/DemoController.java
  10. 92
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/controller/PointsRuleController.java
  11. 34
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/dao/PointsRuleDao.java
  12. 91
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/entity/PointsRuleEntity.java
  13. 86
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/excel/PointsRuleExcel.java
  14. 47
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/redis/PointsRuleRedis.java
  15. 97
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/PointsRuleService.java
  16. 178
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/impl/PointsRuleServiceImpl.java
  17. 4
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml
  18. 27
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/rule/PointsRuleDao.xml

2
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;
@ApiModelProperty(value = "备注")
private String remark;
}

2
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<SysDictDao, SysDictEntit
}
QueryWrapper<SysDictEntity> 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");

11
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);
}
}

6
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/**

7
esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml

@ -11,5 +11,12 @@
<artifactId>epdc-points-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-commons-tools</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

122
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

44
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;
}
}

35
esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml

@ -78,6 +78,29 @@
<artifactId>dockerfile-maven-plugin</artifactId>
</plugin>
</plugins>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/application*.yml</include>
<include>**/*.properties</include>
<include>logback-spring.xml</include>
<include>registry.conf</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/application*.yml</exclude>
<exclude>**/*.properties</exclude>
<exclude>logback-spring.xml</exclude>
<exclude>registry.conf</exclude>
</excludes>
</resource>
</resources>
</build>
@ -90,7 +113,7 @@
<properties>
<spring.profiles.active>dev</spring.profiles.active>
<server.port>9060</server.port>
<server.port>9070</server.port>
<spring.redis.index>2</spring.redis.index>
<spring.redis.host>47.104.224.45</spring.redis.host>
@ -98,7 +121,7 @@
<spring.redis.password>elink@888</spring.redis.password>
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epdc_demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_mutuality?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>root</spring.datasource.druid.username>
<spring.datasource.druid.password>shibei@888</spring.datasource.druid.password>
@ -115,7 +138,7 @@
<properties>
<spring.profiles.active>test</spring.profiles.active>
<server.port>9060</server.port>
<server.port>9070</server.port>
<spring.redis.index>2</spring.redis.index>
<spring.redis.host>47.104.224.45</spring.redis.host>
@ -123,7 +146,7 @@
<spring.redis.password>elink@888</spring.redis.password>
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_job?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_mutuality?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epdc</spring.datasource.druid.username>
<spring.datasource.druid.password>elink888</spring.datasource.druid.password>
@ -140,7 +163,7 @@
<properties>
<spring.profiles.active>prod</spring.profiles.active>
<server.port>9060</server.port>
<server.port>9070</server.port>
<spring.redis.index>2</spring.redis.index>
<spring.redis.host>47.104.224.45</spring.redis.host>
@ -148,7 +171,7 @@
<spring.redis.password>elink@888</spring.redis.password>
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_job?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_mutuality?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epdc</spring.datasource.druid.username>
<spring.datasource.druid.password>elink888</spring.datasource.druid.password>

33
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/DemoController.java

@ -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<List<DemoDto>> listDemo(){
Result<List<DemoDto>> listResult = demoFeignClient.listDemo();
return listResult;
}
}

92
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<PointsRuleDTO>> page(@RequestParam Map<String, Object> params) {
PageData<PointsRuleDTO> page = pointsRuleService.page(params);
return new Result<PageData<PointsRuleDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<PointsRuleDTO> get(@PathVariable("id") String id) {
PointsRuleDTO data = pointsRuleService.get(id);
return new Result<PointsRuleDTO>().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<String, Object> params, HttpServletResponse response) throws Exception {
List<PointsRuleDTO> list = pointsRuleService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, PointsRuleExcel.class);
}
}

34
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PointsRuleEntity> {
}

91
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

86
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

97
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PointsRuleEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<PointsRuleDTO>
* @author generator
* @date 2019-12-11
*/
PageData<PointsRuleDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<PointsRuleDTO>
* @author generator
* @date 2019-12-11
*/
List<PointsRuleDTO> list(Map<String, Object> 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);
}

178
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PointsRuleDao, PointsRuleEntity> implements PointsRuleService {
@Autowired
private PointsRuleRedis pointsRuleRedis;
@Autowired
private RedisUtils redisUtils;
@Override
public PageData<PointsRuleDTO> page(Map<String, Object> 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<PointsRuleEntity> 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<PointsRuleEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
wrapper
);
return getPageData(page, PointsRuleDTO.class);
}
@Override
public List<PointsRuleDTO> list(Map<String, Object> params) {
List<PointsRuleEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, PointsRuleDTO.class);
}
private QueryWrapper<PointsRuleEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<PointsRuleEntity> 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<PointsRuleEntity> wrapper = new QueryWrapper<>();
wrapper.in(FieldConstant.ID, ids);
List<PointsRuleEntity> 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<PointsRuleEntity> wrapper = new QueryWrapper<>();
wrapper.eq("RULE_CODE", dto.getRuleCode())
.ne(StringUtils.isNotBlank(dto.getId()), FieldConstant.ID, dto.getId());
List<PointsRuleEntity> list = baseDao.selectList(wrapper);
if (CollUtil.isNotEmpty(list)) {
return new Result().error("规则编码已存在");
}
return new Result();
}
}

4
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml

@ -2,7 +2,7 @@
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<property name="log.path" value="logs/heart"/>
<property name="log.path" value="logs/points"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
@ -133,7 +133,7 @@
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.elink.esua.epdc" level="INFO"/>
<logger name="com.elink.esua.epdc.dao" level="DEBUG"/>
<logger name="com.elink.esua.epdc.modules.rule.dao" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="DEBUG_FILE"/>
<appender-ref ref="INFO_FILE"/>

27
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/rule/PointsRuleDao.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.modules.rule.dao.PointsRuleDao">
<resultMap type="com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity" id="pointsRuleMap">
<result property="id" column="ID"/>
<result property="ruleCode" column="RULE_CODE"/>
<result property="ruleDesc" column="RULE_DESC"/>
<result property="points" column="POINTS"/>
<result property="operationType" column="OPERATION_TYPE"/>
<result property="available" column="AVAILABLE"/>
<result property="behaviorCode" column="BEHAVIOR_CODE"/>
<result property="behaviorDesc" column="BEHAVIOR_DESC"/>
<result property="upperLimitFlag" column="UPPER_LIMIT_FLAG"/>
<result property="limitTimeType" column="LIMIT_TIME_TYPE"/>
<result property="upperLimitVal" column="UPPER_LIMIT_VAL"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>
Loading…
Cancel
Save