40 changed files with 2464 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||
# Created by .ignore support plugin (hsz.mobi) |
|||
### Java template |
|||
# Compiled class file |
|||
*.class |
|||
|
|||
# Log file |
|||
*.log |
|||
|
|||
# BlueJ files |
|||
*.ctxt |
|||
|
|||
# Mobile Tools for Java (J2ME) |
|||
.mtj.tmp/ |
|||
|
|||
# Package Files # |
|||
*.jar |
|||
*.war |
|||
*.nar |
|||
*.ear |
|||
*.zip |
|||
*.tar.gz |
|||
*.rar |
|||
|
|||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml |
|||
hs_err_pid* |
|||
.idea/ |
|||
*.iml |
|||
**/target/ |
|||
|
|||
@ -0,0 +1,20 @@ |
|||
# 基础镜像 |
|||
FROM openjdk:8u242-jdk-buster |
|||
# 作者 |
|||
MAINTAINER rongchao@elink-cn.com |
|||
# 对应pom.xml文件中的dockerfile-maven-plugin插件JAR_FILE的值 |
|||
ARG JAR_FILE |
|||
# 对应pom.xml文件中的dockerfile-maven-plugin插件JAR_NAME的值 |
|||
ARG JAR_NAME |
|||
# 对应pom.xml文件中的dockerfile-maven-plugin插件SERVER_PORT的值 |
|||
ARG SERVER_PORT |
|||
# 复制打包完成后的jar文件到/opt目录下 |
|||
ENV JAR_PATH /mnt/epdc/${JAR_NAME}.jar |
|||
ADD ${JAR_FILE} $JAR_PATH |
|||
# /data设为环境变量 |
|||
ENV DATAPATH /data |
|||
# 挂载/data目录到主机 |
|||
VOLUME $DATAPATH |
|||
# 启动容器时执行 |
|||
ENTRYPOINT java -jar $JAR_CONFIG $JAR_PATH |
|||
EXPOSE ${SERVER_PORT} |
|||
@ -0,0 +1,205 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-parent-yushan</artifactId> |
|||
<version>1.0.0</version> |
|||
<relativePath>../epdc-cloud-parent-yushan</relativePath> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>epdc-cloud-points</artifactId> |
|||
<packaging>jar</packaging> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-user-client</artifactId> |
|||
<version>${epdc-cloud-client.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-news-client</artifactId> |
|||
<version>${epdc-cloud-client.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-points-client</artifactId> |
|||
<version>${epdc-cloud-client.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-commons-tools</artifactId> |
|||
<version>1.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-commons-mybatis</artifactId> |
|||
<version>${epdc-cloud-commons.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>de.codecentric</groupId> |
|||
<artifactId>spring-boot-admin-starter-client</artifactId> |
|||
<version>2.0.3</version> |
|||
</dependency> |
|||
<!-- zipkin client --> |
|||
<dependency> |
|||
<groupId>org.springframework.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-zipkin</artifactId> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-surefire-plugin</artifactId> |
|||
<configuration> |
|||
<skipTests>true</skipTests> |
|||
</configuration> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-deploy-plugin</artifactId> |
|||
<configuration> |
|||
<skip>true</skip> |
|||
</configuration> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>com.spotify</groupId> |
|||
<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> |
|||
|
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>dev</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<properties> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
<docker.tag>dev</docker.tag> |
|||
|
|||
<server.port>9070</server.port> |
|||
|
|||
<spring.redis.index>2</spring.redis.index> |
|||
<spring.redis.host>47.104.224.45</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>elink@888</spring.redis.password> |
|||
|
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_points?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>elink833066</spring.datasource.druid.password> |
|||
|
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
|||
|
|||
<spring.zipkin.base-url>http://localhost:9411</spring.zipkin.base-url> |
|||
</properties> |
|||
</profile> |
|||
|
|||
<profile> |
|||
<id>test</id> |
|||
<properties> |
|||
<spring.profiles.active>test</spring.profiles.active> |
|||
<docker.tag>test</docker.tag> |
|||
|
|||
<server.port>10017</server.port> |
|||
|
|||
<spring.redis.index>2</spring.redis.index> |
|||
<spring.redis.host>114.215.125.123</spring.redis.host> |
|||
<spring.redis.port>9603</spring.redis.port> |
|||
<spring.redis.password>epdc!redis@master1405</spring.redis.password> |
|||
|
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_points?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>elink833066</spring.datasource.druid.password> |
|||
|
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
|||
<nacos.ip>47.104.85.99</nacos.ip> |
|||
<nacos.namespace>6a3577b4-7b79-43f6-aebb-9c3f31263f6a</nacos.namespace> |
|||
|
|||
<spring.zipkin.base-url>http://localhost:9411</spring.zipkin.base-url> |
|||
</properties> |
|||
</profile> |
|||
|
|||
<profile> |
|||
<id>prod</id> |
|||
<properties> |
|||
<spring.profiles.active>prod</spring.profiles.active> |
|||
<docker.tag>prod</docker.tag> |
|||
|
|||
<server.port>9070</server.port> |
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>172.16.1.243</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>Elink833066</spring.redis.password> |
|||
|
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://rm-m5ew61hl12e70oaw8.mysql.rds.aliyuncs.com:3306/esua_epdc_points?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>Elink@833066</spring.datasource.druid.password> |
|||
|
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>172.16.1.243:8848</nacos.server-addr> |
|||
<nacos.ip></nacos.ip> |
|||
<nacos.namespace></nacos.namespace> |
|||
|
|||
<spring.zipkin.base-url>http://localhost:9411</spring.zipkin.base-url> |
|||
</properties> |
|||
</profile> |
|||
</profiles> |
|||
</project> |
|||
@ -0,0 +1,31 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|||
import org.springframework.cloud.openfeign.EnableFeignClients; |
|||
|
|||
/** |
|||
* 爱心互助模块 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.1.0 |
|||
*/ |
|||
@SpringBootApplication |
|||
@EnableDiscoveryClient |
|||
@EnableFeignClients |
|||
public class PointsApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(PointsApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.config; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.config.ModuleConfig; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 模块配置信息-爱心互助模块 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Service |
|||
public class ModuleConfigImpl implements ModuleConfig { |
|||
@Override |
|||
public String getName() { |
|||
return "points"; |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package com.elink.esua.epdc.modules.async; |
|||
|
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.NewsFeignClient; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.scheduling.annotation.Async; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 新闻通知消息模块 线程任务 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/10 10:02 |
|||
*/ |
|||
@Component |
|||
public class NewsTask { |
|||
|
|||
@Autowired |
|||
private NewsFeignClient newsFeignClient; |
|||
|
|||
/** |
|||
* 给用户发送消息 |
|||
* |
|||
* @param informationDto |
|||
* @return void |
|||
* @author yujintao |
|||
* @date 2019/9/10 10:33 |
|||
*/ |
|||
@Async |
|||
public void insertUserInformation(EpdcInformationFormDTO informationDto) { |
|||
newsFeignClient.saveInformation(informationDto); |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.elink.esua.epdc.modules.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.fallback.NewsFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
/** |
|||
* 消息模块 |
|||
* |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/9/18 15:37 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_NEWS_SERVER, fallback = NewsFeignClientFallback.class) |
|||
public interface NewsFeignClient { |
|||
|
|||
/** |
|||
* 给用户发消息 |
|||
* |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/9/18 15:40 |
|||
*/ |
|||
@PostMapping(value = "news/epdc-app/information/save", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) |
|||
Result saveInformation(@RequestBody EpdcInformationFormDTO formDto); |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.elink.esua.epdc.modules.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.fallback.UserFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
|
|||
/** |
|||
* @Description 用户模块 |
|||
* @Author yinzuomei |
|||
* @Date 2019/12/13 10:00 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UserFeignClientFallback.class) |
|||
public interface UserFeignClient { |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.elink.esua.epdc.dto.UserDTO |
|||
* @Author yinzuomei |
|||
* @Description 根据操作类型更新用户积分 |
|||
* @Date 2019/12/13 15:12 |
|||
**/ |
|||
@PostMapping(value = "app-user/user/handleUserPoints", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<UserDTO> handleUserPoints(EpdcUserPointsFormDTO formDTO); |
|||
|
|||
/** |
|||
* 查询用户基础信息 |
|||
* |
|||
* @param userId |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UserDTO> |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/10/26 15:16 |
|||
*/ |
|||
@GetMapping("app-user/epdc-app/user/getById/{userId}") |
|||
Result<UserDTO> getUserInfoById(@PathVariable("userId") String userId); |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.elink.esua.epdc.modules.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.NewsFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/9/18 15:38 |
|||
*/ |
|||
@Component |
|||
public class NewsFeignClientFallback implements NewsFeignClient { |
|||
|
|||
@Override |
|||
public Result saveInformation(EpdcInformationFormDTO formDto) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "saveInformation", formDto); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.elink.esua.epdc.modules.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.UserFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2019/12/13 10:00 |
|||
*/ |
|||
@Component |
|||
public class UserFeignClientFallback implements UserFeignClient { |
|||
|
|||
@Override |
|||
public Result<UserDTO> handleUserPoints(EpdcUserPointsFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "handleUserPoints", formDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserDTO> getUserInfoById(String userId) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "getUserInfoById", userId); |
|||
} |
|||
} |
|||
@ -0,0 +1,112 @@ |
|||
/** |
|||
* 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.logs.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.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|||
import com.elink.esua.epdc.dto.logs.PointsLogsDTO; |
|||
import com.elink.esua.epdc.modules.logs.excel.PointsLogsExcel; |
|||
import com.elink.esua.epdc.modules.logs.service.PointsLogsService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import javax.validation.Valid; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 积分日志表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-13 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("pointslogs") |
|||
public class PointsLogsController { |
|||
|
|||
@Autowired |
|||
private PointsLogsService pointsLogsService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<PointsLogsDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<PointsLogsDTO> page = pointsLogsService.page(params); |
|||
return new Result<PageData<PointsLogsDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<PointsLogsDTO> get(@PathVariable("id") String id){ |
|||
PointsLogsDTO data = pointsLogsService.get(id); |
|||
return new Result<PointsLogsDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody PointsLogsDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
return pointsLogsService.save(dto); |
|||
} |
|||
@PostMapping("addPointsLog") |
|||
public Result addPointsLog(@RequestBody PointsLogsDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
return pointsLogsService.save(dto); |
|||
} |
|||
@PutMapping |
|||
public Result update(@RequestBody PointsLogsDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
pointsLogsService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
pointsLogsService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PointsLogsDTO> list = pointsLogsService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, PointsLogsExcel.class); |
|||
} |
|||
|
|||
/** |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 确定调整用户积分 |
|||
* @Date 2019/12/16 18:56 |
|||
**/ |
|||
@PostMapping("confirmAdjustPoint") |
|||
public Result confirmAdjustPoint(@RequestBody EpdcAdjustVolunteerPointsDTO formDto){ |
|||
ValidatorUtils.validateEntity(formDto); |
|||
return pointsLogsService.confirmAdjustPoint(formDto); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* 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.logs.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.modules.logs.entity.PointsLogsEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 积分日志表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-13 |
|||
*/ |
|||
@Mapper |
|||
public interface PointsLogsDao extends BaseDao<PointsLogsEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,104 @@ |
|||
/** |
|||
* 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.logs.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-13 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_points_logs") |
|||
public class PointsLogsEntity extends BaseEpdcEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 志愿者ID |
|||
*/ |
|||
private String volunteerId; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 积分操作类型(0-减积分,1-加积分) |
|||
*/ |
|||
private String operationType; |
|||
|
|||
/** |
|||
* 操作积分值 |
|||
*/ |
|||
private Integer points; |
|||
|
|||
/** |
|||
* 操作描述 |
|||
*/ |
|||
private String operationDesc; |
|||
|
|||
/** |
|||
* 操作时间 |
|||
*/ |
|||
private Date operationTime; |
|||
|
|||
/** |
|||
* 操作方式(user-用户操作,admin-管理员操作,sys-系统操作) |
|||
*/ |
|||
private String operationMode; |
|||
|
|||
/** |
|||
* 积分规则编码 |
|||
*/ |
|||
private String ruleCode; |
|||
|
|||
/** |
|||
* 是否操作成功(0-失败,1-成功) |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 操作失败原因 |
|||
*/ |
|||
private String failureReason; |
|||
|
|||
/** |
|||
* 剩余积分值 |
|||
*/ |
|||
private Integer lavePoints; |
|||
|
|||
/** |
|||
* 积分行为编码 |
|||
*/ |
|||
private String behaviorCode; |
|||
|
|||
/** |
|||
* 关联表ID关联表id |
|||
*/ |
|||
private String referenceId; |
|||
} |
|||
@ -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.logs.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-13 |
|||
*/ |
|||
@Data |
|||
public class PointsLogsExcel { |
|||
|
|||
@Excel(name = "主键") |
|||
private String id; |
|||
|
|||
@Excel(name = "志愿者ID") |
|||
private String volunteerId; |
|||
|
|||
@Excel(name = "用户ID") |
|||
private String userId; |
|||
|
|||
@Excel(name = "积分操作类型(0-减积分,1-加积分)") |
|||
private String operationType; |
|||
|
|||
@Excel(name = "操作积分值") |
|||
private Integer points; |
|||
|
|||
@Excel(name = "操作描述") |
|||
private String operationDesc; |
|||
|
|||
@Excel(name = "操作时间") |
|||
private Date operationTime; |
|||
|
|||
@Excel(name = "操作方式(user-用户操作,admin-管理员操作,sys-系统操作)") |
|||
private String operationMode; |
|||
|
|||
@Excel(name = "积分规则编码") |
|||
private String ruleCode; |
|||
|
|||
@Excel(name = "是否操作成功(0-失败,1-成功)") |
|||
private String status; |
|||
|
|||
@Excel(name = "操作失败原因") |
|||
private String failureReason; |
|||
|
|||
@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; |
|||
|
|||
|
|||
} |
|||
@ -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.logs.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-13 |
|||
*/ |
|||
@Component |
|||
public class PointsLogsRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
/** |
|||
* 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.logs.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.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|||
import com.elink.esua.epdc.dto.logs.PointsLogsDTO; |
|||
import com.elink.esua.epdc.modules.logs.entity.PointsLogsEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分日志表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-13 |
|||
*/ |
|||
public interface PointsLogsService extends BaseService<PointsLogsEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<PointsLogsDTO> |
|||
* @author generator |
|||
* @date 2019-12-13 |
|||
*/ |
|||
PageData<PointsLogsDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<PointsLogsDTO> |
|||
* @author generator |
|||
* @date 2019-12-13 |
|||
*/ |
|||
List<PointsLogsDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return PointsLogsDTO |
|||
* @author generator |
|||
* @date 2019-12-13 |
|||
*/ |
|||
PointsLogsDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2019-12-13 |
|||
*/ |
|||
Result save(PointsLogsDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2019-12-13 |
|||
*/ |
|||
void update(PointsLogsDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2019-12-13 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 确定调整用户积分 |
|||
* @Date 2019/12/16 18:56 |
|||
**/ |
|||
Result confirmAdjustPoint(EpdcAdjustVolunteerPointsDTO formDto); |
|||
} |
|||
@ -0,0 +1,200 @@ |
|||
/** |
|||
* 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.logs.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.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.PointsConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationModeEnum; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.constant.PointsNoticeConstant; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|||
import com.elink.esua.epdc.dto.logs.PointsLogsDTO; |
|||
import com.elink.esua.epdc.modules.async.NewsTask; |
|||
import com.elink.esua.epdc.modules.feign.UserFeignClient; |
|||
import com.elink.esua.epdc.modules.logs.dao.PointsLogsDao; |
|||
import com.elink.esua.epdc.modules.logs.entity.PointsLogsEntity; |
|||
import com.elink.esua.epdc.modules.logs.redis.PointsLogsRedis; |
|||
import com.elink.esua.epdc.modules.logs.service.PointsLogsService; |
|||
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.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分日志表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-13 |
|||
*/ |
|||
@Service |
|||
public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, PointsLogsEntity> implements PointsLogsService { |
|||
|
|||
@Autowired |
|||
private PointsLogsRedis pointsLogsRedis; |
|||
|
|||
@Autowired |
|||
private UserFeignClient userFeignClient; |
|||
|
|||
@Autowired |
|||
private NewsTask newsTask; |
|||
|
|||
@Override |
|||
public PageData<PointsLogsDTO> page(Map<String, Object> params) { |
|||
String volunteerId = (String) params.get("volunteerId"); |
|||
String behaviorCode = (String) params.get("behaviorCode"); |
|||
QueryWrapper<PointsLogsEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(volunteerId), "VOLUNTEER_ID", volunteerId) |
|||
.eq(StringUtils.isNotBlank(behaviorCode), "BEHAVIOR_CODE", behaviorCode); |
|||
|
|||
IPage<PointsLogsEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
wrapper |
|||
); |
|||
return getPageData(page, PointsLogsDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsLogsDTO> list(Map<String, Object> params) { |
|||
List<PointsLogsEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsLogsDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsLogsEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsLogsEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsLogsDTO get(String id) { |
|||
PointsLogsEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, PointsLogsDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result save(PointsLogsDTO dto) { |
|||
PointsLogsEntity entity = ConvertUtils.sourceToTarget(dto, PointsLogsEntity.class); |
|||
insert(entity); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PointsLogsDTO dto) { |
|||
PointsLogsEntity entity = ConvertUtils.sourceToTarget(dto, PointsLogsEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
/** |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 确定调整用户积分 |
|||
* @Date 2019/12/16 18:56 |
|||
**/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result confirmAdjustPoint(EpdcAdjustVolunteerPointsDTO formDto) { |
|||
if(formDto.getOperatePoints()== NumConstant.ZERO){ |
|||
return new Result().error("操作积分不能为0"); |
|||
} |
|||
PointsLogsEntity pointsLogsEntity=new PointsLogsEntity(); |
|||
pointsLogsEntity.setVolunteerId(formDto.getId()); |
|||
pointsLogsEntity.setUserId(formDto.getUserId()); |
|||
pointsLogsEntity.setOperationTime(new Date()); |
|||
pointsLogsEntity.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_ADMIN.getOperationMode());//操作方式(user-用户操作,admin-管理员操作,sys-系统操作)
|
|||
pointsLogsEntity.setStatus(YesOrNoEnum.YES.value()); |
|||
pointsLogsEntity.setFailureReason(""); |
|||
pointsLogsEntity.setRuleCode(PointsConstant.ruleCode); |
|||
pointsLogsEntity.setOperationDesc(formDto.getAdjustReason());//操作描述
|
|||
pointsLogsEntity.setPoints(formDto.getOperatePoints()); |
|||
pointsLogsEntity.setOperationType(formDto.getOperationType());//积分操作类型(0-减积分,1-加积分)
|
|||
EpdcUserPointsFormDTO userPointsFormDTO = new EpdcUserPointsFormDTO(); |
|||
userPointsFormDTO.setUserId(formDto.getUserId()); |
|||
userPointsFormDTO.setPoints(formDto.getOperatePoints()); |
|||
userPointsFormDTO.setOperationType(formDto.getOperationType()); |
|||
Result<UserDTO> result = userFeignClient.handleUserPoints(userPointsFormDTO); |
|||
if (!result.success()) { |
|||
return new Result().error("调整用户积分失败"); |
|||
} |
|||
//剩余积分
|
|||
pointsLogsEntity.setLavePoints(result.getData().getPoints()); |
|||
pointsLogsEntity.setBehaviorCode(formDto.getBehaviorCode()); |
|||
this.insert(pointsLogsEntity); |
|||
//给用户发送消息通知
|
|||
this.issueSmsNotification(pointsLogsEntity); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param pointsLogsEntity |
|||
* @return void |
|||
* @Author yinzuomei |
|||
* @Description 调整积分完成后-给用户发送消息通知 |
|||
* @Date 2020/2/7 22:12 |
|||
**/ |
|||
private void issueSmsNotification(PointsLogsEntity pointsLogsEntity) { |
|||
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); |
|||
informationFormDTO.setUserId(pointsLogsEntity.getUserId()); |
|||
String content = ""; |
|||
//积分操作类型(0-减积分,1-加积分)
|
|||
if (PointsOperationEnum.OPERATION_TYPE_ADD.getOperationType().equals(pointsLogsEntity.getOperationType())) { |
|||
informationFormDTO.setTitle(PointsNoticeConstant.ADD_POINTS_NOTICE); |
|||
content = PointsNoticeConstant.ADD_POINTS + pointsLogsEntity.getPoints() + PointsNoticeConstant.REASON + pointsLogsEntity.getOperationDesc(); |
|||
|
|||
} else if (PointsOperationEnum.OPERATION_TYPE_SUBSTRACT.getOperationType().equals(pointsLogsEntity.getOperationType())) { |
|||
informationFormDTO.setTitle(PointsNoticeConstant.SUBTRACT_POINTS_NOTICE); |
|||
content = PointsNoticeConstant.SUBTRACT_POINTS + pointsLogsEntity.getPoints() + PointsNoticeConstant.REASON + pointsLogsEntity.getOperationDesc(); |
|||
} |
|||
informationFormDTO.setContent(content); |
|||
informationFormDTO.setType(PointsNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE); |
|||
informationFormDTO.setBusinessType(PointsNoticeConstant.NOTICE__BUSINESS_TYPE_ACTIVITY); |
|||
informationFormDTO.setBusinessId(pointsLogsEntity.getId()); |
|||
informationFormDTO.setRelBusinessContent(""); |
|||
// 发送消息
|
|||
newsTask.insertUserInformation(informationFormDTO); |
|||
} |
|||
} |
|||
@ -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); |
|||
} |
|||
} |
|||
@ -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> { |
|||
|
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
|
|||
} |
|||
@ -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; |
|||
} |
|||
|
|||
} |
|||
@ -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); |
|||
} |
|||
@ -0,0 +1,235 @@ |
|||
/** |
|||
* 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.enums.pointsenum.PointsLimitTimeEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsRuleAvailableEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsUpperLimitEnum; |
|||
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.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; |
|||
} |
|||
if(StringUtils.isBlank(dto.getLimitTimeType())){ |
|||
dto.setLimitTimeType(PointsLimitTimeEnum.LIMIT_TIME_MINUTE.value()); |
|||
} |
|||
dto.setAvailable(PointsRuleAvailableEnum.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; |
|||
} |
|||
if(StringUtils.isBlank(dto.getLimitTimeType())){ |
|||
dto.setLimitTimeType(PointsLimitTimeEnum.LIMIT_TIME_MINUTE.value()); |
|||
} |
|||
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", PointsRuleAvailableEnum.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 (PointsUpperLimitEnum.YES.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(); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.elink.esua.epdc.support.annotion; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationModeEnum; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
/** |
|||
* @Auther: yinzuomei |
|||
* @Date: 2019/12/13 09:15 |
|||
* @Description: 爱心互助积分注解 |
|||
*/ |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Target(ElementType.METHOD) |
|||
@Inherited |
|||
@Documented |
|||
public @interface PointsBehavior { |
|||
/** |
|||
* 积分操作类型(加积分、减积分) |
|||
*/ |
|||
PointsOperationEnum operationType(); |
|||
|
|||
/** |
|||
* 积分操作方式(user-用户操作,admin-管理员操作,sys-系统操作) |
|||
*/ |
|||
PointsOperationModeEnum operationMode(); |
|||
|
|||
/** |
|||
* 志愿者ID |
|||
*/ |
|||
String volunteerId() default ""; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
String userId() default ""; |
|||
|
|||
/** |
|||
* 规则编码 |
|||
*/ |
|||
String ruleCode() default ""; |
|||
} |
|||
@ -0,0 +1,209 @@ |
|||
package com.elink.esua.epdc.support.aop; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.dto.logs.PointsLogsDTO; |
|||
import com.elink.esua.epdc.dto.logs.UserPointsLogDTO; |
|||
import com.elink.esua.epdc.dto.rule.PointsRuleDTO; |
|||
import com.elink.esua.epdc.modules.feign.UserFeignClient; |
|||
import com.elink.esua.epdc.modules.logs.service.PointsLogsService; |
|||
import com.elink.esua.epdc.modules.rule.service.PointsRuleService; |
|||
import com.elink.esua.epdc.support.annotion.PointsBehavior; |
|||
import io.seata.spring.annotation.GlobalTransactional; |
|||
import org.apache.logging.log4j.LogManager; |
|||
import org.apache.logging.log4j.Logger; |
|||
import org.aspectj.lang.JoinPoint; |
|||
import org.aspectj.lang.annotation.AfterReturning; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.annotation.Pointcut; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.lang.reflect.Method; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2019/12/13 10:00 |
|||
*/ |
|||
@Aspect |
|||
@Component |
|||
public class PointsBehaviorAop { |
|||
private final Logger logger = LogManager.getLogger(getClass()); |
|||
@Autowired |
|||
private PointsLogsService pointsLogsService; |
|||
|
|||
@Autowired |
|||
private PointsRuleService pointsRuleService; |
|||
|
|||
@Autowired |
|||
private UserFeignClient userFeignClient; |
|||
|
|||
@Pointcut("@annotation(com.elink.esua.epdc.support.annotion.PointsBehavior)") |
|||
public void recordUserPointsBehavior() { |
|||
} |
|||
|
|||
@AfterReturning("recordUserPointsBehavior()") |
|||
public void handleUserPoints(JoinPoint joinPoint) throws Exception { |
|||
logger.info("handleUserPoints start"); |
|||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|||
Method method = signature.getMethod(); |
|||
PointsBehavior pointsBehavior = method.getAnnotation(PointsBehavior.class); |
|||
Object[] args = joinPoint.getArgs(); |
|||
String[] argNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames(); |
|||
//解析入参
|
|||
UserPointsLogDTO userPointsLogDTO = this.packageUserPointsLogDTO(pointsBehavior, args, argNames); |
|||
//校验入参属性都不能为空
|
|||
ValidatorUtils.validateEntity(userPointsLogDTO); |
|||
Result result = this.updateUserPoints(userPointsLogDTO); |
|||
if (!result.success()) { |
|||
throw new Exception("更新用户积分异常" + result.getMsg()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param userPointsLogDTO |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description |
|||
* @Date 2019/12/13 15:17 |
|||
**/ |
|||
private Result updateUserPoints(UserPointsLogDTO userPointsLogDTO) { |
|||
//logger.info("解析后的UserPointsLogDTO:" + JSONObject.toJSONString(userPointsLogDTO));
|
|||
//插入积分日志
|
|||
PointsLogsDTO pointsLogDto = ConvertUtils.sourceToTarget(userPointsLogDTO, PointsLogsDTO.class); |
|||
Result<PointsRuleDTO> pointsRuleDTOResult = pointsRuleService.getPointRule(pointsLogDto.getRuleCode()); |
|||
pointsLogDto.setOperationDesc(pointsRuleDTOResult.getData().getBehaviorDesc()); |
|||
pointsLogDto.setPoints(pointsRuleDTOResult.getData().getPoints()); |
|||
pointsLogDto.setOperationTime(new Date()); |
|||
pointsLogDto.setStatus(YesOrNoEnum.YES.value());//是否操作成功(0-失败,1-成功)
|
|||
Result result = pointsLogsService.save(pointsLogDto); |
|||
if (!result.success()) { |
|||
return result; |
|||
} |
|||
//修改用户总积分数
|
|||
EpdcUserPointsFormDTO formDTO = new EpdcUserPointsFormDTO(); |
|||
formDTO.setOperationType(userPointsLogDTO.getOperationType()); |
|||
formDTO.setPoints(pointsRuleDTOResult.getData().getPoints()); |
|||
formDTO.setUserId(userPointsLogDTO.getUserId()); |
|||
Result res = userFeignClient.handleUserPoints(formDTO); |
|||
return res; |
|||
} |
|||
|
|||
/** |
|||
* @param pointsBehavior |
|||
* @param args |
|||
* @param argNames |
|||
* @return com.elink.esua.epdc.dto.logs.UserPointsLogDTO |
|||
* @Author yinzuomei |
|||
* @Description |
|||
* @Date 2019/12/13 10:29 |
|||
**/ |
|||
private UserPointsLogDTO packageUserPointsLogDTO(PointsBehavior pointsBehavior, |
|||
Object[] args, |
|||
String[] argNames) { |
|||
logger.info("packageUserPointsLogDTO start"); |
|||
UserPointsLogDTO userPointsLogDTO = new UserPointsLogDTO(); |
|||
userPointsLogDTO.setOperationMode(pointsBehavior.operationMode().getOperationMode()); |
|||
userPointsLogDTO.setOperationType(pointsBehavior.operationType().getOperationType()); |
|||
//志愿者ID
|
|||
String volunteerIdKey = pointsBehavior.volunteerId(); |
|||
//用户ID
|
|||
String userIdKey = pointsBehavior.userId(); |
|||
//规则编码
|
|||
String ruleCodeKey = pointsBehavior.ruleCode(); |
|||
if (volunteerIdKey.startsWith("#") && userIdKey.startsWith("#") && ruleCodeKey.startsWith("#")) { |
|||
String volunteerId = ""; |
|||
String userId = ""; |
|||
String ruleCode = ""; |
|||
|
|||
//解析志愿者id
|
|||
String volunteerIdExpression = volunteerIdKey.substring(2, volunteerIdKey.length() - 1); |
|||
String[] volunteerIdStrArr = volunteerIdExpression.split("\\."); |
|||
if (volunteerIdStrArr.length > 2 || volunteerIdStrArr.length == 0) { |
|||
throw new RuntimeException("记录用户积分注解中volunteerId格式不正确"); |
|||
} |
|||
if (volunteerIdStrArr.length == 1) { |
|||
for (int i = 0; i < argNames.length; i++) { |
|||
if (argNames[i].equals(volunteerIdStrArr[0])) { |
|||
volunteerId = String.valueOf(args[i]); |
|||
} |
|||
} |
|||
} else if (volunteerIdStrArr.length == 2) { |
|||
for (int i = 0; i < argNames.length; i++) { |
|||
if (argNames[i].equals(volunteerIdStrArr[0])) { |
|||
Object obj = args[i]; |
|||
try { |
|||
Method method = obj.getClass().getDeclaredMethod(volunteerIdStrArr[1]); |
|||
volunteerId = String.valueOf(method.invoke(obj)); |
|||
} catch (Exception e) { |
|||
throw new RuntimeException("记录用户积分注解中volunteerId反射失败"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
//解析ruleCode
|
|||
String ruleCodeExpression = ruleCodeKey.substring(2, ruleCodeKey.length() - 1); |
|||
String[] ruleCodeStrArr = ruleCodeExpression.split("\\."); |
|||
if (ruleCodeStrArr.length > 2 || ruleCodeStrArr.length == 0) { |
|||
throw new RuntimeException("记录用户积分注解中ruleCode格式不正确"); |
|||
} |
|||
if (ruleCodeStrArr.length == 1) { |
|||
for (int i = 0; i < argNames.length; i++) { |
|||
if (argNames[i].equals(ruleCodeStrArr[0])) { |
|||
ruleCode = String.valueOf(args[i]); |
|||
} |
|||
} |
|||
} else if (ruleCodeStrArr.length == 2) { |
|||
for (int i = 0; i < argNames.length; i++) { |
|||
if (argNames[i].equals(ruleCodeStrArr[0])) { |
|||
Object obj = args[i]; |
|||
try { |
|||
Method method = obj.getClass().getDeclaredMethod(ruleCodeStrArr[1]); |
|||
ruleCode = String.valueOf(method.invoke(obj)); |
|||
} catch (Exception e) { |
|||
throw new RuntimeException("记录用户积分注解中ruleCode反射失败"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
//解析userId
|
|||
String userIdExpression = userIdKey.substring(2, userIdKey.length() - 1); |
|||
String[] userIdStrArr = userIdExpression.split("\\."); |
|||
if (userIdStrArr.length > 2 || userIdStrArr.length == 0) { |
|||
throw new RuntimeException("记录用户积分注解中userId格式不正确"); |
|||
} |
|||
if (userIdStrArr.length == 1) { |
|||
for (int i = 0; i < argNames.length; i++) { |
|||
if (argNames[i].equals(userIdStrArr[0])) { |
|||
userId = String.valueOf(args[i]); |
|||
} |
|||
} |
|||
} else if (userIdStrArr.length == 2) { |
|||
for (int i = 0; i < argNames.length; i++) { |
|||
if (argNames[i].equals(userIdStrArr[0])) { |
|||
Object obj = args[i]; |
|||
try { |
|||
Method method = obj.getClass().getDeclaredMethod(userIdStrArr[1]); |
|||
userId = String.valueOf(method.invoke(obj)); |
|||
} catch (Exception e) { |
|||
throw new RuntimeException("记录用户积分注解中userId反射失败"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
userPointsLogDTO.setVolunteerId(volunteerId); |
|||
userPointsLogDTO.setUserId(userId); |
|||
userPointsLogDTO.setRuleCode(ruleCode); |
|||
} |
|||
return userPointsLogDTO; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -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()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
server: |
|||
port: @server.port@ |
|||
servlet: |
|||
context-path: /points |
|||
|
|||
spring: |
|||
main: |
|||
allow-bean-definition-overriding: true |
|||
application: |
|||
name: epdc-points-server |
|||
# 环境 dev|test|prod |
|||
profiles: |
|||
active: @spring.profiles.active@ |
|||
messages: |
|||
encoding: UTF-8 |
|||
basename: i18n/messages,i18n/messages_common |
|||
jackson: |
|||
time-zone: GMT+8 |
|||
date-format: yyyy-MM-dd HH:mm:ss |
|||
redis: |
|||
database: @spring.redis.index@ |
|||
host: @spring.redis.host@ |
|||
timeout: 30s |
|||
port: @spring.redis.port@ |
|||
password: @spring.redis.password@ |
|||
cloud: |
|||
nacos: |
|||
discovery: |
|||
server-addr: @nacos.server-addr@ |
|||
register-enabled: @nacos.register-enabled@ |
|||
ip: @nacos.ip@ |
|||
namespace: @nacos.namespace@ |
|||
alibaba: |
|||
seata: |
|||
tx-service-group: epdc-points-server-fescar-service-group |
|||
datasource: |
|||
druid: |
|||
driver-class-name: com.mysql.jdbc.Driver |
|||
url: @spring.datasource.druid.url@ |
|||
username: @spring.datasource.druid.username@ |
|||
password: @spring.datasource.druid.password@ |
|||
zipkin: |
|||
# 指定了 zipkin 服务器的地址 |
|||
base-url: @spring.zipkin.base-url@ |
|||
sleuth: |
|||
sampler: |
|||
# 将采样比例设置为 1.0,也就是全部都需要。默认是 0.1 |
|||
probability: 1.0 |
|||
|
|||
|
|||
management: |
|||
endpoints: |
|||
web: |
|||
exposure: |
|||
include: "*" |
|||
endpoint: |
|||
health: |
|||
show-details: ALWAYS |
|||
|
|||
mybatis-plus: |
|||
mapper-locations: classpath:/mapper/**/*.xml |
|||
#实体扫描,多个package用逗号或者分号分隔 |
|||
typeAliasesPackage: io.renren.entity;com.elink.esua.epdc.entity |
|||
global-config: |
|||
#数据库相关配置 |
|||
db-config: |
|||
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; |
|||
id-type: ID_WORKER |
|||
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" |
|||
field-strategy: NOT_NULL |
|||
#驼峰下划线转换 |
|||
column-underline: true |
|||
banner: false |
|||
#原生配置 |
|||
configuration: |
|||
map-underscore-to-camel-case: true |
|||
cache-enabled: false |
|||
call-setters-on-nulls: true |
|||
jdbc-type-for-null: 'null' |
|||
@ -0,0 +1,161 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
|||
|
|||
<property name="log.path" value="logs/points"/> |
|||
|
|||
<!-- 彩色日志格式 --> |
|||
<property name="CONSOLE_LOG_PATTERN" |
|||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|||
|
|||
<!--1. 输出到控制台--> |
|||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<level>debug</level> |
|||
</filter> |
|||
<encoder> |
|||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|||
<!-- 设置字符集 --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!--2. 输出到文档--> |
|||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
|||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/debug.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 日志归档 --> |
|||
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录debug级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>debug</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
|||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/info.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 每天日志归档路径以及格式 --> |
|||
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录info级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>info</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
|||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/warn.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录warn级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>warn</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
|||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/error.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录ERROR级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>ERROR</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 开发、测试环境 --> |
|||
<springProfile name="dev,test"> |
|||
<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.logs.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"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
<!-- 生产环境 --> |
|||
<springProfile name="prod"> |
|||
<logger name="org.springframework.web" level="ERROR"/> |
|||
<logger name="org.springboot.sample" level="ERROR"/> |
|||
<logger name="com.elink.esua.epdc" level="ERROR"/> |
|||
<root level="ERROR"> |
|||
<appender-ref ref="CONSOLE"/> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
</configuration> |
|||
@ -0,0 +1,29 @@ |
|||
<?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.logs.dao.PointsLogsDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.modules.logs.entity.PointsLogsEntity" id="pointsLogsMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="volunteerId" column="VOLUNTEER_ID"/> |
|||
<result property="userId" column="USER_ID"/> |
|||
<result property="operationType" column="OPERATION_TYPE"/> |
|||
<result property="points" column="POINTS"/> |
|||
<result property="operationDesc" column="OPERATION_DESC"/> |
|||
<result property="operationTime" column="OPERATION_TIME"/> |
|||
<result property="operationMode" column="OPERATION_MODE"/> |
|||
<result property="ruleCode" column="RULE_CODE"/> |
|||
<result property="status" column="STATUS"/> |
|||
<result property="failureReason" column="FAILURE_REASON"/> |
|||
<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"/> |
|||
<result property="lavePoints" column="LAVE_POINTS"></result> |
|||
<result property="behaviorCode" column="BEHAVIOR_CODE"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
|||
@ -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> |
|||
@ -0,0 +1,21 @@ |
|||
registry { |
|||
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa |
|||
type = "nacos" |
|||
|
|||
nacos { |
|||
serverAddr = "@nacos.server-addr@" |
|||
namespace = "public" |
|||
cluster = "default" |
|||
} |
|||
} |
|||
|
|||
config { |
|||
# file、nacos 、apollo、zk、consul、etcd3 |
|||
type = "nacos" |
|||
|
|||
nacos { |
|||
serverAddr = "@nacos.server-addr@" |
|||
namespace = "public" |
|||
cluster = "default" |
|||
} |
|||
} |
|||
Loading…
Reference in new issue