diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.java new file mode 100644 index 000000000..a986655c5 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.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.WxUserChannel; +import com.simple.service.WxUserChannelService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("wxUserChannel") +public class WxUserChannelController extends BaseController +{ + @Autowired + private WxUserChannelService wxUserChannelService; + + private Logger logger = Logger.getLogger(WxUserChannelController.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 WxUserChannel wxUserChannel,Integer pageNum, Integer pageSize) { + if (null == wxUserChannel) wxUserChannel = new WxUserChannel(); + final PageInfo page = wxUserChannelService.listAsPage(wxUserChannel, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增接口") + @PostMapping("add") + public ResultData add(@RequestBody WxUserChannel wxUserChannel) { + //Assert.notNull(wxUserChannel.getName(), "角色名不能为空"); + //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); + wxUserChannelService.saveOrUpdate(wxUserChannel); + return new ResultData(); + } + + @ApiOperation("根据id更新接口") + @PostMapping("update") + public ResultData update(@RequestBody WxUserChannel wxUserChannel) { + wxUserChannelService.saveOrUpdate(wxUserChannel); + return new ResultData(); + } + + @ApiOperation("根据id删除接口") + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + wxUserChannelService.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,"查询成功",wxUserChannelService.getById(id)); + } + + + +} diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java b/mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java new file mode 100644 index 000000000..ed551f6ac --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java @@ -0,0 +1,132 @@ +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_user_channel") +public class WxUserChannel 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="channelName") + private String channelName; + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="sceneAddress") + private String sceneAddress; + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="description") + private String description; + public String getChannelName() { + return channelName; + } + public void setChannelName(String _channelName) { + channelName = _channelName; + } + public String getSceneAddress() { + return sceneAddress; + } + public void setSceneAddress(String _sceneAddress) { + sceneAddress = _sceneAddress; + } + public String getDescription() { + return description; + } + public void setDescription(String _description) { + description = _description; + } + + + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,ChannelName_ASC("`channelName` ASC"),ChannelName_DESC("`channelName` DESC") + ,SceneAddress_ASC("`sceneAddress` ASC"),SceneAddress_DESC("`sceneAddress` DESC") + ,Description_ASC("`description` ASC"),Description_DESC("`description` 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(WxUserChannel.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/WxUserChannelMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxUserChannelMapper.java new file mode 100644 index 000000000..7e0cd34ac --- /dev/null +++ b/mallinkService/src/main/java/com/simple/mapper/WxUserChannelMapper.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.WxUserChannel; + +public interface WxUserChannelMapper extends CommonMapper { + + List findList(WxUserChannel wxUserChannel); + + + List findDistinctChannel(); + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/WxUserChannelService.java b/mallinkService/src/main/java/com/simple/service/WxUserChannelService.java new file mode 100644 index 000000000..a7b25fb79 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/WxUserChannelService.java @@ -0,0 +1,48 @@ +package com.simple.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxUserChannel; + +public interface WxUserChannelService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param offset + * @param limit + * @return + */ + PageInfo listAsPage(WxUserChannel record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxUserChannel getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(WxUserChannel record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + List findDistinctChannel(); + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java new file mode 100644 index 000000000..1332d026b --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java @@ -0,0 +1,53 @@ +package com.simple.service.impl; + +import java.util.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxUserChannel; +import com.simple.mapper.WxUserChannelMapper; +import com.simple.service.WxUserChannelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.simple.common.IdWorker; + +@Service +public class WxUserChannelServiceImpl implements WxUserChannelService { + + @Autowired + WxUserChannelMapper wxUserChannelMapper; + + + @Override + public PageInfo listAsPage(WxUserChannel record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxUserChannelMapper.findList(record)); + } + + @Override + public WxUserChannel getById(Long id) { + return wxUserChannelMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(WxUserChannel record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + IdWorker idWorker = new IdWorker(0, 0); + record.setId(idWorker.nextId()); + wxUserChannelMapper.insertSelective(record); + } else { + wxUserChannelMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + wxUserChannelMapper.deleteByPrimaryKey(id); + } + + @Override + public List findDistinctChannel() { + + return wxUserChannelMapper.findDistinctChannel(); + } + +} diff --git a/mallinkService/src/main/resources/mapper/WxUserChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxUserChannelMapper.xml new file mode 100644 index 000000000..39e968ba7 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxUserChannelMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + `id`,`channel_name`,`scene_address`,`description` + + + + where 1 = 1 + + + and `id` = #{id} + + + + + and `channel_name` like concat('%', #{channelName},'%') + + + + + and `scene_address` like concat('%', #{sceneAddress},'%') + + + + + and `description` like concat('%', #{description},'%') + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + +