26 changed files with 1273 additions and 51 deletions
@ -0,0 +1,27 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.enums.pointsenum; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/13 09:43 |
||||
|
* @Description: 积分规则限制时限枚举类 |
||||
|
*/ |
||||
|
public enum PointsLimitTimeEnum { |
||||
|
/** |
||||
|
* 限制时限(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; |
||||
|
|
||||
|
PointsLimitTimeEnum(String value) { |
||||
|
this.value = value; |
||||
|
} |
||||
|
|
||||
|
public String value() { |
||||
|
return value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.enums.pointsenum; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/13 09:31 |
||||
|
* @Description: 积分操作类型枚举类 |
||||
|
*/ |
||||
|
public enum PointsOperationEnum { |
||||
|
/** |
||||
|
* 规则操作类型(0-减积分,1-加积分) |
||||
|
*/ |
||||
|
OPERATION_TYPE_ADD("1"), |
||||
|
OPERATION_TYPE_SUBSTRACT("0"); |
||||
|
|
||||
|
private String operationType; |
||||
|
|
||||
|
PointsOperationEnum(String operationType) { |
||||
|
this.operationType = operationType; |
||||
|
} |
||||
|
|
||||
|
public String getOperationType() { |
||||
|
return operationType; |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.enums.pointsenum; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/13 09:33 |
||||
|
* @Description: 积分操作方式枚举类 |
||||
|
*/ |
||||
|
public enum PointsOperationModeEnum { |
||||
|
|
||||
|
/** |
||||
|
* user-用户操作 |
||||
|
*/ |
||||
|
OPERATION_MODE_USER("user"), |
||||
|
|
||||
|
/** |
||||
|
* admin-管理员操作 |
||||
|
*/ |
||||
|
OPERATION_MODE_ADMIN("admin"), |
||||
|
|
||||
|
/** |
||||
|
* sys-系统操作 |
||||
|
*/ |
||||
|
OPERATION_MODE_SYS("sys"); |
||||
|
|
||||
|
private String operationMode; |
||||
|
|
||||
|
PointsOperationModeEnum(String operationMode) { |
||||
|
this.operationMode = operationMode; |
||||
|
} |
||||
|
|
||||
|
public String getOperationMode() { |
||||
|
return operationMode; |
||||
|
} |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.enums.pointsenum; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/12 15:04 |
||||
|
* @Description: 积分规则可用标志枚举类 |
||||
|
*/ |
||||
|
public enum PointsRuleAvailableEnum { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 可用标记(0-不可用,1-可用) |
||||
|
*/ |
||||
|
AVAILABLE_TRUE("1"), |
||||
|
AVAILABLE_FALSE("0"); |
||||
|
|
||||
|
private String value; |
||||
|
|
||||
|
PointsRuleAvailableEnum(String value) { |
||||
|
this.value = value; |
||||
|
} |
||||
|
|
||||
|
public String value() { |
||||
|
return value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.enums.pointsenum; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/13 09:48 |
||||
|
* @Description: 积分是否有上限限制 枚举类 |
||||
|
*/ |
||||
|
public enum PointsUpperLimitEnum { |
||||
|
/** |
||||
|
* 是 |
||||
|
*/ |
||||
|
YES("1"), |
||||
|
|
||||
|
/** |
||||
|
* 否 |
||||
|
*/ |
||||
|
NO("0"); |
||||
|
|
||||
|
private String value; |
||||
|
|
||||
|
PointsUpperLimitEnum(String value) { |
||||
|
this.value = value; |
||||
|
} |
||||
|
|
||||
|
public String value() { |
||||
|
return value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,121 @@ |
|||||
|
/** |
||||
|
* 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.logs; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 积分日志表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-13 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PointsLogsDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 志愿者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 String delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
package com.elink.esua.epdc.dto.logs; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description @PointsBehavior 入参DTO |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2019/12/13 10:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserPointsLogDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -4809148536169854292L; |
||||
|
|
||||
|
/** |
||||
|
* 积分操作类型(加积分、减积分) |
||||
|
*/ |
||||
|
@NotBlank(message = "积分操作类型不能为空") |
||||
|
private String operationType; |
||||
|
|
||||
|
/** |
||||
|
* 积分操作方式(user-用户操作,admin-管理员操作,sys-系统操作) |
||||
|
*/ |
||||
|
@NotBlank(message = "积分操作方式不能为空") |
||||
|
private String operationMode; |
||||
|
|
||||
|
/** |
||||
|
* VOLUNTEER_ID 志愿者ID |
||||
|
*/ |
||||
|
@NotBlank(message = "志愿者id不能为空") |
||||
|
private String volunteerId; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
@NotBlank(message = "用户id不能为空") |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 规则编码 |
||||
|
*/ |
||||
|
@NotBlank(message = "规则编码不能为空") |
||||
|
private String ruleCode; |
||||
|
} |
@ -1,44 +0,0 @@ |
|||||
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; |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,29 @@ |
|||||
|
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.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.PostMapping; |
||||
|
|
||||
|
/** |
||||
|
* @Description 用户模块 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2019/12/13 10:00 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UserFeignClientFallback.class,url = "http://127.0.0.1:9068") |
||||
|
public interface UserFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 根据操作类型更新用户积分 |
||||
|
* @Date 2019/12/13 15:12 |
||||
|
**/ |
||||
|
@PostMapping(value = "app-user/user/handleUserPoints", consumes = MediaType.APPLICATION_JSON_VALUE) |
||||
|
Result handleUserPoints(EpdcUserPointsFormDTO formDTO); |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
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.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 handleUserPoints(EpdcUserPointsFormDTO formDTO) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "handleUserPoints", formDTO); |
||||
|
} |
||||
|
} |
@ -0,0 +1,93 @@ |
|||||
|
/** |
||||
|
* 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.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 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); |
||||
|
} |
||||
|
|
||||
|
@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); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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,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.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; |
||||
|
|
||||
|
} |
@ -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,96 @@ |
|||||
|
/** |
||||
|
* 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.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); |
||||
|
} |
@ -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.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.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.dto.logs.PointsLogsDTO; |
||||
|
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.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; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<PointsLogsDTO> page(Map<String, Object> params) { |
||||
|
IPage<PointsLogsEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
getWrapper(params) |
||||
|
); |
||||
|
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)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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,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.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"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,29 @@ |
|||||
|
package com.elink.esua.epdc.dto.epdc.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
|
||||
|
/** |
||||
|
* @Description 根据操作类型更新用户积分 入参DTO |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2019/12/13 13:57 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EpdcUserPointsFormDTO { |
||||
|
/** |
||||
|
* 积分操作类型(加积分、减积分) |
||||
|
*/ |
||||
|
@NotBlank(message = "积分操作类型不能为空") |
||||
|
private String operationType; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
@NotBlank(message = "用户id不能为空") |
||||
|
private String userId; |
||||
|
|
||||
|
@NotNull |
||||
|
private Integer points; |
||||
|
} |
Loading…
Reference in new issue