jinguo24@163.com 7 лет назад
Родитель
Сommit
93893f3f73
8 измененных файлов: 563 добавлений и 104 удалений
  1. +5
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java
  2. +112
    -104
      mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java
  3. +76
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxCouponSpreadController.java
  4. +171
    -0
      mallinkService/src/main/java/com/simple/domain/po/WxCouponSpread.java
  5. +17
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCouponSpreadMapper.java
  6. +48
    -0
      mallinkService/src/main/java/com/simple/service/WxCouponSpreadService.java
  7. +54
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxCouponSpreadServiceImpl.java
  8. +80
    -0
      mallinkService/src/main/resources/mapper/WxCouponSpreadMapper.xml

+ 5
- 0
mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java Просмотреть файл

@@ -2,6 +2,7 @@ package com.simple.controller;

import com.simple.domain.dto.WxCouponChannelDto;
import com.simple.domain.po.MallUserInfo;
import io.swagger.annotations.Api;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -21,6 +22,7 @@ import java.util.List;

@RestController
@RequestMapping("wxCouponChannel")
@Api(description="优惠券投放接口")
public class WxCouponChannelController extends BaseController
{
@Autowired
@@ -36,6 +38,7 @@ public class WxCouponChannelController extends BaseController
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel,Integer pageNum, Integer pageSize) {
if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel();
wxCouponChannel.setTenantId(getUser().getTenantId());
final PageInfo<WxCouponChannel> page = wxCouponChannelService.listAsPage(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}
@@ -45,6 +48,7 @@ public class WxCouponChannelController extends BaseController
public ResultData add(@RequestBody WxCouponChannel wxCouponChannel) {
//Assert.notNull(wxCouponChannel.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponChannel.setTenantId(getUser().getTenantId());
wxCouponChannelService.saveOrUpdate(wxCouponChannel);
return new ResultData();
}
@@ -52,6 +56,7 @@ public class WxCouponChannelController extends BaseController
@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.setTenantId(getUser().getTenantId());
wxCouponChannelService.saveOrUpdate(wxCouponChannel);
return new ResultData();
}


+ 112
- 104
mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java Просмотреть файл

