18 changed files with 875 additions and 47 deletions
@ -0,0 +1,122 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dto.rule; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 积分规则表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PointsRuleDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 规则编码 |
||||
|
*/ |
||||
|
private String ruleCode; |
||||
|
|
||||
|
/** |
||||
|
* 规则描述 |
||||
|
*/ |
||||
|
private String ruleDesc; |
||||
|
|
||||
|
/** |
||||
|
* 积分值 |
||||
|
*/ |
||||
|
private Integer points; |
||||
|
|
||||
|
/** |
||||
|
* 规则操作类型(0-减积分,1-加积分) |
||||
|
*/ |
||||
|
private String operationType; |
||||
|
|
||||
|
/** |
||||
|
* 可用标记(0-不可用,1-可用) |
||||
|
*/ |
||||
|
private String available; |
||||
|
|
||||
|
/** |
||||
|
* 积分行为编码 |
||||
|
*/ |
||||
|
private String behaviorCode; |
||||
|
|
||||
|
/** |
||||
|
* 积分行为描述 |
||||
|
*/ |
||||
|
private String behaviorDesc; |
||||
|
|
||||
|
/** |
||||
|
* 积分是否有上限限制(0-否,1-是) |
||||
|
*/ |
||||
|
private String upperLimitFlag; |
||||
|
|
||||
|
/** |
||||
|
* 限制时限(0-分钟,1-小时,2-日,3-月,4-年) |
||||
|
*/ |
||||
|
private String limitTimeType; |
||||
|
|
||||
|
/** |
||||
|
* 积分上限值 |
||||
|
*/ |
||||
|
private Integer upperLimitVal; |
||||
|
|
||||
|
/** |
||||
|
* 删除标记 |
||||
|
*/ |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package com.elink.esua.epdc.enums; |
||||
|
|
||||
|
/** |
||||
|
* @Auther: yinzuomei |
||||
|
* @Date: 2019/12/12 15:04 |
||||
|
* @Description: 积分规则表枚举类 |
||||
|
*/ |
||||
|
public enum PointsRuleEnum { |
||||
|
/** |
||||
|
* 规则操作类型(0-减积分,1-加积分) |
||||
|
*/ |
||||
|
OPERATION_TYPE_ADD("1"), |
||||
|
OPERATION_TYPE_SUBSTRACT("0"), |
||||
|
|
||||
|
/** |
||||
|
* 可用标记(0-不可用,1-可用) |
||||
|
*/ |
||||
|
AVAILABLE_TRUE("1"), |
||||
|
AVAILABLE_FALSE("0"), |
||||
|
|
||||
|
/** |
||||
|
* 积分是否有上限限制(0-否,1-是) |
||||
|
*/ |
||||
|
UPPER_LIMIT_FLAG_TRUE("1"), |
||||
|
UPPER_LIMIT_FLAG_FALSE("0"), |
||||
|
/** |
||||
|
* 限制时限(0-分钟,1-小时,2-日,3-月,4-年) |
||||
|
*/ |
||||
|
LIMIT_TIME_MINUTE("0"), |
||||
|
LIMIT_TIME_HOUR("1"), |
||||
|
LIMIT_TIME_DAY("2"), |
||||
|
LIMIT_TIME_MONTH("3"), |
||||
|
LIMIT_TIME_YEAR("4"); |
||||
|
|
||||
|
private String value; |
||||
|
|
||||
|
PointsRuleEnum(String value) { |
||||
|
this.value = value; |
||||
|
} |
||||
|
|
||||
|
public String value() { |
||||
|
return value; |
||||
|
} |
||||
|
} |
@ -1,33 +0,0 @@ |
|||||
package com.elink.esua.epdc.controller; |
|
||||
|
|
||||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
||||
import com.elink.esua.epdc.dto.DemoDto; |
|
||||
import com.elink.esua.epdc.feign.DemoFeignClient; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||
import org.springframework.web.bind.annotation.RestController; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* |
|
||||
* @author yujintao |
|
||||
* @email yujintao@elink-cn.com |
|
||||
* @date 2019/8/23 10:59 |
|
||||
*/ |
|
||||
@RestController |
|
||||
@RequestMapping("demo") |
|
||||
public class DemoController { |
|
||||
|
|
||||
|
|
||||
@Autowired |
|
||||
private DemoFeignClient demoFeignClient; |
|
||||
|
|
||||
|
|
||||
@GetMapping("listAll") |
|
||||
public Result<List<DemoDto>> listDemo(){ |
|
||||
Result<List<DemoDto>> listResult = demoFeignClient.listDemo(); |
|
||||
return listResult; |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,92 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.modules.rule.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.rule.PointsRuleDTO; |
||||
|
import com.elink.esua.epdc.modules.rule.excel.PointsRuleExcel; |
||||
|
import com.elink.esua.epdc.modules.rule.service.PointsRuleService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 积分规则表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-11 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("pointsrule") |
||||
|
public class PointsRuleController { |
||||
|
|
||||
|
@Autowired |
||||
|
private PointsRuleService pointsRuleService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<PointsRuleDTO>> page(@RequestParam Map<String, Object> params) { |
||||
|
PageData<PointsRuleDTO> page = pointsRuleService.page(params); |
||||
|
return new Result<PageData<PointsRuleDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<PointsRuleDTO> get(@PathVariable("id") String id) { |
||||
|
PointsRuleDTO data = pointsRuleService.get(id); |
||||
|
return new Result<PointsRuleDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody PointsRuleDTO dto) { |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
return pointsRuleService.save(dto); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody PointsRuleDTO dto) { |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
return pointsRuleService.update(dto); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids) { |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
pointsRuleService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<PointsRuleDTO> list = pointsRuleService.list(params); |
||||
|
ExcelUtils.exportExcelToTarget(response, null, list, PointsRuleExcel.class); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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,97 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.modules.rule.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.rule.PointsRuleDTO; |
||||
|
import com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 积分规则表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-11 |
||||
|
*/ |
||||
|
public interface PointsRuleService extends BaseService<PointsRuleEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<PointsRuleDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-12-11 |
||||
|
*/ |
||||
|
PageData<PointsRuleDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<PointsRuleDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-12-11 |
||||
|
*/ |
||||
|
List<PointsRuleDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return PointsRuleDTO |
||||
|
* @author generator |
||||
|
* @date 2019-12-11 |
||||
|
*/ |
||||
|
PointsRuleDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-12-11 |
||||
|
*/ |
||||
|
Result save(PointsRuleDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-12-11 |
||||
|
*/ |
||||
|
Result update(PointsRuleDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-12-11 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
} |
@ -0,0 +1,178 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.modules.rule.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.rule.PointsRuleDTO; |
||||
|
import com.elink.esua.epdc.enums.PointsRuleEnum; |
||||
|
import com.elink.esua.epdc.modules.rule.dao.PointsRuleDao; |
||||
|
import com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity; |
||||
|
import com.elink.esua.epdc.modules.rule.redis.PointsRuleRedis; |
||||
|
import com.elink.esua.epdc.modules.rule.service.PointsRuleService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 积分规则表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-12-11 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, PointsRuleEntity> implements PointsRuleService { |
||||
|
|
||||
|
@Autowired |
||||
|
private PointsRuleRedis pointsRuleRedis; |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<PointsRuleDTO> page(Map<String, Object> params) { |
||||
|
String ruleDesc = (String) params.get("ruleDesc"); |
||||
|
String behaviorCode = (String) params.get("behaviorCode"); |
||||
|
String behaviorDesc = (String) params.get("behaviorDesc"); |
||||
|
String ruleCode = (String) params.get("ruleCode"); |
||||
|
String operationType = (String) params.get("operationType"); |
||||
|
String available = (String) params.get("available"); |
||||
|
String upperLimitFlag = (String) params.get("upperLimitFlag"); |
||||
|
String startTime = (String) params.get("startTime"); |
||||
|
String endTime = (String) params.get("endTime"); |
||||
|
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.like(StringUtils.isNotBlank(ruleDesc), "RULE_DESC", ruleDesc.trim()) |
||||
|
.like(StringUtils.isNotBlank(behaviorDesc), "BEHAVIOR_DESC", behaviorDesc.trim()) |
||||
|
.like(StringUtils.isNotBlank(ruleCode), "RULE_CODE", ruleCode.trim()) |
||||
|
.eq(StringUtils.isNotBlank(operationType), "OPERATION_TYPE", operationType) |
||||
|
.eq(StringUtils.isNotBlank(available), "AVAILABLE", available) |
||||
|
.eq(StringUtils.isNotBlank(upperLimitFlag), "UPPER_LIMIT_FLAG", upperLimitFlag) |
||||
|
.eq(StringUtils.isNotBlank(behaviorCode), "BEHAVIOR_CODE", behaviorCode) |
||||
|
.between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), |
||||
|
"DATE_FORMAT(CREATED_TIME, '%Y-%m-%d' )", |
||||
|
startTime, |
||||
|
endTime); |
||||
|
IPage<PointsRuleEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
wrapper |
||||
|
); |
||||
|
return getPageData(page, PointsRuleDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<PointsRuleDTO> list(Map<String, Object> params) { |
||||
|
List<PointsRuleEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, PointsRuleDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<PointsRuleEntity> getWrapper(Map<String, Object> params) { |
||||
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PointsRuleDTO get(String id) { |
||||
|
PointsRuleEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, PointsRuleDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public Result save(PointsRuleDTO dto) { |
||||
|
Result checkResult = checkPointsRuleDTO(dto); |
||||
|
if (!checkResult.success()) { |
||||
|
return checkResult; |
||||
|
} |
||||
|
dto.setAvailable(PointsRuleEnum.AVAILABLE_TRUE.value());//可用标记(0-不可用,1-可用) 新增时默认可用
|
||||
|
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); |
||||
|
insert(entity); |
||||
|
String pointsRuleKey = RedisKeys.getPointsRuleKey(dto.getRuleCode()); |
||||
|
redisUtils.set(pointsRuleKey, entity); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public Result update(PointsRuleDTO dto) { |
||||
|
Result checkResult = checkPointsRuleDTO(dto); |
||||
|
if (!checkResult.success()) { |
||||
|
return checkResult; |
||||
|
} |
||||
|
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); |
||||
|
updateById(entity); |
||||
|
String pointsRuleKey = RedisKeys.getPointsRuleKey(dto.getRuleCode()); |
||||
|
redisUtils.set(pointsRuleKey, entity); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.in(FieldConstant.ID, ids); |
||||
|
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper); |
||||
|
for (PointsRuleEntity pointsRuleEntity : pointsRuleEntityList) { |
||||
|
String pointsRuleKey = RedisKeys.getPointsRuleKey(pointsRuleEntity.getRuleCode()); |
||||
|
redisUtils.delete(pointsRuleKey); |
||||
|
} |
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param dto |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 校验界面提交数据 |
||||
|
* @Date 2019/12/11 17:56 |
||||
|
**/ |
||||
|
public Result checkPointsRuleDTO(PointsRuleDTO dto) { |
||||
|
//规则有上限值:积分值不能大于上限值
|
||||
|
if (PointsRuleEnum.UPPER_LIMIT_FLAG_TRUE.value().equals(dto.getUpperLimitFlag()) |
||||
|
&& dto.getPoints() > dto.getUpperLimitVal()) { |
||||
|
return new Result().error("积分值不能大于上限值"); |
||||
|
} |
||||
|
//校验规则编码是否唯一
|
||||
|
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq("RULE_CODE", dto.getRuleCode()) |
||||
|
.ne(StringUtils.isNotBlank(dto.getId()), FieldConstant.ID, dto.getId()); |
||||
|
List<PointsRuleEntity> list = baseDao.selectList(wrapper); |
||||
|
if (CollUtil.isNotEmpty(list)) { |
||||
|
return new Result().error("规则编码已存在"); |
||||
|
} |
||||
|
return new Result(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.elink.esua.epdc.modules.rule.dao.PointsRuleDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity" id="pointsRuleMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="ruleCode" column="RULE_CODE"/> |
||||
|
<result property="ruleDesc" column="RULE_DESC"/> |
||||
|
<result property="points" column="POINTS"/> |
||||
|
<result property="operationType" column="OPERATION_TYPE"/> |
||||
|
<result property="available" column="AVAILABLE"/> |
||||
|
<result property="behaviorCode" column="BEHAVIOR_CODE"/> |
||||
|
<result property="behaviorDesc" column="BEHAVIOR_DESC"/> |
||||
|
<result property="upperLimitFlag" column="UPPER_LIMIT_FLAG"/> |
||||
|
<result property="limitTimeType" column="LIMIT_TIME_TYPE"/> |
||||
|
<result property="upperLimitVal" column="UPPER_LIMIT_VAL"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue