| @@ -0,0 +1,61 @@ | |||
| package com.simple.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.PushLimit; | |||
| import com.simple.service.PushLimitService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("pushLimit") | |||
| public class PushLimitController extends BaseController | |||
| { | |||
| @Autowired | |||
| private PushLimitService pushLimitService; | |||
| private Logger logger = Logger.getLogger(PushLimitController.class); | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute PushLimit pushLimit, Integer pageNum, Integer pageSize) { | |||
| if (null == pushLimit) pushLimit = new PushLimit(); | |||
| final PageInfo<PushLimit> page = pushLimitService.listAsPage(pushLimit, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody PushLimit pushLimit) { | |||
| pushLimitService.saveOrUpdate(pushLimit); | |||
| 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)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,182 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "push_limit") | |||
| public class PushLimit implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | |||
| private String tenantId; | |||
| /*每人每天可接收短信数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="每人每天可接收短信数",name="msgAmount") | |||
| private Integer msgAmount; | |||
| /*每人每周可接收发券数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="每人每周可接收发券数",name="couponAmount") | |||
| private Integer couponAmount; | |||
| /*每人几天内,不会收到同一个券**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="每人几天内,不会收到同一个券",name="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="createTime") | |||
| private Date createTime; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="updateTime") | |||
| private Date updateTime; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Integer getMsgAmount() { | |||
| return msgAmount; | |||
| } | |||
| public void setMsgAmount(Integer _msgAmount) { | |||
| msgAmount = _msgAmount; | |||
| } | |||
| public Integer getCouponAmount() { | |||
| return couponAmount; | |||
| } | |||
| public void setCouponAmount(Integer _couponAmount) { | |||
| couponAmount = _couponAmount; | |||
| } | |||
| public Integer getCouponDay() { | |||
| return couponDay; | |||
| } | |||
| public void setCouponDay(Integer _couponDay) { | |||
| couponDay = _couponDay; | |||
| } | |||
| public String getRefuseTimeStart() { | |||
| return refuseTimeStart; | |||
| } | |||
| public void setRefuseTimeStart(String _refuseTimeStart) { | |||
| refuseTimeStart = _refuseTimeStart; | |||
| } | |||
| public String getRefuseTimeEnd() { | |||
| return refuseTimeEnd; | |||
| } | |||
| public void setRefuseTimeEnd(String _refuseTimeEnd) { | |||
| refuseTimeEnd = _refuseTimeEnd; | |||
| } | |||
| public Date getCreateTime() { | |||
| return createTime; | |||
| } | |||
| public void setCreateTime(Date _createTime) { | |||
| createTime = _createTime; | |||
| } | |||
| public Date getUpdateTime() { | |||
| return updateTime; | |||
| } | |||
| public void setUpdateTime(Date _updateTime) { | |||
| updateTime = _updateTime; | |||
| } | |||
| public static enum Field | |||
| { | |||
| 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") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(PushLimit.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.simple.mapper; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.po.PushLimit; | |||
| import java.util.List; | |||
| public interface PushLimitMapper extends CommonMapper<PushLimit, Long> { | |||
| List<PushLimit> findList(PushLimit pushLimit); | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package com.simple.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.PushLimit; | |||
| public interface PushLimitService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<PushLimit> listAsPage(PushLimit record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| PushLimit getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(PushLimit record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -0,0 +1,53 @@ | |||
| package com.simple.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.domain.po.PushLimit; | |||
| import com.simple.mapper.PushLimitMapper; | |||
| import com.simple.service.PushLimitService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @Service | |||
| public class PushLimitServiceImpl implements PushLimitService { | |||
| @Autowired | |||
| PushLimitMapper pushLimitMapper; | |||
| @Override | |||
| public PageInfo<PushLimit> listAsPage(PushLimit record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> pushLimitMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public PushLimit getById(Long id) { | |||
| return pushLimitMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(PushLimit record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| IdWorker idWorker = new IdWorker(0, 0); | |||
| record.setId(idWorker.nextId()); | |||
| pushLimitMapper.insertSelective(record); | |||
| } else { | |||
| pushLimitMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| pushLimitMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,86 @@ | |||
| <?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.simple.mapper.PushLimitMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.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` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{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.simple.domain.po.PushLimit" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from push_limit | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||