| @@ -1,104 +0,0 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCouponSpread; | |||||
| import com.iformall.service.WxCouponSpreadService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxCouponSpread") | |||||
| @Api(description = "推广接口") | |||||
| public class WxCouponSpreadController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponSpreadService wxCouponSpreadService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "券推广-列表") | |||||
| public ResultData list(@ModelAttribute WxCouponSpread wxCouponSpread, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::list"); | |||||
| if (null == wxCouponSpread) wxCouponSpread = new WxCouponSpread(); | |||||
| final PageInfo<WxCouponSpread> page = wxCouponSpreadService.listAsPage(wxCouponSpread, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "券推广-新增") | |||||
| public ResultData add(@RequestBody WxCouponSpread wxCouponSpread) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::add"); | |||||
| if (wxCouponSpread.getCouponId() == null) { | |||||
| return new ResultData(Result.ERROR, "没有找到券id"); | |||||
| } | |||||
| //Assert.notNull(wxCouponSpread.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCouponSpreadService.saveOrUpdate(wxCouponSpread); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "券推广-更新") | |||||
| public ResultData update(@RequestBody WxCouponSpread wxCouponSpread) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::update"); | |||||
| wxCouponSpreadService.saveOrUpdate(wxCouponSpread); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "券推广-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::delete"); | |||||
| wxCouponSpreadService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "券推广-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponSpreadService.getById(id)); | |||||
| } | |||||
| @ApiOperation("根据卡券id查询接口") | |||||
| @GetMapping("/findByCouponId") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "券推广-卡券id查询") | |||||
| public ResultData findByCouponId(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::findByCouponId"); | |||||
| WxCouponSpread result = null; | |||||
| if (id != null) { | |||||
| WxCouponSpread wxCouponSpread = new WxCouponSpread(); | |||||
| wxCouponSpread.setCouponId(id); | |||||
| List<WxCouponSpread> list = wxCouponSpreadService.findList(wxCouponSpread); | |||||
| if (!list.isEmpty()) { | |||||
| result = list.get(0); | |||||
| } | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "查询成功", result); | |||||
| } | |||||
| } | |||||
| @@ -1,170 +0,0 @@ | |||||
| package com.iformall.domain.po; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_coupon_spread") | |||||
| public class WxCouponSpread implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<String> 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<String> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<String> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /*券id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="券id",name="couponId") | |||||
| private Long couponId; | |||||
| /*标题**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="标题",name="title") | |||||
| private String title; | |||||
| /*分享内容**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="分享内容",name="content") | |||||
| private String content; | |||||
| /*分享图片**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="分享图片",name="image") | |||||
| private String image; | |||||
| /*链接地址**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="链接地址",name="linkUrl") | |||||
| private String linkUrl; | |||||
| /*创建时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| /*修改时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| public Long getCouponId() { | |||||
| return couponId; | |||||
| } | |||||
| public void setCouponId(Long _couponId) { | |||||
| couponId = _couponId; | |||||
| } | |||||
| public String getTitle() { | |||||
| return title; | |||||
| } | |||||
| public void setTitle(String _title) { | |||||
| title = _title; | |||||
| } | |||||
| public String getContent() { | |||||
| return content; | |||||
| } | |||||
| public void setContent(String _content) { | |||||
| content = _content; | |||||
| } | |||||
| public String getImage() { | |||||
| return image; | |||||
| } | |||||
| public void setImage(String _image) { | |||||
| image = _image; | |||||
| } | |||||
| public String getLinkUrl() { | |||||
| return linkUrl; | |||||
| } | |||||
| public void setLinkUrl(String _linkUrl) { | |||||
| linkUrl = _linkUrl; | |||||
| } | |||||
| public Date getCreateDate() { | |||||
| return createDate; | |||||
| } | |||||
| public void setCreateDate(Date _createDate) { | |||||
| createDate = _createDate; | |||||
| } | |||||
| public Date getUpdateDate() { | |||||
| return updateDate; | |||||
| } | |||||
| public void setUpdateDate(Date _updateDate) { | |||||
| updateDate = _updateDate; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") | |||||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||||
| ,Content_ASC("`content` ASC"),Content_DESC("`content` DESC") | |||||
| ,Image_ASC("`image` ASC"),Image_DESC("`image` DESC") | |||||
| ,LinkUrl_ASC("`linkUrl` ASC"),LinkUrl_DESC("`linkUrl` DESC") | |||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` 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(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(","); | |||||
| List<Field> fList = new 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)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,16 +0,0 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCouponSpread; | |||||
| public interface WxCouponSpreadMapper extends CommonMapper<WxCouponSpread, String> { | |||||
| List<WxCouponSpread> findList(WxCouponSpread wxCouponSpread); | |||||
| } | |||||
| @@ -1,56 +0,0 @@ | |||||
| package com.iformall.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxCouponSpread; | |||||
| public interface WxCouponSpreadService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxCouponSpread> listAsPage(WxCouponSpread record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxCouponSpread getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxCouponSpread record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| /** | |||||
| * 根据实体查询不分页 | |||||
| * | |||||
| * @param | |||||
| */ | |||||
| List<WxCouponSpread> findList(WxCouponSpread record); | |||||
| } | |||||
| @@ -1,57 +0,0 @@ | |||||
| package com.iformall.service.impl; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxCouponSpread; | |||||
| import com.iformall.mapper.WxCouponSpreadMapper; | |||||
| import com.iformall.service.WxCouponSpreadService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| @Service | |||||
| public class WxCouponSpreadServiceImpl implements WxCouponSpreadService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCouponSpreadMapper wxCouponSpreadMapper; | |||||
| @Override | |||||
| public PageInfo<WxCouponSpread> listAsPage(WxCouponSpread record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSpreadMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxCouponSpread getById(Long id) { | |||||
| return wxCouponSpreadMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxCouponSpread record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxCouponSpreadMapper.insertSelective(record); | |||||
| } else { | |||||
| wxCouponSpreadMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxCouponSpreadMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public List<WxCouponSpread> findList(WxCouponSpread record) { | |||||
| return wxCouponSpreadMapper.findList(record); | |||||
| } | |||||
| } | |||||
| @@ -1,80 +0,0 @@ | |||||
| <?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.iformall.mapper.WxCouponSpreadMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponSpread"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||||
| <result column="content" jdbcType="VARCHAR" property="content" /> | |||||
| <result column="image" jdbcType="VARCHAR" property="image" /> | |||||
| <result column="link_url" jdbcType="VARCHAR" property="linkUrl" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`coupon_id`,`title`,`content`,`image`,`link_url`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != title "> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != content "> | |||||
| and `content` like concat('%', #{content},'%') | |||||
| </if> | |||||
| <if test=" null != image "> | |||||
| and `image` like concat('%', #{image},'%') | |||||
| </if> | |||||
| <if test=" null != linkUrl "> | |||||
| and `link_url` like concat('%', #{linkUrl},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </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.WxCouponSpread" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_spread | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||