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

新增会员管理接口

release_toaliyun_real
jinguo24@163.com 7 лет назад
Родитель
Сommit
100f8cb469
7 измененных файлов: 517 добавлений и 4 удалений
  1. +6
    -4
      .gitignore
  2. +77
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java
  3. +211
    -0
      mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java
  4. +17
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java
  5. +48
    -0
      mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java
  6. +54
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java
  7. +104
    -0
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml

+ 6
- 4
.gitignore Просмотреть файл

@@ -1,4 +1,6 @@
.idea/**
*/target/**
logs/**
uploads/**
.idea/**
*/target/**
logs/**
uploads/**
/.project
/.gitignore

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

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

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.github.pagehelper.PageInfo;
import com.simple.common.Result;
import com.simple.common.ResultData;
import com.simple.domain.po.WxCUserBasicInfo;
import com.simple.service.WxCUserBasicInfoService;

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

@RestController
@RequestMapping("wxCUserBasicInfo")
@Api(description="会员管理相关接口")
public class WxCUserBasicInfoController extends BaseController
{
@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

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

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
//Assert.notNull(wxCUserBasicInfo.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo);
return new ResultData();
}

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

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

@@ -0,0 +1,211 @@
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_c_user_basic_info")
public class WxCUserBasicInfo 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;
}
/*微信用户绑定的手机号**/
@io.swagger.annotations.ApiModelProperty(value="微信用户绑定的手机号",name="phone")
private String phone;
/*出生日期**/
@io.swagger.annotations.ApiModelProperty(value="出生日期",name="birthdate")
private Date birthdate;
/*学历**/
@io.swagger.annotations.ApiModelProperty(value="学历",name="education")
private String education;
/*性别:0:保密 1.男 2女**/
@io.swagger.annotations.ApiModelProperty(value="性别:0:保密 1.男 2女",name="sex")
private Integer sex;
/*邮箱**/
@io.swagger.annotations.ApiModelProperty(value="邮箱",name="email")
private String email;
/*地址**/
@io.swagger.annotations.ApiModelProperty(value="地址",name="address")
private String address;
/*积分**/
@io.swagger.annotations.ApiModelProperty(value="积分",name="poins")
private Integer poins;
/*标签**/
@io.swagger.annotations.ApiModelProperty(value="标签",name="tagId")
private Long tagId;
/*wx_c_user 的id**/
@io.swagger.annotations.ApiModelProperty(value="wx_c_user 的id",name="cUserId")
private Long cUserId;
/*创建时间**/
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
/*更新时间**/
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
private Date updateDate;
public String getPhone() {
return phone;
}
public void setPhone(String _phone) {
phone = _phone;
}
public Date getBirthdate() {
return birthdate;
}
public void setBirthdate(Date _birthdate) {
birthdate = _birthdate;
}
public String getEducation() {
return education;
}
public void setEducation(String _education) {
education = _education;
}
public Integer getSex() {
return sex;
}
public void setSex(Integer _sex) {
sex = _sex;
}
public String getEmail() {
return email;
}
public void setEmail(String _email) {
email = _email;
}
public String getAddress() {
return address;
}
public void setAddress(String _address) {
address = _address;
}
public Integer getPoins() {
return poins;
}
public void setPoins(Integer _poins) {
poins = _poins;
}
public Long getTagId() {
return tagId;
}
public void setTagId(Long _tagId) {
tagId = _tagId;
}
public Long getCUserId() {
return cUserId;
}
public void setCUserId(Long _cUserId) {
cUserId = _cUserId;
}
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")
,Phone_ASC("`phone` ASC"),Phone_DESC("`phone` DESC")
,Birthdate_ASC("`birthdate` ASC"),Birthdate_DESC("`birthdate` DESC")
,Education_ASC("`education` ASC"),Education_DESC("`education` DESC")
,Sex_ASC("`sex` ASC"),Sex_DESC("`sex` DESC")
,Email_ASC("`email` ASC"),Email_DESC("`email` DESC")
,Address_ASC("`address` ASC"),Address_DESC("`address` DESC")
,Poins_ASC("`poins` ASC"),Poins_DESC("`poins` DESC")
,TagId_ASC("`tagId` ASC"),TagId_DESC("`tagId` DESC")
,CUserId_ASC("`cUserId` ASC"),CUserId_DESC("`cUserId` 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(WxCUserBasicInfo.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/WxCUserBasicInfoMapper.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.WxCUserBasicInfo;

public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, String> {

List<WxCUserBasicInfo> findList(WxCUserBasicInfo wxCUserBasicInfo);

}

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

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

import java.util.*;
import com.github.pagehelper.PageInfo;
import com.simple.domain.po.WxCUserBasicInfo;

public interface WxCUserBasicInfoService {

/**
* 根据实体查询分页列表
*
* @param record
* @param offset
* @param limit
* @return
*/
PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize);
/**
* 根据Id获得实体
*
* @param id
* @return
*/
WxCUserBasicInfo getById(Long id);
/**
* 保存或更新实体
*
* @param record
*/
void saveOrUpdate(WxCUserBasicInfo record);

/**
* 根据Id删除实体
*
* @param id
*/
void deleteById(Long id);

}

