diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxChannelController.java new file mode 100644 index 000000000..a439cca3b --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxChannelController.java @@ -0,0 +1,71 @@ +package com.simple.controller; + +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.WxChannel; +import com.simple.service.WxChannelService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("wxChannel") +public class WxChannelController extends BaseController +{ + @Autowired + private WxChannelService wxChannelService; + + private Logger logger = Logger.getLogger(WxChannelController.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 WxChannel wxChannel,Integer pageNum, Integer pageSize) { + if (null == wxChannel) wxChannel = new WxChannel(); + final PageInfo page = wxChannelService.listAsPage(wxChannel, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增接口") + @PostMapping("add") + public ResultData add(@RequestBody WxChannel wxChannel) { + //Assert.notNull(wxChannel.getName(), "角色名不能为空"); + //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); + wxChannelService.saveOrUpdate(wxChannel); + return new ResultData(); + } + + @ApiOperation("根据id更新接口") + @PostMapping("update") + public ResultData update(@RequestBody WxChannel wxChannel) { + wxChannelService.saveOrUpdate(wxChannel); + return new ResultData(); + } + + @ApiOperation("根据id删除接口") + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + wxChannelService.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,"查询成功",wxChannelService.getById(id)); + } + + + +} diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java index dd39b05b8..2b60eb267 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java @@ -19,10 +19,10 @@ import io.swagger.annotations.ApiOperation; @RequestMapping("wxCoupon") public class WxCouponController extends BaseController { + private Logger logger = Logger.getLogger(WxCouponController.class); + @Autowired private WxCouponService wxCouponService; - - private Logger logger = Logger.getLogger(WxCouponController.class); @ApiOperation("分页列表接口") @GetMapping("list") diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxChannel.java b/mallinkService/src/main/java/com/simple/domain/po/WxChannel.java new file mode 100644 index 000000000..9c89beddc --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/po/WxChannel.java @@ -0,0 +1,141 @@ +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_channel") +public class WxChannel implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List 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 getIds() { + return ids; + } + public void setIds(List ids) { + this.ids = ids; + } + + + + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") + private Long tenantId; + /*渠道ID**/ + @io.swagger.annotations.ApiModelProperty(value="渠道ID",name="channelId") + private Integer channelId; + /*渠道名**/ + @io.swagger.annotations.ApiModelProperty(value="渠道名",name="title") + private String title; + /*图片url**/ + @io.swagger.annotations.ApiModelProperty(value="图片url",name="img") + private String img; + public Long getTenantId() { + return tenantId; + } + public void setTenantId(Long _tenantId) { + tenantId = _tenantId; + } + public Integer getChannelId() { + return channelId; + } + public void setChannelId(Integer _channelId) { + channelId = _channelId; + } + public String getTitle() { + return title; + } + public void setTitle(String _title) { + title = _title; + } + public String getImg() { + return img; + } + public void setImg(String _img) { + img = _img; + } + + + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,ChannelId_ASC("`channelId` ASC"),ChannelId_DESC("`channelId` DESC") + ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") + ,Img_ASC("`img` ASC"),Img_DESC("`img` 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(WxChannel.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(","); + java.util.List fList = new java.util.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)); + } + } +} diff --git a/mallinkService/src/main/java/com/simple/mapper/WxChannelMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxChannelMapper.java new file mode 100644 index 000000000..f525da3ba --- /dev/null +++ b/mallinkService/src/main/java/com/simple/mapper/WxChannelMapper.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.WxChannel; + +public interface WxChannelMapper extends CommonMapper { + + List findList(WxChannel wxChannel); + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/WxChannelService.java b/mallinkService/src/main/java/com/simple/service/WxChannelService.java new file mode 100644 index 000000000..dc380d564 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/WxChannelService.java @@ -0,0 +1,48 @@ +package com.simple.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxChannel; + +public interface WxChannelService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param offset + * @param limit + * @return + */ + PageInfo listAsPage(WxChannel record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxChannel getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(WxChannel record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxChannelServiceImpl.java new file mode 100644 index 000000000..77cf2646a --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/impl/WxChannelServiceImpl.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.WxChannel; +import com.simple.mapper.WxChannelMapper; +import com.simple.service.WxChannelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.simple.common.IdWorker; + +@Service +public class WxChannelServiceImpl implements WxChannelService { + + @Autowired + WxChannelMapper wxChannelMapper; + + + @Override + public PageInfo listAsPage(WxChannel record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxChannelMapper.findList(record)); + } + + @Override + public WxChannel getById(Long id) { + return wxChannelMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(WxChannel record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + wxChannelMapper.insertSelective(record); + } else { + wxChannelMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + wxChannelMapper.deleteByPrimaryKey(id); + } + + + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/WxChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxChannelMapper.xml new file mode 100644 index 000000000..c3488c3d1 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxChannelMapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + `id`,`tenant_id`,`channel_id`,`title`,`img` + + + + where 1 = 1 + + + and `id` = #{id} + + + + + and `tenant_id` = #{tenantId} + + + + + and `channel_id` = #{channelId} + + + + + and `title` like concat('%', #{title},'%') + + + + + and `img` like concat('%', #{img},'%') + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + +