Просмотр исходного кода

[拓客分析][修改]渠道的新增

release_toaliyun_real
jinguo24@163.com 7 лет назад
Родитель
Сommit
69c344419d
6 измененных файлов: 380 добавлений и 0 удалений
  1. +71
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.java
  2. +132
    -0
      mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java
  3. +17
    -0
      mallinkService/src/main/java/com/simple/mapper/WxUserChannelMapper.java
  4. +48
    -0
      mallinkService/src/main/java/com/simple/service/WxUserChannelService.java
  5. +53
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java
  6. +59
    -0
      mallinkService/src/main/resources/mapper/WxUserChannelMapper.xml

+ 71
- 0
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<WxUserChannel> 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));
}
}

+ 132
- 0
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<Long> 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<Long> getIds() {
return ids;
}

public void setIds(List<Long> 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<Field> 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));
}
}
}

+ 17
- 0
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<WxUserChannel, Long> {

List<WxUserChannel> findList(WxUserChannel wxUserChannel);
List<WxUserChannel> findDistinctChannel();
}

+ 48
- 0
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<WxUserChannel> 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<WxUserChannel> findDistinctChannel();

}

+ 53
- 0
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<WxUserChannel> 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<WxUserChannel> findDistinctChannel() {
return wxUserChannelMapper.findDistinctChannel();
}
}

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

@@ -0,0 +1,59 @@
<?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.WxUserChannelMapper">
<resultMap id="BaseResultMap" type="com.simple.domain.po.WxUserChannel">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="channel_name" jdbcType="VARCHAR" property="channelName" />
<result column="scene_address" jdbcType="VARCHAR" property="sceneAddress" />
<result column="description" jdbcType="VARCHAR" property="description" />
</resultMap>
<sql id="allColumns">
`id`,`channel_name`,`scene_address`,`description`
</sql>

<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
<if test=" null != channelName ">
and `channel_name` like concat('%', #{channelName},'%')
</if>
<if test=" null != sceneAddress ">
and `scene_address` like concat('%', #{sceneAddress},'%')
</if>
<if test=" null != description ">
and `description` like concat('%', #{description},'%')
</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.WxUserChannel" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_user_channel
<include refid="dynamicWhereConditions" />
</select>
<select id="findDistinctChannel"r esultMap="BaseResultMap">
select distinct channel_name from wx_user_channel
<include refid="dynamicWhereConditions" />
</select>
</mapper>

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