+ 54
- 0
mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.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.WxCUserBasicInfo;
import com.simple.mapper.WxCUserBasicInfoMapper;
import com.simple.service.WxCUserBasicInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.simple.common.IdWorker;

@Service
public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
@Autowired
WxCUserBasicInfoMapper wxCUserBasicInfoMapper;


@Override
public PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record));
}

@Override
public WxCUserBasicInfo getById(Long id) {
return wxCUserBasicInfoMapper.selectByPrimaryKey(id);
}

@Override
public void saveOrUpdate(WxCUserBasicInfo record) {
if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
IdWorker idWorker = new IdWorker(0, 0);
record.setId(idWorker.nextId());
wxCUserBasicInfoMapper.insertSelective(record);
} else {
wxCUserBasicInfoMapper.updateByPrimaryKeySelective(record);
}
}

@Override
public void deleteById(Long id) {
wxCUserBasicInfoMapper.deleteByPrimaryKey(id);
}
}

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

@@ -0,0 +1,104 @@
<?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.WxCUserBasicInfoMapper">
<resultMap id="BaseResultMap" type="com.simple.domain.po.WxCUserBasicInfo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="birthdate" jdbcType="TIMESTAMP" property="birthdate" />
<result column="education" jdbcType="VARCHAR" property="education" />
<result column="sex" jdbcType="INTEGER" property="sex" />
<result column="email" jdbcType="VARCHAR" property="email" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="poins" jdbcType="INTEGER" property="poins" />
<result column="tag_id" jdbcType="BIGINT" property="tagId" />
<result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
</resultMap>
<sql id="allColumns">
`id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,`c_user_id`,`create_date`,`update_date`
</sql>

<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
<if test=" null != phone ">
and `phone` like concat('%', #{phone},'%')
</if>
<if test=" null != birthdate ">
and `birthdate` = #{birthdate}
</if>
<if test=" null != education ">
and `education` like concat('%', #{education},'%')
</if>
<if test=" null != sex ">
and `sex` = #{sex}
</if>
<if test=" null != email ">
and `email` like concat('%', #{email},'%')
</if>
<if test=" null != address ">
and `address` like concat('%', #{address},'%')
</if>
<if test=" null != poins ">
and `poins` = #{poins}
</if>
<if test=" null != tagId ">
and `tag_id` = #{tagId}
</if>
<if test=" null != cUserId ">
and `c_user_id` = #{cUserId}
</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.WxCUserBasicInfo" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_c_user_basic_info
<include refid="dynamicWhereConditions" />
</select>
</mapper>

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