From 6a3320af6b5c2f4422fd1e58bf648a1c05b72f7b Mon Sep 17 00:00:00 2001 From: masterspirit Date: Sun, 19 Aug 2018 00:54:55 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E9=A1=B5][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9]:bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCampaignController.java | 21 +- .../java/com/simple/domain/po/WxCampaign.java | 99 ++++++---- .../resources/mapper/WxCampaignMapper.xml | 182 ++++++++++-------- 3 files changed, 181 insertions(+), 121 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java index bd367f33f..20352f96b 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java @@ -17,6 +17,7 @@ import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; import static com.simple.domain.po.WxCampaign.Field.SortNum_ASC; @@ -40,6 +41,9 @@ public class WxCampaignController extends BaseController @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) { if (null == wxCampaign) wxCampaign = new WxCampaign(); + if(wxCampaign.getStatus()!=null&&wxCampaign.getStatus()==-1){ + wxCampaign.setStatus(null); + } wxCampaign.setTenantId(getTenantId()); wxCampaign.setSortColumns(SortNum_ASC); final PageInfo page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize); @@ -51,13 +55,13 @@ public class WxCampaignController extends BaseController public ResultData add(@RequestBody WxCampaign wxCampaign) { //Assert.notNull(wxCampaign.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - int sortNum = wxCampaignService.getMaxSortNum(getTenantId()); +// int sortNum = wxCampaignService.getMaxSortNum(getTenantId()); if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { String[] arys = wxCampaign.getCouponIds().split(","); wxCampaign.setCouponIds(JSON.toJSONString(arys)); } wxCampaign.setTenantId(getTenantId()); - wxCampaign.setSortNum(sortNum+1); +// wxCampaign.setSortNum(sortNum+1); wxCampaignService.saveOrUpdate(wxCampaign); return new ResultData(); } @@ -65,6 +69,10 @@ public class WxCampaignController extends BaseController @ApiOperation("根据id更新接口") @PostMapping("update") public ResultData update(@RequestBody WxCampaign wxCampaign) { + if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { + String[] arys = wxCampaign.getCouponIds().split(","); + wxCampaign.setCouponIds(JSON.toJSONString(arys)); + } wxCampaignService.saveOrUpdate(wxCampaign); return new ResultData(); } @@ -82,8 +90,13 @@ public class WxCampaignController extends BaseController @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) public ResultData findById(Long id) { WxCampaign wxCampaign = wxCampaignService.getById(id); - if(wxCampaign!=null) { - List list = JSON.parseArray(wxCampaign.getCouponIds(), Long.class); + if (wxCampaign != null) { + List list = new ArrayList<>(); + List templist = JSON.parseArray(wxCampaign.getCouponIds(), String.class); + for (String temp : templist + ) { + list.add(Long.parseLong(temp)); + } WxCoupon wxCoupon = new WxCoupon(); wxCoupon.setTenantId(getTenantId()); wxCoupon.setIds(list); diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java b/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java index 97225f6d3..ced30a5d3 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java @@ -1,22 +1,24 @@ package com.simple.domain.po; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; +import java.util.*; +import java.math.*; import javax.persistence.Transient; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; @Table(name = "wx_campaign") public class WxCampaign implements Serializable { private static final long serialVersionUID = 1L; - + @Id - protected Long id; - - @Transient - protected List ids; + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; @Transient protected List coupons; @@ -28,9 +30,6 @@ public class WxCampaign implements Serializable { this.coupons = coupons; } - @Transient - protected String sortColumns; - public Long getId() { return id; } @@ -38,11 +37,11 @@ public class WxCampaign implements Serializable { public void setId(Long id) { this.id = id; } - + public String getSortColumns() { return sortColumns; } - + public List getIds() { return ids; } @@ -50,9 +49,9 @@ public class WxCampaign implements Serializable { public void setIds(List ids) { this.ids = ids; } - - - + + + /***/ @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") private String tenantId; @@ -95,6 +94,15 @@ public class WxCampaign implements Serializable { /*排序**/ @io.swagger.annotations.ApiModelProperty(value="排序",name="sortNum") private Integer sortNum; + /*0上线 1下线**/ + @io.swagger.annotations.ApiModelProperty(value="0上线 1下线",name="status") + private Integer status; + /***/ + @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; } @@ -179,27 +187,48 @@ public class WxCampaign implements Serializable { public void setSortNum(Integer _sortNum) { sortNum = _sortNum; } + public Integer getStatus() { + return status; + } + public void setStatus(Integer _status) { + status = _status; + } + 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") - ,CoverImg_ASC("`coverImg` ASC"),CoverImg_DESC("`coverImg` DESC") - ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") - ,SubTitle_ASC("`subTitle` ASC"),SubTitle_DESC("`subTitle` DESC") - ,UsePrice_ASC("`usePrice` ASC"),UsePrice_DESC("`usePrice` DESC") - ,DiscountPrice_ASC("`discountPrice` ASC"),DiscountPrice_DESC("`discountPrice` DESC") - ,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC") - ,ValidStartDate_ASC("`validStartDate` ASC"),ValidStartDate_DESC("`validStartDate` DESC") - ,ValidEndDate_ASC("`validEndDate` ASC"),ValidEndDate_DESC("`validEndDate` DESC") - ,ImgDetail_ASC("`imgDetail` ASC"),ImgDetail_DESC("`imgDetail` DESC") - ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") - ,CouponIds_ASC("`couponIds` ASC"),CouponIds_DESC("`couponIds` DESC") - ,MechantId_ASC("`mechantId` ASC"),MechantId_DESC("`mechantId` DESC") - ,SortNum_ASC("`sortNum` ASC"),SortNum_DESC("`sortNum` DESC") - ; + ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,CoverImg_ASC("`coverImg` ASC"),CoverImg_DESC("`coverImg` DESC") + ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") + ,SubTitle_ASC("`subTitle` ASC"),SubTitle_DESC("`subTitle` DESC") + ,UsePrice_ASC("`usePrice` ASC"),UsePrice_DESC("`usePrice` DESC") + ,DiscountPrice_ASC("`discountPrice` ASC"),DiscountPrice_DESC("`discountPrice` DESC") + ,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC") + ,ValidStartDate_ASC("`validStartDate` ASC"),ValidStartDate_DESC("`validStartDate` DESC") + ,ValidEndDate_ASC("`validEndDate` ASC"),ValidEndDate_DESC("`validEndDate` DESC") + ,ImgDetail_ASC("`imgDetail` ASC"),ImgDetail_DESC("`imgDetail` DESC") + ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") + ,CouponIds_ASC("`couponIds` ASC"),CouponIds_DESC("`couponIds` DESC") + ,MechantId_ASC("`mechantId` ASC"),MechantId_DESC("`mechantId` DESC") + ,SortNum_ASC("`sortNum` ASC"),SortNum_DESC("`sortNum` DESC") + ,Status_ASC("`status` ASC"),Status_DESC("`status` 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; @@ -215,7 +244,7 @@ public class WxCampaign implements Serializable { return this.getValue(); } } - + public void setSortColumns(WxCampaign.Field... fields) { if (fields == null || fields.length == 0) { @@ -241,7 +270,7 @@ public class WxCampaign implements Serializable { } if (sortColumns.contains(",")) { String[] cols = sortColumns.split(","); - List fList = new ArrayList(); + java.util.List fList = new java.util.ArrayList(); for (int k = 0; k < cols.length; k++) { fList.add(Field.valueOf(cols[k])); } diff --git a/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml b/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml index f30f1ec0f..6d733db1e 100644 --- a/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml @@ -17,98 +17,116 @@ + + + - + - `id`,`tenant_id`,`cover_img`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`,`mechant_id`,`sort_num` + `id`,`tenant_id`,`cover_img`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`,`mechant_id`,`sort_num`,`status`,`create_time`,`update_time` - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `cover_img` like concat('%', #{coverImg},'%') - - - - - and `title` like concat('%', #{title},'%') - - - - - and `sub_title` like concat('%', #{subTitle},'%') - - - - - and `use_price` = #{usePrice} - - - - - and `discount_price` = #{discountPrice} - - - - - and `detail` like concat('%', #{detail},'%') - - - - - and `valid_start_date` = #{validStartDate} - - - - - and `valid_end_date` = #{validEndDate} - - - - - and `img_detail` like concat('%', #{imgDetail},'%') - - - - - and `type` = #{type} - - - - - and `coupon_ids` like concat('%', #{couponIds},'%') - - - - - and `mechant_id` = #{mechantId} - - - - - and `sort_num` = #{sortNum} - - + where 1 = 1 + + + and `id` = #{id} + + + + + and `tenant_id` like concat('%', #{tenantId},'%') + + + + + and `cover_img` like concat('%', #{coverImg},'%') + + + + + and `title` like concat('%', #{title},'%') + + + + + and `sub_title` like concat('%', #{subTitle},'%') + + + + + and `use_price` = #{usePrice} + + + + + and `discount_price` = #{discountPrice} + + + + + and `detail` like concat('%', #{detail},'%') + + + + + and `valid_start_date` = #{validStartDate} + + + + + and `valid_end_date` = #{validEndDate} + + + + + and `img_detail` like concat('%', #{imgDetail},'%') + + + + + and `type` = #{type} + + + + + and `coupon_ids` like concat('%', #{couponIds},'%') + + + + + and `mechant_id` = #{mechantId} + + + + + and `sort_num` = #{sortNum} + + + + + and `status` = #{status} + + + + + and `create_time` = #{createTime} + + + + + and `update_time` = #{updateTime} + + - and id in + and id in - #{idItem} + #{idItem} - + order by ${sortColumns} - +