Browse Source

积分规则配置页面:动作编码 去除不可重复限制,改为可多选

feature/syp_points
zhangyongzhangyong 5 years ago
parent
commit
fbef7c88b2
  1. 81
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/PointsBehaviorRuleDTO.java
  2. 9
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/PointsRuleDTO.java
  3. 94
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsBehaviorRuleController.java
  4. 43
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsBehaviorRuleDao.java
  5. 10
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsRuleDao.java
  6. 51
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/entity/PointsBehaviorRuleEntity.java
  7. 5
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/entity/PointsRuleEntity.java
  8. 62
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/excel/PointsBehaviorRuleExcel.java
  9. 47
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/redis/PointsBehaviorRuleRedis.java
  10. 95
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsBehaviorRuleService.java
  11. 104
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsBehaviorRuleServiceImpl.java
  12. 48
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsRuleServiceImpl.java
  13. 23
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsBehaviorRuleDao.xml
  14. 83
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsRuleDao.xml

81
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/PointsBehaviorRuleDTO.java

@ -0,0 +1,81 @@
/**
* 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;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 积分动作规则关系表
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Data
public class PointsBehaviorRuleDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private String id;
/**
* 动作ID
*/
private String behaviorId;
/**
* 规则ID
*/
private String ruleId;
/**
* 乐观锁
*/
private Integer revision;
/**
* 删除标识 0-1-
*/
private String delFlag;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

9
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/PointsRuleDTO.java

@ -19,6 +19,8 @@ package com.elink.esua.epdc.dto;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
@ -46,7 +48,7 @@ public class PointsRuleDTO implements Serializable {
/**
* 动作编码
*/
//private String behaviorCode;
private String behaviorCode;
/**
* 积分规则描述
@ -127,4 +129,9 @@ public class PointsRuleDTO implements Serializable {
* 虚字段 - 序号
*/
private Integer orderNumber;
/**
* 积分规则编码
*/
private List<String> behaviorCodeArray;
}

94
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsBehaviorRuleController.java

@ -0,0 +1,94 @@
/**
* 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.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.PointsBehaviorRuleDTO;
import com.elink.esua.epdc.excel.PointsBehaviorRuleExcel;
import com.elink.esua.epdc.service.PointsBehaviorRuleService;
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 elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@RestController
@RequestMapping("pointsbehaviorrule")
public class PointsBehaviorRuleController {
@Autowired
private PointsBehaviorRuleService pointsBehaviorRuleService;
@GetMapping("page")
public Result<PageData<PointsBehaviorRuleDTO>> page(@RequestParam Map<String, Object> params){
PageData<PointsBehaviorRuleDTO> page = pointsBehaviorRuleService.page(params);
return new Result<PageData<PointsBehaviorRuleDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<PointsBehaviorRuleDTO> get(@PathVariable("id") String id){
PointsBehaviorRuleDTO data = pointsBehaviorRuleService.get(id);
return new Result<PointsBehaviorRuleDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody PointsBehaviorRuleDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
pointsBehaviorRuleService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody PointsBehaviorRuleDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
pointsBehaviorRuleService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
pointsBehaviorRuleService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<PointsBehaviorRuleDTO> list = pointsBehaviorRuleService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, PointsBehaviorRuleExcel.class);
}
}

43
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsBehaviorRuleDao.java

@ -0,0 +1,43 @@
/**
* 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.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.PointsBehaviorRuleEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 积分动作规则关系表
*
* @author zhangyong
* @since v1.0.0 2020-05-11
*/
@Mapper
public interface PointsBehaviorRuleDao extends BaseDao<PointsBehaviorRuleEntity> {
/**
* 根据参数删除积分动作规则关系表中 与积分动作管理表 有关联的数据
* @param ruleId 积分规则管理表主键
* @return void
* @Author zhangyong
* @Date 10:54 2020-05-11
**/
void deletePointsBehaviorRule(String ruleId);
}

10
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsRuleDao.java

@ -59,4 +59,14 @@ public interface PointsRuleDao extends BaseDao<PointsRuleEntity> {
* @Date: 2020-04-29
*/
List<PointsRuleDTO> selectListPointsRule(Map<String, Object> params);
/**
* 根据积分规则管理表ID查询相关联的动作编码
*
* @param pointsRuldId 积分规则管理表ID
* @return java.util.List<java.lang.String>
* @Author zhangyong
* @Date 10:22 2020-05-11
**/
List<String> selectListBehaviorCode(String pointsRuldId);
}

51
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/entity/PointsBehaviorRuleEntity.java

@ -0,0 +1,51 @@
/**
* 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.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 elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_points_behavior_rule")
public class PointsBehaviorRuleEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 动作ID
*/
private String behaviorId;
/**
* 规则ID
*/
private String ruleId;
}

5
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/entity/PointsRuleEntity.java

@ -43,11 +43,6 @@ public class PointsRuleEntity extends BaseEpdcEntity {
*/
private String ruleCode;
/**
* 动作编码
*/
//private String behaviorCode;
/**
* 积分规则描述
*/

62
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/excel/PointsBehaviorRuleExcel.java

@ -0,0 +1,62 @@
/**
* 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.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 积分动作规则关系表
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Data
public class PointsBehaviorRuleExcel {
@Excel(name = "ID")
private String id;
@Excel(name = "动作ID")
private String behaviorId;
@Excel(name = "规则ID")
private String ruleId;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "删除标识 0-否,1-是")
private String delFlag;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
}

47
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/redis/PointsBehaviorRuleRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.redis;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 积分动作规则关系表
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Component
public class PointsBehaviorRuleRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

95
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsBehaviorRuleService.java

@ -0,0 +1,95 @@
/**
* 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.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.PointsBehaviorRuleDTO;
import com.elink.esua.epdc.entity.PointsBehaviorRuleEntity;
import java.util.List;
import java.util.Map;
/**
* 积分动作规则关系表
*
* @author elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
public interface PointsBehaviorRuleService extends BaseService<PointsBehaviorRuleEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<PointsBehaviorRuleDTO>
* @author generator
* @date 2020-05-11
*/
PageData<PointsBehaviorRuleDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<PointsBehaviorRuleDTO>
* @author generator
* @date 2020-05-11
*/
List<PointsBehaviorRuleDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return PointsBehaviorRuleDTO
* @author generator
* @date 2020-05-11
*/
PointsBehaviorRuleDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-05-11
*/
void save(PointsBehaviorRuleDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-05-11
*/
void update(PointsBehaviorRuleDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-05-11
*/
void delete(String[] ids);
}

104
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsBehaviorRuleServiceImpl.java

@ -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.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.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dao.PointsBehaviorRuleDao;
import com.elink.esua.epdc.dto.PointsBehaviorRuleDTO;
import com.elink.esua.epdc.entity.PointsBehaviorRuleEntity;
import com.elink.esua.epdc.redis.PointsBehaviorRuleRedis;
import com.elink.esua.epdc.service.PointsBehaviorRuleService;
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 elink elink@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Service
public class PointsBehaviorRuleServiceImpl extends BaseServiceImpl<PointsBehaviorRuleDao, PointsBehaviorRuleEntity> implements PointsBehaviorRuleService {
@Autowired
private PointsBehaviorRuleRedis pointsBehaviorRuleRedis;
@Override
public PageData<PointsBehaviorRuleDTO> page(Map<String, Object> params) {
IPage<PointsBehaviorRuleEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, PointsBehaviorRuleDTO.class);
}
@Override
public List<PointsBehaviorRuleDTO> list(Map<String, Object> params) {
List<PointsBehaviorRuleEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, PointsBehaviorRuleDTO.class);
}
private QueryWrapper<PointsBehaviorRuleEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<PointsBehaviorRuleEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public PointsBehaviorRuleDTO get(String id) {
PointsBehaviorRuleEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, PointsBehaviorRuleDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(PointsBehaviorRuleDTO dto) {
PointsBehaviorRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorRuleEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PointsBehaviorRuleDTO dto) {
PointsBehaviorRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorRuleEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

48
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsRuleServiceImpl.java

@ -22,7 +22,6 @@ 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.enums.pointsenum.PointsRuleAvailableEnum;
import com.elink.esua.epdc.commons.tools.exception.ErrorCode;
import com.elink.esua.epdc.commons.tools.page.PageData;
@ -30,9 +29,15 @@ 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.dao.PointsBehaviorDao;
import com.elink.esua.epdc.dao.PointsBehaviorRuleDao;
import com.elink.esua.epdc.dao.PointsRuleDao;
import com.elink.esua.epdc.dto.PointsBehaviorDTO;
import com.elink.esua.epdc.dto.PointsBehaviorRuleDTO;
import com.elink.esua.epdc.dto.PointsRuleDTO;
import com.elink.esua.epdc.dto.result.BehaviorResultDto;
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO;
import com.elink.esua.epdc.entity.PointsBehaviorRuleEntity;
import com.elink.esua.epdc.entity.PointsRuleEntity;
import com.elink.esua.epdc.redis.PointsRuleRedis;
import com.elink.esua.epdc.service.PointsRuleService;
@ -60,6 +65,12 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
@Autowired
private RedisUtils redisUtils;
@Autowired
private PointsBehaviorRuleDao pointsBehaviorRuleDao;
@Autowired
private PointsBehaviorDao pointsBehaviorDao;
@Override
public PageData<PointsRuleDTO> page(Map<String, Object> params) {
IPage<PointsRuleDTO> page = getPage(params);
@ -86,7 +97,9 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
@Override
public PointsRuleDTO get(String id) {
PointsRuleEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, PointsRuleDTO.class);
PointsRuleDTO dto = ConvertUtils.sourceToTarget(entity, PointsRuleDTO.class);
dto.setBehaviorCodeArray(baseDao.selectListBehaviorCode(dto.getId()));
return dto;
}
@Override
@ -98,8 +111,12 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
return checkRuleCode;
}
// 积分规则管理表
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class);
insert(entity);
// 存入积分动作规则关系表
this.insertPointsBehaviorRule(dto, entity.getId());
// 存入redis
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()), entity, RedisUtils.NOT_EXPIRE);
return new Result();
@ -132,9 +149,13 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
return checkRuleCode;
}
}
// 修改积分规则管理表
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class);
updateById(entity);
// 删除积分动作规则关系表
pointsBehaviorRuleDao.deletePointsBehaviorRule(dto.getId());
// 存入积分动作规则关系表
this.insertPointsBehaviorRule(dto, dto.getId());
// 删除redis中的存储信息
redisUtils.delete(RedisKeys.getAllPointsRuleCodeKey(queryEntity.getRuleCode()));
// 新增redis信息
@ -205,4 +226,25 @@ public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, Points
}
return new Result();
}
/**
* 存入积分动作规则关系表
* @param pointsRuleDTO
* @param pointsRuldId 积分规则表主键ID
* @return void
* @Author zhangyong
* @Date 10:37 2020-05-11
**/
private void insertPointsBehaviorRule(PointsRuleDTO pointsRuleDTO, String pointsRuldId) {
for (String behaviorCode : pointsRuleDTO.getBehaviorCodeArray()){
PointsBehaviorRuleDTO dto = new PointsBehaviorRuleDTO();
// 根据动作编码查询动作ID
BehaviorResultDto pointsBehavior = pointsBehaviorDao.getBehaviorCodeInfoByBehaviorCode(behaviorCode);
dto.setBehaviorId(pointsBehavior.getId());
dto.setRuleId(pointsRuldId);
PointsBehaviorRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorRuleEntity.class);
pointsBehaviorRuleDao.insert(entity);
}
}
}

