| @@ -1,12 +1,9 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.service.PushLimitService; | import com.iformall.service.PushLimitService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -22,16 +19,13 @@ public class PushLimitController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private PushLimitService pushLimitService; | private PushLimitService pushLimitService; | ||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| public ResultData list(@ModelAttribute PushLimit pushLimit) { | |||||
| if (null == pushLimit) pushLimit = new PushLimit(); | |||||
| pushLimit.setTenantId(getTenantId()); | |||||
| final PageInfo<PushLimit> page = pushLimitService.listAsPage(pushLimit, 1, 10); | |||||
| return new ResultData(page); | |||||
| @ApiOperation("疲劳度配置") | |||||
| @GetMapping("setting") | |||||
| public ResultData list() { | |||||
| PushLimit pushLimit = pushLimitService.getPushLimit(getTenantId()); | |||||
| return new ResultData(pushLimit); | |||||
| } | } | ||||
| @ApiOperation("根据id更新接口") | @ApiOperation("根据id更新接口") | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody PushLimit pushLimit) { | public ResultData update(@RequestBody PushLimit pushLimit) { | ||||
| @@ -40,29 +34,4 @@ public class PushLimitController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData delete(Long id) { | |||||
| pushLimitService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData findById(Long id) { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", pushLimitService.getById(id)); | |||||
| } | |||||
| @ApiOperation("默认数据接口") | |||||
| @GetMapping("/getDefaultData") | |||||
| public ResultData getDefaultData() { | |||||
| PushLimit pushLimit=pushLimitService.getDefaultData(getTenantId()); | |||||
| return new ResultData(pushLimit); | |||||
| } | |||||
| } | } | ||||
| @@ -41,24 +41,24 @@ public class PushLimit implements Serializable { | |||||
| /***/ | |||||
| /**租户ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| /*每人每天可接收短信数**/ | |||||
| /**每人每天可接收短信数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="每人每天可接收短信数",name="msgAmount") | @io.swagger.annotations.ApiModelProperty(value="每人每天可接收短信数",name="msgAmount") | ||||
| private Integer msgAmount; | private Integer msgAmount; | ||||
| /*每人每周可接收发券数**/ | |||||
| /**每人每周可接收发券数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="每人每周可接收发券数",name="couponAmount") | @io.swagger.annotations.ApiModelProperty(value="每人每周可接收发券数",name="couponAmount") | ||||
| private Integer couponAmount; | private Integer couponAmount; | ||||
| /*每人几天内,不会收到同一个券**/ | |||||
| /**(每人几天内,不会收到同一个券**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="每人几天内,不会收到同一个券",name="couponDay") | @io.swagger.annotations.ApiModelProperty(value="每人几天内,不会收到同一个券",name="couponDay") | ||||
| private Integer couponDay; | private Integer couponDay; | ||||
| /*禁止发券,发短信开始时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="禁止发券,发短信开始时间",name="refuseTimeStart") | |||||
| private String refuseTimeStart; | |||||
| /*禁止发券,发短信结束时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="禁止发券,发短信结束时间",name="refuseTimeEnd") | |||||
| private String refuseTimeEnd; | |||||
| /**发券,发短信开始时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="发券,发短信开始时间",name="timeStart") | |||||
| private String timeStart; | |||||
| /**发券,发短信结束时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="发券,发短信结束时间",name="timeEnd") | |||||
| private String timeEnd; | |||||
| /***/ | /***/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="createTime") | @io.swagger.annotations.ApiModelProperty(value="",name="createTime") | ||||
| private Date createTime; | private Date createTime; | ||||
| @@ -89,18 +89,23 @@ public class PushLimit implements Serializable { | |||||
| public void setCouponDay(Integer _couponDay) { | public void setCouponDay(Integer _couponDay) { | ||||
| couponDay = _couponDay; | couponDay = _couponDay; | ||||
| } | } | ||||
| public String getRefuseTimeStart() { | |||||
| return refuseTimeStart; | |||||
| public String getTimeStart() { | |||||
| return timeStart; | |||||
| } | } | ||||
| public void setRefuseTimeStart(String _refuseTimeStart) { | |||||
| refuseTimeStart = _refuseTimeStart; | |||||
| public void setTimeStart(String timeStart) { | |||||
| this.timeStart = timeStart; | |||||
| } | } | ||||
| public String getRefuseTimeEnd() { | |||||
| return refuseTimeEnd; | |||||
| public String getTimeEnd() { | |||||
| return timeEnd; | |||||
| } | } | ||||
| public void setRefuseTimeEnd(String _refuseTimeEnd) { | |||||
| refuseTimeEnd = _refuseTimeEnd; | |||||
| public void setTimeEnd(String timeEnd) { | |||||
| this.timeEnd = timeEnd; | |||||
| } | } | ||||
| public Date getCreateTime() { | public Date getCreateTime() { | ||||
| return createTime; | return createTime; | ||||
| } | } | ||||
| @@ -119,14 +124,14 @@ public class PushLimit implements Serializable { | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,MsgAmount_ASC("`msgAmount` ASC"),MsgAmount_DESC("`msgAmount` DESC") | |||||
| ,CouponAmount_ASC("`couponAmount` ASC"),CouponAmount_DESC("`couponAmount` DESC") | |||||
| ,CouponDay_ASC("`couponDay` ASC"),CouponDay_DESC("`couponDay` DESC") | |||||
| ,RefuseTimeStart_ASC("`refuseTimeStart` ASC"),RefuseTimeStart_DESC("`refuseTimeStart` DESC") | |||||
| ,RefuseTimeEnd_ASC("`refuseTimeEnd` ASC"),RefuseTimeEnd_DESC("`refuseTimeEnd` DESC") | |||||
| ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") | |||||
| ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") | |||||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||||
| ,MsgAmount_ASC("`msg_amount` ASC"),MsgAmount_DESC("`msg_amount` DESC") | |||||
| ,CouponAmount_ASC("`coupon_amount` ASC"),CouponAmount_DESC("`coupon_amount` DESC") | |||||
| ,CouponDay_ASC("`coupon_day` ASC"),CouponDay_DESC("`coupon_day` DESC") | |||||
| ,TimeStart_ASC("`time_start` ASC"),TimeStart_DESC("`time_start` DESC") | |||||
| ,TimeEnd_ASC("`time_end` ASC"),TimeEnd_DESC("`time_end` DESC") | |||||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||||
| ,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -159,7 +164,7 @@ public class PushLimit implements Serializable { | |||||
| sb.append(","); | sb.append(","); | ||||
| sb.append(fields[k].toString()); | sb.append(fields[k].toString()); | ||||
| } | } | ||||
| this.sortColumns = sb.toString(); | |||||
| } | } | ||||
| public void setSortColumns(String sortColumns) | public void setSortColumns(String sortColumns) | ||||
| @@ -5,29 +5,37 @@ import com.iformall.domain.po.PushLimit; | |||||
| public interface PushLimitService { | public interface PushLimitService { | ||||
| /** | |||||
| /** | |||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| * | * | ||||
| * @param record | * @param record | ||||
| * @param offset | |||||
| * @param limit | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<PushLimit> listAsPage(PushLimit record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| PageInfo<PushLimit> listAsPage(PushLimit record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 获取租户的ScoreRules | |||||
| * | |||||
| * @param tenantId | |||||
| * @return | |||||
| */ | |||||
| PushLimit getPushLimit(String tenantId); | |||||
| /** | |||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| * | * | ||||
| * @param id | * @param id | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PushLimit getById(Long id); | PushLimit getById(Long id); | ||||
| /** | |||||
| /** | |||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| * @param record | |||||
| */ | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(PushLimit record); | void saveOrUpdate(PushLimit record); | ||||
| /** | /** | ||||
| @@ -36,7 +44,4 @@ public interface PushLimitService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| PushLimit getDefaultData(String tenantId); | |||||
| } | } | ||||
| @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| @Service | @Service | ||||
| @@ -26,6 +27,30 @@ public class PushLimitServiceImpl implements PushLimitService { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> pushLimitMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> pushLimitMapper.findList(record)); | ||||
| } | } | ||||
| @Override | |||||
| public PushLimit getPushLimit(String tenantId) { | |||||
| PushLimit pushLimit = new PushLimit(); | |||||
| pushLimit.setTenantId(tenantId); | |||||
| List<PushLimit> list = pushLimitMapper.findList(pushLimit); | |||||
| if (list.size() > 0) { | |||||
| return list.get(0); | |||||
| } | |||||
| // 如果疲劳度设置不存在,启用默认值 | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| pushLimit.setId(idWorker.nextId()); | |||||
| pushLimit.setMsgAmount(3); | |||||
| pushLimit.setCouponAmount(10); | |||||
| pushLimit.setCouponDay(10); | |||||
| pushLimit.setTimeStart("8:30"); | |||||
| pushLimit.setTimeEnd("18:00"); | |||||
| Date curDate = new Date(); | |||||
| pushLimit.setCreateTime(curDate); | |||||
| pushLimit.setUpdateTime(curDate); | |||||
| pushLimitMapper.insertSelective(pushLimit); | |||||
| return pushLimit; | |||||
| } | |||||
| @Override | @Override | ||||
| public PushLimit getById(Long id) { | public PushLimit getById(Long id) { | ||||
| return pushLimitMapper.selectByPrimaryKey(id); | return pushLimitMapper.selectByPrimaryKey(id); | ||||
| @@ -33,50 +58,11 @@ public class PushLimitServiceImpl implements PushLimitService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(PushLimit record) { | public void saveOrUpdate(PushLimit record) { | ||||
| PushLimit params=new PushLimit(); | |||||
| params.setTenantId(record.getTenantId()); | |||||
| List<PushLimit> list = pushLimitMapper.findList(params); | |||||
| if(list.size()>0){ | |||||
| pushLimitMapper.updateByPrimaryKeySelective(record); | |||||
| }else{ | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| pushLimitMapper.insertSelective(record); | |||||
| } | |||||
| // if (record.getId() == null) { | |||||
| // //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| // final IdWorker idWorker = IdWorker.get(); | |||||
| // record.setId(idWorker.nextId()); | |||||
| // pushLimitMapper.insertSelective(record); | |||||
| // return record.getId(); | |||||
| // } else { | |||||
| // pushLimitMapper.updateByPrimaryKeySelective(record); | |||||
| // return record.getId(); | |||||
| // } | |||||
| pushLimitMapper.updateByPrimaryKeySelective(record); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| pushLimitMapper.deleteByPrimaryKey(id); | pushLimitMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public PushLimit getDefaultData(String tenantId) { | |||||
| PushLimit record =new PushLimit(); | |||||
| record.setTenantId(tenantId); | |||||
| List<PushLimit> list = pushLimitMapper.findList(record); | |||||
| if(list.size()>0){ | |||||
| record=list.get(0); | |||||
| }else{ | |||||
| record=new PushLimit(); | |||||
| record.setMsgAmount(3); | |||||
| record.setRefuseTimeStart("00:00"); | |||||
| record.setRefuseTimeEnd("23:45"); | |||||
| record.setCouponDay(10); | |||||
| record.setCouponAmount(10); | |||||
| } | |||||
| return record; | |||||
| } | |||||
| } | } | ||||
| @@ -1,86 +1,75 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?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"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.iformall.mapper.PushLimitMapper"> | <mapper namespace="com.iformall.mapper.PushLimitMapper"> | ||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.PushLimit"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="msg_amount" jdbcType="INTEGER" property="msgAmount" /> | |||||
| <result column="coupon_amount" jdbcType="INTEGER" property="couponAmount" /> | |||||
| <result column="coupon_day" jdbcType="INTEGER" property="couponDay" /> | |||||
| <result column="refuse_time_start" jdbcType="VARCHAR" property="refuseTimeStart" /> | |||||
| <result column="refuse_time_end" jdbcType="VARCHAR" property="refuseTimeEnd" /> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`refuse_time_start`,`refuse_time_end`,`create_time`,`update_time` | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.PushLimit"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="msg_amount" jdbcType="INTEGER" property="msgAmount"/> | |||||
| <result column="coupon_amount" jdbcType="INTEGER" property="couponAmount"/> | |||||
| <result column="coupon_day" jdbcType="INTEGER" property="couponDay"/> | |||||
| <result column="time_start" jdbcType="VARCHAR" property="timeStart"/> | |||||
| <result column="time_end" jdbcType="VARCHAR" property="timeEnd"/> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_start`,`time_end`,`create_time`,`update_time` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != msgAmount "> | |||||
| and `msg_amount` = #{msgAmount} | |||||
| </if> | |||||
| <if test=" null != couponAmount "> | |||||
| and `coupon_amount` = #{couponAmount} | |||||
| </if> | |||||
| <if test=" null != couponDay "> | |||||
| and `coupon_day` = #{couponDay} | |||||
| </if> | |||||
| <if test=" null != refuseTimeStart "> | |||||
| and `refuse_time_start` like concat('%', #{refuseTimeStart},'%') | |||||
| </if> | |||||
| <if test=" null != refuseTimeEnd "> | |||||
| and `refuse_time_end` like concat('%', #{refuseTimeEnd},'%') | |||||
| </if> | |||||
| <if test=" null != createTime "> | |||||
| and `create_time` = #{createTime} | |||||
| </if> | |||||
| <if test=" null != updateTime "> | |||||
| and `update_time` = #{updateTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.PushLimit" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from push_limit | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != msgAmount "> | |||||
| and `msg_amount` = #{msgAmount} | |||||
| </if> | |||||
| <if test=" null != couponAmount "> | |||||
| and `coupon_amount` = #{couponAmount} | |||||
| </if> | |||||
| <if test=" null != couponDay "> | |||||
| and `coupon_day` = #{couponDay} | |||||
| </if> | |||||
| <if test=" null != timeStart "> | |||||
| and `time_start` like concat('%', #{timeStart},'%') | |||||
| </if> | |||||
| <if test=" null != timeEnd "> | |||||
| and `time_end` like concat('%', #{timeEnd},'%') | |||||
| </if> | |||||
| <if test=" null != createTime "> | |||||
| and `create_time` = #{createTime} | |||||
| </if> | |||||
| <if test=" null != updateTime "> | |||||
| and `update_time` = #{updateTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.PushLimit" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from push_limit | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||