| @@ -17,6 +17,7 @@ import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | import java.util.List; | ||||
| import static com.simple.domain.po.WxCampaign.Field.SortNum_ASC; | 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)}) | @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | ||||
| public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) { | ||||
| if (null == wxCampaign) wxCampaign = new WxCampaign(); | if (null == wxCampaign) wxCampaign = new WxCampaign(); | ||||
| if(wxCampaign.getStatus()!=null&&wxCampaign.getStatus()==-1){ | |||||
| wxCampaign.setStatus(null); | |||||
| } | |||||
| wxCampaign.setTenantId(getTenantId()); | wxCampaign.setTenantId(getTenantId()); | ||||
| wxCampaign.setSortColumns(SortNum_ASC); | wxCampaign.setSortColumns(SortNum_ASC); | ||||
| final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize); | final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize); | ||||
| @@ -51,13 +55,13 @@ public class WxCampaignController extends BaseController | |||||
| public ResultData add(@RequestBody WxCampaign wxCampaign) { | public ResultData add(@RequestBody WxCampaign wxCampaign) { | ||||
| //Assert.notNull(wxCampaign.getName(), "角色名不能为空"); | //Assert.notNull(wxCampaign.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| int sortNum = wxCampaignService.getMaxSortNum(getTenantId()); | |||||
| // int sortNum = wxCampaignService.getMaxSortNum(getTenantId()); | |||||
| if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | ||||
| String[] arys = wxCampaign.getCouponIds().split(","); | String[] arys = wxCampaign.getCouponIds().split(","); | ||||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | wxCampaign.setCouponIds(JSON.toJSONString(arys)); | ||||
| } | } | ||||
| wxCampaign.setTenantId(getTenantId()); | wxCampaign.setTenantId(getTenantId()); | ||||
| wxCampaign.setSortNum(sortNum+1); | |||||
| // wxCampaign.setSortNum(sortNum+1); | |||||
| wxCampaignService.saveOrUpdate(wxCampaign); | wxCampaignService.saveOrUpdate(wxCampaign); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -65,6 +69,10 @@ public class WxCampaignController extends BaseController | |||||
| @ApiOperation("根据id更新接口") | @ApiOperation("根据id更新接口") | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxCampaign wxCampaign) { | public ResultData update(@RequestBody WxCampaign wxCampaign) { | ||||
| if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | |||||
| String[] arys = wxCampaign.getCouponIds().split(","); | |||||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | |||||
| } | |||||
| wxCampaignService.saveOrUpdate(wxCampaign); | wxCampaignService.saveOrUpdate(wxCampaign); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -82,8 +90,13 @@ public class WxCampaignController extends BaseController | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | ||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| WxCampaign wxCampaign = wxCampaignService.getById(id); | WxCampaign wxCampaign = wxCampaignService.getById(id); | ||||
| if(wxCampaign!=null) { | |||||
| List<Long> list = JSON.parseArray(wxCampaign.getCouponIds(), Long.class); | |||||
| if (wxCampaign != null) { | |||||
| List<Long> list = new ArrayList<>(); | |||||
| List<String> templist = JSON.parseArray(wxCampaign.getCouponIds(), String.class); | |||||
| for (String temp : templist | |||||
| ) { | |||||
| list.add(Long.parseLong(temp)); | |||||
| } | |||||
| WxCoupon wxCoupon = new WxCoupon(); | WxCoupon wxCoupon = new WxCoupon(); | ||||
| wxCoupon.setTenantId(getTenantId()); | wxCoupon.setTenantId(getTenantId()); | ||||
| wxCoupon.setIds(list); | wxCoupon.setIds(list); | ||||
| @@ -1,22 +1,24 @@ | |||||
| package com.simple.domain.po; | 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 javax.persistence.Transient; | ||||
| import java.io.Serializable; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_campaign") | @Table(name = "wx_campaign") | ||||
| public class WxCampaign implements Serializable { | public class WxCampaign implements Serializable { | ||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @Id | @Id | ||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| @Transient | @Transient | ||||
| protected List<WxCoupon> coupons; | protected List<WxCoupon> coupons; | ||||
| @@ -28,9 +30,6 @@ public class WxCampaign implements Serializable { | |||||
| this.coupons = coupons; | this.coupons = coupons; | ||||
| } | } | ||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | public Long getId() { | ||||
| return id; | return id; | ||||
| } | } | ||||
| @@ -38,11 +37,11 @@ public class WxCampaign implements Serializable { | |||||
| public void setId(Long id) { | public void setId(Long id) { | ||||
| this.id = id; | this.id = id; | ||||
| } | } | ||||
| public String getSortColumns() { | public String getSortColumns() { | ||||
| return sortColumns; | return sortColumns; | ||||
| } | } | ||||
| public List<Long> getIds() { | public List<Long> getIds() { | ||||
| return ids; | return ids; | ||||
| } | } | ||||
| @@ -50,9 +49,9 @@ public class WxCampaign implements Serializable { | |||||
| public void setIds(List<Long> ids) { | public void setIds(List<Long> ids) { | ||||
| this.ids = ids; | this.ids = ids; | ||||
| } | } | ||||
| /***/ | /***/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| @@ -95,6 +94,15 @@ public class WxCampaign implements Serializable { | |||||
| /*排序**/ | /*排序**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="排序",name="sortNum") | @io.swagger.annotations.ApiModelProperty(value="排序",name="sortNum") | ||||
| private Integer 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() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -179,27 +187,48 @@ public class WxCampaign implements Serializable { | |||||
| public void setSortNum(Integer _sortNum) { | public void setSortNum(Integer _sortNum) { | ||||
| sortNum = _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 | 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") | |||||
| ,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; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| this.value = value; | this.value = value; | ||||
| @@ -215,7 +244,7 @@ public class WxCampaign implements Serializable { | |||||
| return this.getValue(); | return this.getValue(); | ||||
| } | } | ||||
| } | } | ||||
| public void setSortColumns(WxCampaign.Field... fields) | public void setSortColumns(WxCampaign.Field... fields) | ||||
| { | { | ||||
| if (fields == null || fields.length == 0) { | if (fields == null || fields.length == 0) { | ||||
| @@ -241,7 +270,7 @@ public class WxCampaign implements Serializable { | |||||
| } | } | ||||
| if (sortColumns.contains(",")) { | if (sortColumns.contains(",")) { | ||||
| String[] cols = sortColumns.split(","); | String[] cols = sortColumns.split(","); | ||||
| List<Field> fList = new ArrayList(); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | for (int k = 0; k < cols.length; k++) { | ||||
| fList.add(Field.valueOf(cols[k])); | fList.add(Field.valueOf(cols[k])); | ||||
| } | } | ||||
| @@ -17,98 +17,116 @@ | |||||
| <result column="coupon_ids" jdbcType="VARCHAR" property="couponIds" /> | <result column="coupon_ids" jdbcType="VARCHAR" property="couponIds" /> | ||||
| <result column="mechant_id" jdbcType="BIGINT" property="mechantId" /> | <result column="mechant_id" jdbcType="BIGINT" property="mechantId" /> | ||||
| <result column="sort_num" jdbcType="INTEGER" property="sortNum" /> | <result column="sort_num" jdbcType="INTEGER" property="sortNum" /> | ||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `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` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <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 != coverImg "> | |||||
| and `cover_img` like concat('%', #{coverImg},'%') | |||||
| </if> | |||||
| <if test=" null != title "> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != subTitle "> | |||||
| and `sub_title` like concat('%', #{subTitle},'%') | |||||
| </if> | |||||
| <if test=" null != usePrice "> | |||||
| and `use_price` = #{usePrice} | |||||
| </if> | |||||
| <if test=" null != discountPrice "> | |||||
| and `discount_price` = #{discountPrice} | |||||
| </if> | |||||
| <if test=" null != detail "> | |||||
| and `detail` like concat('%', #{detail},'%') | |||||
| </if> | |||||
| <if test=" null != validStartDate "> | |||||
| and `valid_start_date` = #{validStartDate} | |||||
| </if> | |||||
| <if test=" null != validEndDate "> | |||||
| and `valid_end_date` = #{validEndDate} | |||||
| </if> | |||||
| <if test=" null != imgDetail "> | |||||
| and `img_detail` like concat('%', #{imgDetail},'%') | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != couponIds "> | |||||
| and `coupon_ids` like concat('%', #{couponIds},'%') | |||||
| </if> | |||||
| <if test=" null != mechantId "> | |||||
| and `mechant_id` = #{mechantId} | |||||
| </if> | |||||
| <if test=" null != sortNum "> | |||||
| and `sort_num` = #{sortNum} | |||||
| </if> | |||||
| 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 != coverImg "> | |||||
| and `cover_img` like concat('%', #{coverImg},'%') | |||||
| </if> | |||||
| <if test=" null != title "> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != subTitle "> | |||||
| and `sub_title` like concat('%', #{subTitle},'%') | |||||
| </if> | |||||
| <if test=" null != usePrice "> | |||||
| and `use_price` = #{usePrice} | |||||
| </if> | |||||
| <if test=" null != discountPrice "> | |||||
| and `discount_price` = #{discountPrice} | |||||
| </if> | |||||
| <if test=" null != detail "> | |||||
| and `detail` like concat('%', #{detail},'%') | |||||
| </if> | |||||
| <if test=" null != validStartDate "> | |||||
| and `valid_start_date` = #{validStartDate} | |||||
| </if> | |||||
| <if test=" null != validEndDate "> | |||||
| and `valid_end_date` = #{validEndDate} | |||||
| </if> | |||||
| <if test=" null != imgDetail "> | |||||
| and `img_detail` like concat('%', #{imgDetail},'%') | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != couponIds "> | |||||
| and `coupon_ids` like concat('%', #{couponIds},'%') | |||||
| </if> | |||||
| <if test=" null != mechantId "> | |||||
| and `mechant_id` = #{mechantId} | |||||
| </if> | |||||
| <if test=" null != sortNum "> | |||||
| and `sort_num` = #{sortNum} | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and `status` = #{status} | |||||
| </if> | |||||
| <if test=" null != createTime "> | |||||
| and `create_time` = #{createTime} | |||||
| </if> | |||||
| <if test=" null != updateTime "> | |||||
| and `update_time` = #{updateTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | |||||
| #{idItem} | |||||
| </foreach> | </foreach> | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </sql> | </sql> | ||||
| <select id="findList" parameterType="com.simple.domain.po.WxCampaign" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.simple.domain.po.WxCampaign" resultMap="BaseResultMap"> | ||||
| select <include refid="allColumns" /> from wx_campaign | select <include refid="allColumns" /> from wx_campaign | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||