23
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsBehaviorRuleDao.xml

@ -0,0 +1,23 @@
<?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.dao.PointsBehaviorRuleDao">
<resultMap type="com.elink.esua.epdc.entity.PointsBehaviorRuleEntity" id="pointsBehaviorRuleMap">
<result property="id" column="ID"/>
<result property="behaviorId" column="BEHAVIOR_ID"/>
<result property="ruleId" column="RULE_ID"/>
<result property="revision" column="REVISION"/>
<result property="delFlag" column="DEL_FLAG"/>
<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>
<delete id="deletePointsBehaviorRule">
update epdc_points_behavior_rule
set DEL_FLAG = '1'
where DEL_FLAG='0' and RULE_ID =#{ruleId}
</delete>
</mapper>

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

@ -37,33 +37,62 @@
<select id="selectListPointsRule" resultType="com.elink.esua.epdc.dto.PointsRuleDTO">
SELECT
(@i:=@i+1) as orderNumber,
r.ID id,
r.RULE_CODE ruleCode,
r.RULE_DESC ruleDesc,
r.OPERATION_TYPE operationType,
r.POINTS points,
r.LIMIT_TYPE limitType,
r.UPPER_LIMIT_VAL upperLimitVal,
r.LIMIT_NUM limitNum,
r.ENABLE_FLAG enableFlag,
r.ADDED_VAL addedVal,
r.REMARK remark
r.id,
r.ruleCode,
r.ruleDesc,
r.operationType,
r.points,
r.limitType,
r.upperLimitVal,
r.limitNum,
r.enableFlag,
r.addedVal,
r.remark,
r.behaviorCode
FROM(
SELECT
r.ID id,
r.RULE_CODE ruleCode,
r.RULE_DESC ruleDesc,
r.OPERATION_TYPE operationType,
r.POINTS points,
r.LIMIT_TYPE limitType,
r.UPPER_LIMIT_VAL upperLimitVal,
r.LIMIT_NUM limitNum,
r.ENABLE_FLAG enableFlag,
r.ADDED_VAL addedVal,
r.REMARK remark,
GROUP_CONCAT(b.BEHAVIOR_CODE) as behaviorCode,
r.CREATED_TIME
FROM
epdc_points_rule r
LEFT JOIN epdc_points_behavior_rule br ON r.id = br.RULE_ID AND br.DEL_FLAG = 0
LEFT JOIN epdc_points_behavior b ON br.BEHAVIOR_ID = b.ID AND b.DEL_FLAG = 0
WHERE r.DEL_FLAG = 0
<if test="ruleCode != null and ruleCode.trim() != ''">
AND instr(r.RULE_CODE , trim(#{ruleCode}) ) > 0
</if>
<if test="ruleDesc != null and ruleDesc.trim() != ''">
AND instr(r.RULE_DESC , trim(#{ruleDesc}) ) > 0
</if>
<if test="operationType != null and operationType != ''">
AND r.OPERATION_TYPE = #{operationType}
</if>
<if test="enableFlag != null and enableFlag != ''">
AND r.ENABLE_FLAG = #{enableFlag}
</if>
GROUP BY r.ID
) r, (select @i:=0) as it
ORDER BY r.CREATED_TIME DESC
</select>
<select id="selectListBehaviorCode" resultType="String">
SELECT
b.BEHAVIOR_CODE behaviorCodeArray
FROM
epdc_points_rule r, (select @i:=0) as it
WHERE r.DEL_FLAG = 0
<if test="ruleCode != null and ruleCode.trim() != ''">
AND instr(r.RULE_CODE , trim(#{ruleCode}) ) > 0
</if>
<if test="ruleDesc != null and ruleDesc.trim() != ''">
AND instr(r.RULE_DESC , trim(#{ruleDesc}) ) > 0
</if>
<if test="operationType != null and operationType != ''">
AND r.OPERATION_TYPE = #{operationType}
</if>
<if test="enableFlag != null and enableFlag != ''">
AND r.ENABLE_FLAG = #{enableFlag}
</if>
ORDER BY
CREATED_TIME DESC
epdc_points_rule r
LEFT JOIN epdc_points_behavior_rule br ON r.id = br.RULE_ID AND br.DEL_FLAG = 0
LEFT JOIN epdc_points_behavior b ON br.BEHAVIOR_ID = b.ID AND b.DEL_FLAG = 0
WHERE r.DEL_FLAG = 0 AND r.id = #{pointsRuldId}
</select>
</mapper>

Loading…
Cancel
Save