From b82e54762e37fe2dbb08e1e2aa81d0c6afa2c1b0 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Wed, 26 Sep 2018 23:18:55 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=96=B2=E5=8A=B3=E5=BA=A6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=87=8D=E6=95=B4][=E9=87=8D=E6=95=B4]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PushLimitController.java | 41 +---- .../com/iformall/domain/po/PushLimit.java | 59 +++---- .../iformall/service/PushLimitService.java | 31 ++-- .../service/impl/PushLimitServiceImpl.java | 66 ++++---- .../main/resources/mapper/PushLimitMapper.xml | 145 ++++++++---------- 5 files changed, 148 insertions(+), 194 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java b/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java index 9f240d19a..2a6d4ba15 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java @@ -1,12 +1,9 @@ package com.iformall.controller; -import com.github.pagehelper.PageInfo; -import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.PushLimit; import com.iformall.service.PushLimitService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,16 +19,13 @@ public class PushLimitController extends BaseController { @Autowired private PushLimitService pushLimitService; - @ApiOperation("分页列表接口") - @GetMapping("list") - public ResultData list(@ModelAttribute PushLimit pushLimit) { - if (null == pushLimit) pushLimit = new PushLimit(); - pushLimit.setTenantId(getTenantId()); - final PageInfo 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更新接口") @PostMapping("update") public ResultData update(@RequestBody PushLimit pushLimit) { @@ -40,29 +34,4 @@ public class PushLimitController extends BaseController { 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); - } - - } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java b/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java index 353923078..ddbe681f6 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java @@ -41,24 +41,24 @@ public class PushLimit implements Serializable { - /***/ + /**租户ID*/ @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="timeStart") + private String timeStart; + /**发券,发短信结束时间**/ + @io.swagger.annotations.ApiModelProperty(value="发券,发短信结束时间",name="timeEnd") + private String timeEnd; /***/ @io.swagger.annotations.ApiModelProperty(value="",name="createTime") private Date createTime; @@ -89,18 +89,23 @@ public class PushLimit implements Serializable { public void setCouponDay(Integer _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() { return createTime; } @@ -119,14 +124,14 @@ public class PushLimit implements Serializable { 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") + ,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; Field(String value){ @@ -159,7 +164,7 @@ public class PushLimit implements Serializable { sb.append(","); sb.append(fields[k].toString()); } - + this.sortColumns = sb.toString(); } public void setSortColumns(String sortColumns) diff --git a/mallinkService/src/main/java/com/iformall/service/PushLimitService.java b/mallinkService/src/main/java/com/iformall/service/PushLimitService.java index 70c97b716..a1382c6be 100644 --- a/mallinkService/src/main/java/com/iformall/service/PushLimitService.java +++ b/mallinkService/src/main/java/com/iformall/service/PushLimitService.java @@ -5,29 +5,37 @@ import com.iformall.domain.po.PushLimit; public interface PushLimitService { - /** + /** * 根据实体查询分页列表 * * @param record - * @param offset - * @param limit + * @param pageIndex + * @param pageSize * @return */ - PageInfo listAsPage(PushLimit record, Integer pageIndex, Integer pageSize); - - /** + PageInfo listAsPage(PushLimit record, Integer pageIndex, Integer pageSize); + + /** + * 获取租户的ScoreRules + * + * @param tenantId + * @return + */ + PushLimit getPushLimit(String tenantId); + + /** * 根据Id获得实体 * * @param id * @return */ PushLimit getById(Long id); - - /** + + /** * 保存或更新实体 * - * @param record - */ + * @param record + */ void saveOrUpdate(PushLimit record); /** @@ -36,7 +44,4 @@ public interface PushLimitService { * @param id */ void deleteById(Long id); - - - PushLimit getDefaultData(String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java index f2a529660..885133790 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; @Service @@ -26,6 +27,30 @@ public class PushLimitServiceImpl implements PushLimitService { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> pushLimitMapper.findList(record)); } + @Override + public PushLimit getPushLimit(String tenantId) { + PushLimit pushLimit = new PushLimit(); + pushLimit.setTenantId(tenantId); + + List 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 public PushLimit getById(Long id) { return pushLimitMapper.selectByPrimaryKey(id); @@ -33,50 +58,11 @@ public class PushLimitServiceImpl implements PushLimitService { @Override public void saveOrUpdate(PushLimit record) { - PushLimit params=new PushLimit(); - params.setTenantId(record.getTenantId()); - List 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 public void deleteById(Long id) { pushLimitMapper.deleteByPrimaryKey(id); } - - @Override - public PushLimit getDefaultData(String tenantId) { - PushLimit record =new PushLimit(); - record.setTenantId(tenantId); - List 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; - } - - } diff --git a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml index 5f98d8e5a..b2c8bb3c0 100644 --- a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml +++ b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml @@ -1,86 +1,75 @@ - - - - - - - - - - - - - - `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`refuse_time_start`,`refuse_time_end`,`create_time`,`update_time` + + + + + + + + + + + + + + `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_start`,`time_end`,`create_time`,`update_time` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` = #{tenantId} - - - - - and `msg_amount` = #{msgAmount} - - - - - and `coupon_amount` = #{couponAmount} - - - - - and `coupon_day` = #{couponDay} - - - - - and `refuse_time_start` like concat('%', #{refuseTimeStart},'%') - - - - - and `refuse_time_end` like concat('%', #{refuseTimeEnd},'%') - - - - - and `create_time` = #{createTime} - - - - - and `update_time` = #{updateTime} - - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - - - - + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + + and `msg_amount` = #{msgAmount} + + + + and `coupon_amount` = #{couponAmount} + + + + and `coupon_day` = #{couponDay} + + + + and `time_start` like concat('%', #{timeStart},'%') + + + + and `time_end` like concat('%', #{timeEnd},'%') + + + + and `create_time` = #{createTime} + + + + and `update_time` = #{updateTime} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + +