From 100f8cb4696e6e2d5b777df215c587133a026c7a Mon Sep 17 00:00:00 2001 From: "jinguo24@163.com" Date: Sun, 12 Aug 2018 12:46:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=9A=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 10 +- .../WxCUserBasicInfoController.java | 77 +++++++ .../simple/domain/po/WxCUserBasicInfo.java | 211 ++++++++++++++++++ .../simple/mapper/WxCUserBasicInfoMapper.java | 17 ++ .../service/WxCUserBasicInfoService.java | 48 ++++ .../impl/WxCUserBasicInfoServiceImpl.java | 54 +++++ .../mapper/WxCUserBasicInfoMapper.xml | 104 +++++++++ 7 files changed, 517 insertions(+), 4 deletions(-) create mode 100644 mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java create mode 100644 mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java create mode 100644 mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java create mode 100644 mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java create mode 100644 mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java create mode 100644 mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml diff --git a/.gitignore b/.gitignore index 9b9617186..246771ee6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -.idea/** -*/target/** -logs/** -uploads/** \ No newline at end of file +.idea/** +*/target/** +logs/** +uploads/** +/.project +/.gitignore diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java new file mode 100644 index 000000000..46602754c --- /dev/null +++ b/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 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)); + } + + + +} diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java b/mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java new file mode 100644 index 000000000..95df69cda --- /dev/null +++ b/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 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="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 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/WxCUserBasicInfoMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java new file mode 100644 index 000000000..52df60d41 --- /dev/null +++ b/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 { + + List findList(WxCUserBasicInfo wxCUserBasicInfo); + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java new file mode 100644 index 000000000..63e1d79aa --- /dev/null +++ b/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 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); + + + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java new file mode 100644 index 000000000..66f172cd9 --- /dev/null +++ b/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 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); + } + + + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml new file mode 100644 index 000000000..f52d61459 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,`c_user_id`,`create_date`,`update_date` + + + + where 1 = 1 + + + and `id` = #{id} + + + + + and `phone` like concat('%', #{phone},'%') + + + + + and `birthdate` = #{birthdate} + + + + + and `education` like concat('%', #{education},'%') + + + + + and `sex` = #{sex} + + + + + and `email` like concat('%', #{email},'%') + + + + + and `address` like concat('%', #{address},'%') + + + + + and `poins` = #{poins} + + + + + and `tag_id` = #{tagId} + + + + + and `c_user_id` = #{cUserId} + + + + + and `create_date` = #{createDate} + + + + + and `update_date` = #{updateDate} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + +