Browse Source

Merge branch 'dev_heart' of http://121.42.41.42:7070/r/esua-epdc-cloud into dev_heart

feature/dangjian
管理员 6 years ago
parent
commit
be34324a01
  1. 4
      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. 19
      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. 92
      esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/phrases/ActPhraseDTO.java
  6. 2
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/HeartApplication.java
  7. 107
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/controller/ActPhraseController.java
  8. 44
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/dao/ActPhraseDao.java
  9. 63
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/entity/ActPhraseEntity.java
  10. 46
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/entity/ActPhraseRedisEntity.java
  11. 65
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/excel/ActPhraseExcel.java
  12. 47
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/redis/ActPhraseRedis.java
  13. 119
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/service/ActPhraseService.java
  14. 189
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/service/impl/ActPhraseServiceImpl.java
  15. 19
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/support/initbean/InitRedisCache.java
  16. 28
      esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/phrases/ActPhraseDao.xml
  17. 7
      esua-epdc/epdc-module/epdc-points/epdc-points-client/pom.xml
  18. 122
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/rule/PointsRuleDTO.java
  19. 44
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/enums/PointsRuleEnum.java
  20. 35
      esua-epdc/epdc-module/epdc-points/epdc-points-server/pom.xml
  21. 33
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/DemoController.java
  22. 103
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/controller/PointsRuleController.java
  23. 34
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/dao/PointsRuleDao.java
  24. 91
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/entity/PointsRuleEntity.java
  25. 86
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/excel/PointsRuleExcel.java
  26. 47
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/redis/PointsRuleRedis.java
  27. 114
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/PointsRuleService.java
  28. 227
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/impl/PointsRuleServiceImpl.java
  29. 31
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/support/initbean/InitPointsRuleRedisCache.java
  30. 6
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/logback-spring.xml
  31. 27
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/rule/PointsRuleDao.xml

4
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");

19
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java

@ -145,4 +145,23 @@ public class RedisKeys {
public static String getEventsCategoryKey() {
return rootPrefix.concat("options:category:events");
}
/**
* @Author wanggongfeng
* @Description常用语
*/
public static String getPhraseListKey() {
return rootPrefix.concat("epdc:heart:phrase:list");
}
/**
* @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/**

92
esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/phrases/ActPhraseDTO.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.phrases;
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 ActPhraseDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 常用语
*/
private String phrase;
/**
* 显示顺序
*/
private Integer sort;
/**
* 是否显示(0-1-)
*/
private String showFlag;
/**
* 使用次数 0
*/
private Integer usageNum;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* code
*/
private String code;
}

2
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/HeartApplication.java

@ -25,7 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public class HeartApplication {
public static void main(String[] args) {
SpringApplication.run(PointsApplication.class, args);
SpringApplication.run(HeartApplication.class, args);
}
}

107
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/controller/ActPhraseController.java

@ -0,0 +1,107 @@
/**
* 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.phrases.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.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseRedisEntity;
import com.elink.esua.epdc.modules.phrases.excel.ActPhraseExcel;
import com.elink.esua.epdc.modules.phrases.service.ActPhraseService;
import com.elink.esua.epdc.phrases.ActPhraseDTO;
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("actphrase")
public class ActPhraseController {
@Autowired
private ActPhraseService actPhraseService;
@GetMapping("page")
public Result<PageData<ActPhraseDTO>> page(@RequestParam Map<String, Object> params){
PageData<ActPhraseDTO> page = actPhraseService.page(params);
return new Result<PageData<ActPhraseDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<ActPhraseDTO> get(@PathVariable("id") String id){
ActPhraseDTO data = actPhraseService.get(id);
return new Result<ActPhraseDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody ActPhraseDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
actPhraseService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody ActPhraseDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
actPhraseService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
actPhraseService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ActPhraseDTO> list = actPhraseService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ActPhraseExcel.class);
}
@GetMapping(value="sagenumAddOneById",produces = "text/plain;charset=UTF-8")
public Result sagenumAddOne(String id) {
actPhraseService.updateUsagenumAddOne(id);
return new Result().ok("使用次数加一成功");
}
@GetMapping(value="getPhraseList",produces = "text/plain;charset=UTF-8")
public Result getPhraseList() {
List<ActPhraseRedisEntity> object = actPhraseService.getPhraseList();
return new Result().ok(object);
}
}

44
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/dao/ActPhraseDao.java

@ -0,0 +1,44 @@
/**
* 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.phrases.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseEntity;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseRedisEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 常用语表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-11
*/
@Mapper
public interface ActPhraseDao extends BaseDao<ActPhraseEntity> {
/**
* 按序号顺序查询常用语
* @return
*/
List<ActPhraseRedisEntity> selectListPhraseInOrder();
void updateUsagenumAddOne(@Param("id")String id);
}

63
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/entity/ActPhraseEntity.java

@ -0,0 +1,63 @@
/**
* 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.phrases.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 常用语表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-11
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_act_phrase")
public class ActPhraseEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 常用语
*/
private String phrase;
/**
* 显示顺序
*/
private Integer sort;
/**
* 是否显示(0-1-)
*/
private String showFlag;
/**
* 使用次数 0
*/
private Integer usageNum;
/**
* code
*/
private String code;
}

46
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/entity/ActPhraseRedisEntity.java

@ -0,0 +1,46 @@
/**
* 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.phrases.entity;
import lombok.Data;
/**
* 常用语表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-11
*/
@Data
public class ActPhraseRedisEntity {
/**
* ID
*/
private String id;
/**
* 常用语
*/
private String phrase;
/**
* code
*/
private String code;
}

65
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/excel/ActPhraseExcel.java

@ -0,0 +1,65 @@
/**
* 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.phrases.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 ActPhraseExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "常用语")
private String phrase;
@Excel(name = "显示顺序")
private Integer sort;
@Excel(name = "是否显示(0-否,1-是)")
private String showFlag;
@Excel(name = "使用次数 0")
private Integer usageNum;
@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-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/redis/ActPhraseRedis.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.phrases.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 ActPhraseRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

119
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/service/ActPhraseService.java

@ -0,0 +1,119 @@
/**
* 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.phrases.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseEntity;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseRedisEntity;
import com.elink.esua.epdc.phrases.ActPhraseDTO;
import java.util.List;
import java.util.Map;
/**
* 常用语表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-11
*/
public interface ActPhraseService extends BaseService<ActPhraseEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<ActPhraseDTO>
* @author generator
* @date 2019-12-11
*/
PageData<ActPhraseDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<ActPhraseDTO>
* @author generator
* @date 2019-12-11
*/
List<ActPhraseDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return ActPhraseDTO
* @author generator
* @date 2019-12-11
*/
ActPhraseDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2019-12-11
*/
void save(ActPhraseDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2019-12-11
*/
void update(ActPhraseDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2019-12-11
*/
void delete(String[] ids);
/**
* 查询常用语更新Radis
*/
void insertPhraseListToRedis();
/**
* 更新使用次数+1
*
* @param id
* @return void
* @author wanggongfeng
* @date 2019-12-12
*/
void updateUsagenumAddOne(String id);
/**
* 从redis直接读取常用语
* @author wanggongfeng
* @date 2019-12-12
* @return 常用语列表
*/
List<ActPhraseRedisEntity> getPhraseList();
}

189
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/phrases/service/impl/ActPhraseServiceImpl.java

@ -0,0 +1,189 @@
/**
* 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.phrases.service.impl;
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.exception.RenException;
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.modules.phrases.dao.ActPhraseDao;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseEntity;
import com.elink.esua.epdc.modules.phrases.entity.ActPhraseRedisEntity;
import com.elink.esua.epdc.modules.phrases.redis.ActPhraseRedis;
import com.elink.esua.epdc.modules.phrases.service.ActPhraseService;
import com.elink.esua.epdc.phrases.ActPhraseDTO;
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.ArrayList;
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 ActPhraseServiceImpl extends BaseServiceImpl<ActPhraseDao, ActPhraseEntity> implements ActPhraseService {
@Autowired
private ActPhraseRedis actPhraseRedis;
@Autowired
private RedisUtils redisUtils;
@Override
public PageData<ActPhraseDTO> page(Map<String, Object> params) {
IPage<ActPhraseEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ActPhraseDTO.class);
}
@Override
public List<ActPhraseDTO> list(Map<String, Object> params) {
List<ActPhraseEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ActPhraseDTO.class);
}
private QueryWrapper<ActPhraseEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ActPhraseEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public ActPhraseDTO get(String id) {
ActPhraseEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ActPhraseDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ActPhraseDTO dto) {
String categoryCode = dto.getCode();
if (StringUtils.isNotBlank(categoryCode)) {
if (getCodeCount(dto) > 0) {
throw new RenException("您输入的编码已存在");
}
}
ActPhraseEntity entity = ConvertUtils.sourceToTarget(dto, ActPhraseEntity.class);
insert(entity);
//redis存储
String key = RedisKeys.getPhraseListKey();
redisUtils.delete(key);
List<ActPhraseRedisEntity> list = baseDao.selectListPhraseInOrder();
redisUtils.set(key,list);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ActPhraseDTO dto) {
ActPhraseEntity entity = ConvertUtils.sourceToTarget(dto, ActPhraseEntity.class);
updateById(entity);
//redis存储
String key = RedisKeys.getPhraseListKey();
redisUtils.delete(key);
List<ActPhraseRedisEntity> list = baseDao.selectListPhraseInOrder();
redisUtils.set(key,list);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
//redis存储
String key = RedisKeys.getPhraseListKey();
redisUtils.delete(key);
List<ActPhraseRedisEntity> list = baseDao.selectListPhraseInOrder();
redisUtils.set(key,list);
}
/**
* 统计编码数量
* @param dto
* @return
*/
public Integer getCodeCount(ActPhraseDTO dto) {
QueryWrapper<ActPhraseEntity> wrapper = new QueryWrapper<>();
wrapper.eq("code", dto.getCode());
String id = dto.getId();
wrapper.ne(id != null, "id", dto.getId());
wrapper.eq("del_flag", "0");
return baseDao.selectCount(wrapper);
}
/**
* 查询启动时需存入radis内的常用语
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPhraseListToRedis(){
//redis存储
String key = RedisKeys.getPhraseListKey();
redisUtils.delete(key);
List<ActPhraseRedisEntity> list = baseDao.selectListPhraseInOrder();
redisUtils.set(key,list);
}
/**
* 使用次数加一
* @param id
*/
@Override
public void updateUsagenumAddOne(String id){
baseDao.updateUsagenumAddOne(id);
}
/**
* 从redis直接读取常用语
* @return
*/
@Override
public List<ActPhraseRedisEntity> getPhraseList(){
String key = RedisKeys.getPhraseListKey();
Object object = redisUtils.get(key);
List<ActPhraseRedisEntity> list = new ArrayList<ActPhraseRedisEntity>();
if(object != null){
list = (List<ActPhraseRedisEntity>)object;
}
return list;
}
}

19
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/support/initbean/InitRedisCache.java

@ -0,0 +1,19 @@
package com.elink.esua.epdc.support.initbean;
import com.elink.esua.epdc.modules.phrases.service.ActPhraseService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class InitRedisCache implements InitializingBean {
@Autowired
private ActPhraseService actPhraseService;
@Override
public void afterPropertiesSet() throws Exception{
//redis存储常用语
actPhraseService.insertPhraseListToRedis();
}
}

28
esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/phrases/ActPhraseDao.xml

@ -0,0 +1,28 @@
<?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.phrases.dao.ActPhraseDao">
<resultMap type="com.elink.esua.epdc.modules.phrases.entity.ActPhraseEntity" id="actPhraseMap">
<result property="id" column="ID"/>
<result property="phrase" column="PHRASE"/>
<result property="sort" column="SORT"/>
<result property="showFlag" column="SHOW_FLAG"/>
<result property="usageNum" column="USAGE_NUM"/>
<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>
<select id="selectListPhraseInOrder" resultType="com.elink.esua.epdc.modules.phrases.entity.ActPhraseRedisEntity">
select id,code,phrase from epdc_act_phrase where DEL_FLAG = '0' and SHOW_FLAG = '1' ORDER BY SORT ,UPDATED_TIME
</select>
<update id="updateUsagenumAddOne">
update epdc_act_phrase set USAGE_NUM = USAGE_NUM + 1 where id = #{id}
</update>
</mapper>

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

103
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/controller/PointsRuleController.java

@ -0,0 +1,103 @@
/**
* 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);
}
/**
* @param ruleCode
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.rule.PointsRuleDTO>
* @Author yinzuomei
* @Description 根据规则编码查询规则信息
* @Date 2019/12/12 16:29
**/
@GetMapping("getPointRule/{ruleCode}")
public Result<PointsRuleDTO> getPointRule(@PathVariable("ruleCode") String ruleCode) {
return pointsRuleService.getPointRule(ruleCode);
}
}

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

114
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/modules/rule/service/PointsRuleService.java

@ -0,0 +1,114 @@
/**
* 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);
/**
* @param
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @Author yinzuomei
* @Description 项目启动初始化积分规则到redis
* @Date 2019/12/12 16:27
**/
Result initPointsRuleRedis();
/**
* @param ruleCode
* @return com.elink.esua.epdc.dto.rule.PointsRuleDTO
* @Author yinzuomei
* @Description 根据规则编码查询规则信息
* @Date 2019/12/12 16:30
**/
Result<PointsRuleDTO> getPointRule(String ruleCode);
}

227
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,227 @@
/**
* 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
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @Author yinzuomei
* @Description 项目启动初始化积分规则到redis
* @Date 2019/12/12 16:26
**/
@Override
public Result initPointsRuleRedis() {
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>();
wrapper.eq("AVAILABLE", PointsRuleEnum.AVAILABLE_TRUE.value());
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper);
for (PointsRuleEntity pointsRuleEntity : pointsRuleEntityList) {
String pointsRuleKey = RedisKeys.getPointsRuleKey(pointsRuleEntity.getRuleCode());
redisUtils.set(pointsRuleKey, pointsRuleEntity);
}
return new Result();
}
/**
* @param ruleCode
* @return com.elink.esua.epdc.dto.rule.PointsRuleDTO
* @Author yinzuomei
* @Description 根据规则编码查询规则信息
* @Date 2019/12/12 16:30
**/
@Override
public Result<PointsRuleDTO> getPointRule(String ruleCode) {
if (StringUtils.isBlank(ruleCode)) {
return new Result<PointsRuleDTO>().error("规则编码不能为空");
}
String pointsRuleKey = RedisKeys.getPointsRuleKey(ruleCode);
Object obj = redisUtils.get(pointsRuleKey);
if (null == obj) {
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>();
wrapper.eq("RULE_CODE", ruleCode);
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper);
if (CollUtil.isEmpty(pointsRuleEntityList)) {
return new Result<PointsRuleDTO>().error("没有找到有效记录");
} else if (pointsRuleEntityList.size() > 1) {
return new Result<PointsRuleDTO>().error("规则编码不唯一");
}
redisUtils.set(pointsRuleKey, pointsRuleEntityList.get(0));
obj = redisUtils.get(pointsRuleKey);
}
PointsRuleDTO pointsRuleDTO = ConvertUtils.sourceToTarget(obj, PointsRuleDTO.class);
return new Result<PointsRuleDTO>().ok(pointsRuleDTO);
}
/**
* @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();
}
}

31
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/support/initbean/InitPointsRuleRedisCache.java

@ -0,0 +1,31 @@
package com.elink.esua.epdc.support.initbean;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.modules.rule.service.PointsRuleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @Description 项目启动初始化积分规则到缓存
* @Author yinzuomei
* @Date 2019/12/12 16:06
*/
@Component
public class InitPointsRuleRedisCache implements InitializingBean {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private PointsRuleService pointsRuleService;
@Override
public void afterPropertiesSet() throws Exception {
Result result = pointsRuleService.initPointsRuleRedis();
if (result.success()) {
logger.info("积分规则初始化成功");
} else {
logger.info("积分规则初始化失败" + result.getMsg());
}
}
}

6
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"/>
@ -156,4 +156,4 @@
</root>
</springProfile>
</configuration>
</configuration>

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