@@ -1,104 +1,112 @@
package com.simple.controller;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.simple.common.Result;
import com.simple.common.ResultData;
import com.simple.domain.dto.WxCounponDto;
import com.simple.domain.po.WxCoupon;
import com.simple.domain.po.WxMerchant;
import com.simple.service.WxCouponService;
import com.simple.service.WxMerchantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("wxCoupon")
@Api(description="优惠券接口")
public class WxCouponController extends BaseController
{
@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxMerchantService wxMerchantService;
private Logger logger = Logger.getLogger(WxCouponController.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 WxCoupon wxCoupon,Integer pageNum, Integer pageSize) {
if (null == wxCoupon) wxCoupon = new WxCoupon();
if(wxCoupon.getType()!=null&&wxCoupon.getType()==-1){
wxCoupon.setType(null);
}
final PageInfo<WxCoupon> page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize);
return new ResultData(page);
}
@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCoupon wxCoupon) {
//Assert.notNull(wxCoupon.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
if(StringUtils.isNotBlank(wxCoupon.getBusiness())) {
String[] arys = wxCoupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
Long id = wxCouponService.saveOrUpdate(wxCoupon);
return new ResultData(id);
}
@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCoupon wxCoupon) {
if(wxCoupon.getId()==null) {
return new ResultData(ResultData.ERROR,"缺少id");
}
if(StringUtils.isNotBlank(wxCoupon.getBusiness())) {
String[] arys = wxCoupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
Long id = wxCouponService.saveOrUpdate(wxCoupon);
return new ResultData(id);
}
@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxCouponService.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) {
WxCoupon c = wxCouponService.getById(id);
WxCounponDto dto = new WxCounponDto();
org.springframework.beans.BeanUtils.copyProperties(c, dto);
WxMerchant merchant = wxMerchantService.getById(c.getMerchantId());
dto.setWxMerchant(merchant);
return new ResultData(Result.SUCCESS,"查询成功",dto);
}
}
package com.simple.controller;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.simple.common.Result;
import com.simple.common.ResultData;
import com.simple.domain.dto.WxCounponDto;
import com.simple.domain.po.WxCoupon;
import com.simple.domain.po.WxMerchant;
import com.simple.service.WxCouponService;
import com.simple.service.WxMerchantService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxCoupon")
@Api(description="优惠券接口")
public class WxCouponController extends BaseController
{
@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxMerchantService wxMerchantService;

private Logger logger = Logger.getLogger(WxCouponController.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 WxCoupon wxCoupon,Integer pageNum, Integer pageSize) {
if (null == wxCoupon) wxCoupon = new WxCoupon();
if(wxCoupon.getType()!=null&&wxCoupon.getType()==-1){
wxCoupon.setType(null);
}
final PageInfo<WxCoupon> page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCoupon wxCoupon) {
//Assert.notNull(wxCoupon.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
if(StringUtils.isNotBlank(wxCoupon.getBusiness())) {
String[] arys = wxCoupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
Long id = wxCouponService.saveOrUpdate(wxCoupon);
return new ResultData(id);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCoupon wxCoupon) {
if(wxCoupon.getId()==null) {
return new ResultData(ResultData.ERROR,"缺少id");
}
if(wxCoupon.getStatus()!=null){
if(wxCoupon.getStatus()==3){ //已作废
WxCoupon temp = wxCouponService.getById(wxCoupon.getId());
if(temp.getStatus()==1){
return new ResultData(Result.ERROR,"生效的卡券,不能修改");
}
}
}
if(StringUtils.isNotBlank(wxCoupon.getBusiness())) {
String[] arys = wxCoupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
Long id = wxCouponService.saveOrUpdate(wxCoupon);
return new ResultData(id);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxCouponService.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) {
WxCoupon c = wxCouponService.getById(id);
WxCounponDto dto = new WxCounponDto();
org.springframework.beans.BeanUtils.copyProperties(c, dto);
WxMerchant merchant = wxMerchantService.getById(c.getMerchantId());
dto.setWxMerchant(merchant);
return new ResultData(Result.SUCCESS,"查询成功",dto);
}
}

+ 76
- 0
mallinkAdmin/src/main/java/com/simple/controller/WxCouponSpreadController.java Просмотреть файл

@@ -0,0 +1,76 @@
package com.simple.controller;

import io.swagger.annotations.Api;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.simple.common.Result;
import com.simple.common.ResultData;

import com.simple.domain.po.WxCouponSpread;
import com.simple.service.WxCouponSpreadService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxCouponSpread")
@Api(description="推广接口")
public class WxCouponSpreadController extends BaseController
{
@Autowired
private WxCouponSpreadService wxCouponSpreadService;

private Logger logger = Logger.getLogger(WxCouponSpreadController.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 WxCouponSpread wxCouponSpread,Integer pageNum, Integer pageSize) {
if (null == wxCouponSpread) wxCouponSpread = new WxCouponSpread();
final PageInfo<WxCouponSpread> page = wxCouponSpreadService.listAsPage(wxCouponSpread, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCouponSpread wxCouponSpread) {
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")
public ResultData update(@RequestBody WxCouponSpread wxCouponSpread) {
wxCouponSpreadService.saveOrUpdate(wxCouponSpread);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxCouponSpreadService.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,"查询成功",wxCouponSpreadService.getById(id));
}
}

+ 171
- 0
mallinkService/src/main/java/com/simple/domain/po/WxCouponSpread.java Просмотреть файл

@@ -0,0 +1,171 @@
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 = "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));
}
}
}

+ 17
- 0
mallinkService/src/main/java/com/simple/mapper/WxCouponSpreadMapper.java Просмотреть файл

@@ -0,0 +1,17 @@
package com.simple.mapper;

import java.util.*;
import com.simple.common.CommonMapper;
import org.apache.ibatis.annotations.Param;
import com.simple.domain.po.WxCouponSpread;

public interface WxCouponSpreadMapper extends CommonMapper<WxCouponSpread, String> {

List<WxCouponSpread> findList(WxCouponSpread wxCouponSpread);

}

+ 48
- 0
mallinkService/src/main/java/com/simple/service/WxCouponSpreadService.java Просмотреть файл

@@ -0,0 +1,48 @@
package com.simple.service;

import java.util.*;
import com.github.pagehelper.PageInfo;
import com.simple.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);

}

+ 54
- 0
mallinkService/src/main/java/com/simple/service/impl/WxCouponSpreadServiceImpl.java Просмотреть файл

@@ -0,0 +1,54 @@
package com.simple.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.simple.domain.po.WxCouponSpread;
import com.simple.mapper.WxCouponSpreadMapper;
import com.simple.service.WxCouponSpreadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.simple.common.IdWorker;

@Service
public class WxCouponSpreadServiceImpl implements WxCouponSpreadService {
@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);
}
}

+ 80
- 0
mallinkService/src/main/resources/mapper/WxCouponSpreadMapper.xml Просмотреть файл

@@ -0,0 +1,80 @@
<?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.WxCouponSpreadMapper">
<resultMap id="BaseResultMap" type="com.simple.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.simple.domain.po.WxCouponSpread" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_coupon_spread
<include refid="dynamicWhereConditions" />
</select>
</mapper>

Загрузка…
Отмена
Сохранить