新增查询微信用户代码

This commit is contained in:
wuyibo
2022-08-30 15:53:31 +08:00
parent afa23c2111
commit d7ce9bbbb8
13 changed files with 1278 additions and 9 deletions

View File

@@ -14,12 +14,14 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 192.168.1.211:30006
namespace: dev
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 192.168.1.211:30006
# 配置文件格式
file-extension: yml
namespace: dev
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@@ -0,0 +1,105 @@
package com.ruoyi.system.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.WxUser;
import com.ruoyi.system.service.IWxUserService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* 微信用户Controller
*
* @author 吴一博
* @date 2022-08-30
*/
@RestController
@RequestMapping("/wxUser")
public class WxUserController extends BaseController
{
@Autowired
private IWxUserService wxUserService;
/**
* 查询微信用户列表
*/
@RequiresPermissions("system:wxUser:list")
@GetMapping("/list")
public TableDataInfo list(WxUser wxUser)
{
startPage();
List<WxUser> list = wxUserService.selectWxUserList(wxUser);
return getDataTable(list);
}
/**
* 导出微信用户列表
*/
@RequiresPermissions("system:wxUser:export")
@Log(title = "微信用户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, WxUser wxUser)
{
List<WxUser> list = wxUserService.selectWxUserList(wxUser);
ExcelUtil<WxUser> util = new ExcelUtil<WxUser>(WxUser.class);
util.exportExcel(response, list, "微信用户数据");
}
/**
* 获取微信用户详细信息
*/
@RequiresPermissions("system:wxUser:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(wxUserService.selectWxUserById(id));
}
/**
* 新增微信用户
*/
@RequiresPermissions("system:wxUser:add")
@Log(title = "微信用户", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WxUser wxUser)
{
return toAjax(wxUserService.insertWxUser(wxUser));
}
/**
* 修改微信用户
*/
@RequiresPermissions("system:wxUser:edit")
@Log(title = "微信用户", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WxUser wxUser)
{
return toAjax(wxUserService.updateWxUser(wxUser));
}
/**
* 删除微信用户
*/
@RequiresPermissions("system:wxUser:remove")
@Log(title = "微信用户", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(wxUserService.deleteWxUserByIds(ids));
}
}

View File

@@ -0,0 +1,351 @@
package com.ruoyi.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* 微信用户对象 user_info
*
* @author 吴一博
* @date 2022-08-30
*/
public class WxUser extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 删除 */
@Excel(name = "删除")
private Long isDeleted;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
/** 最后修改人 */
@Excel(name = "最后修改人")
private String modifiedBy;
/** 最后修改时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后修改时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastUpdatedTime;
/** 登录名称 */
@Excel(name = "登录名称")
private String loginName;
/** 密码 */
@Excel(name = "密码")
private String passWord;
/** 角色 */
@Excel(name = "角色")
private String role;
/** 用户编码(小程序平台OPENID) */
@Excel(name = "用户编码(小程序平台OPENID)")
private String openid;
/** 头像地址 */
@Excel(name = "头像地址")
private String avatar;
/** 性别 */
@Excel(name = "性别")
private String gender;
/** 用户名称 */
@Excel(name = "用户名称")
private String userName;
/** 手机号 */
@Excel(name = "手机号")
private String telephone;
/** 生日 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
/** 身高 */
@Excel(name = "身高")
private Long height;
/** 体重 */
@Excel(name = "体重")
private BigDecimal weight;
/** 球队位置 */
@Excel(name = "球队位置")
private String teamPosition;
/** 标签 */
@Excel(name = "标签")
private String tag;
/** 状态 */
@Excel(name = "状态")
private String enabled;
/** 微信多平台唯一ID */
@Excel(name = "微信多平台唯一ID")
private String unionid;
/** 公众号平台的openId */
@Excel(name = "公众号平台的openId")
private String officialAccountOpenid;
/** 真实姓名 */
@Excel(name = "真实姓名")
private String realName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setIsDeleted(Long isDeleted)
{
this.isDeleted = isDeleted;
}
public Long getIsDeleted()
{
return isDeleted;
}
public void setCreatedTime(Date createdTime)
{
this.createdTime = createdTime;
}
public Date getCreatedTime()
{
return createdTime;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public String getCreatedBy()
{
return createdBy;
}
public void setModifiedBy(String modifiedBy)
{
this.modifiedBy = modifiedBy;
}
public String getModifiedBy()
{
return modifiedBy;
}
public void setLastUpdatedTime(Date lastUpdatedTime)
{
this.lastUpdatedTime = lastUpdatedTime;
}
public Date getLastUpdatedTime()
{
return lastUpdatedTime;
}
public void setLoginName(String loginName)
{
this.loginName = loginName;
}
public String getLoginName()
{
return loginName;
}
public void setPassWord(String passWord)
{
this.passWord = passWord;
}
public String getPassWord()
{
return passWord;
}
public void setRole(String role)
{
this.role = role;
}
public String getRole()
{
return role;
}
public void setOpenid(String openid)
{
this.openid = openid;
}
public String getOpenid()
{
return openid;
}
public void setAvatar(String avatar)
{
this.avatar = avatar;
}
public String getAvatar()
{
return avatar;
}
public void setGender(String gender)
{
this.gender = gender;
}
public String getGender()
{
return gender;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
public void setTelephone(String telephone)
{
this.telephone = telephone;
}
public String getTelephone()
{
return telephone;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public Date getBirthday()
{
return birthday;
}
public void setHeight(Long height)
{
this.height = height;
}
public Long getHeight()
{
return height;
}
public void setWeight(BigDecimal weight)
{
this.weight = weight;
}
public BigDecimal getWeight()
{
return weight;
}
public void setTeamPosition(String teamPosition)
{
this.teamPosition = teamPosition;
}
public String getTeamPosition()
{
return teamPosition;
}
public void setTag(String tag)
{
this.tag = tag;
}
public String getTag()
{
return tag;
}
public void setEnabled(String enabled)
{
this.enabled = enabled;
}
public String getEnabled()
{
return enabled;
}
public void setUnionid(String unionid)
{
this.unionid = unionid;
}
public String getUnionid()
{
return unionid;
}
public void setOfficialAccountOpenid(String officialAccountOpenid)
{
this.officialAccountOpenid = officialAccountOpenid;
}
public String getOfficialAccountOpenid()
{
return officialAccountOpenid;
}
public void setRealName(String realName)
{
this.realName = realName;
}
public String getRealName()
{
return realName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("isDeleted", getIsDeleted())
.append("createdTime", getCreatedTime())
.append("createdBy", getCreatedBy())
.append("modifiedBy", getModifiedBy())
.append("lastUpdatedTime", getLastUpdatedTime())
.append("loginName", getLoginName())
.append("passWord", getPassWord())
.append("role", getRole())
.append("openid", getOpenid())
.append("avatar", getAvatar())
.append("gender", getGender())
.append("userName", getUserName())
.append("telephone", getTelephone())
.append("birthday", getBirthday())
.append("height", getHeight())
.append("weight", getWeight())
.append("teamPosition", getTeamPosition())
.append("tag", getTag())
.append("enabled", getEnabled())
.append("unionid", getUnionid())
.append("officialAccountOpenid", getOfficialAccountOpenid())
.append("realName", getRealName())
.toString();
}
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.WxUser;
/**
* 微信用户Mapper接口
*
* @author 吴一博
* @date 2022-08-30
*/
public interface WxUserMapper
{
/**
* 查询微信用户
*
* @param id 微信用户主键
* @return 微信用户
*/
public WxUser selectWxUserById(Long id);
/**
* 查询微信用户列表
*
* @param wxUser 微信用户
* @return 微信用户集合
*/
public List<WxUser> selectWxUserList(WxUser wxUser);
/**
* 新增微信用户
*
* @param wxUser 微信用户
* @return 结果
*/
public int insertWxUser(WxUser wxUser);
/**
* 修改微信用户
*
* @param wxUser 微信用户
* @return 结果
*/
public int updateWxUser(WxUser wxUser);
/**
* 删除微信用户
*
* @param id 微信用户主键
* @return 结果
*/
public int deleteWxUserById(Long id);
/**
* 批量删除微信用户
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteWxUserByIds(Long[] ids);
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.WxUser;
/**
* 微信用户Service接口
*
* @author 吴一博
* @date 2022-08-30
*/
public interface IWxUserService
{
/**
* 查询微信用户
*
* @param id 微信用户主键
* @return 微信用户
*/
public WxUser selectWxUserById(Long id);
/**
* 查询微信用户列表
*
* @param wxUser 微信用户
* @return 微信用户集合
*/
public List<WxUser> selectWxUserList(WxUser wxUser);
/**
* 新增微信用户
*
* @param wxUser 微信用户
* @return 结果
*/
public int insertWxUser(WxUser wxUser);
/**
* 修改微信用户
*
* @param wxUser 微信用户
* @return 结果
*/
public int updateWxUser(WxUser wxUser);
/**
* 批量删除微信用户
*
* @param ids 需要删除的微信用户主键集合
* @return 结果
*/
public int deleteWxUserByIds(Long[] ids);
/**
* 删除微信用户信息
*
* @param id 微信用户主键
* @return 结果
*/
public int deleteWxUserById(Long id);
}

View File

@@ -0,0 +1,93 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WxUserMapper;
import com.ruoyi.system.domain.WxUser;
import com.ruoyi.system.service.IWxUserService;
/**
* 微信用户Service业务层处理
*
* @author 吴一博
* @date 2022-08-30
*/
@Service
public class WxUserServiceImpl implements IWxUserService
{
@Autowired
private WxUserMapper wxUserMapper;
/**
* 查询微信用户
*
* @param id 微信用户主键
* @return 微信用户
*/
@Override
public WxUser selectWxUserById(Long id)
{
return wxUserMapper.selectWxUserById(id);
}
/**
* 查询微信用户列表
*
* @param wxUser 微信用户
* @return 微信用户
*/
@Override
public List<WxUser> selectWxUserList(WxUser wxUser)
{
return wxUserMapper.selectWxUserList(wxUser);
}
/**
* 新增微信用户
*
* @param wxUser 微信用户
* @return 结果
*/
@Override
public int insertWxUser(WxUser wxUser)
{
return wxUserMapper.insertWxUser(wxUser);
}
/**
* 修改微信用户
*
* @param wxUser 微信用户
* @return 结果
*/
@Override
public int updateWxUser(WxUser wxUser)
{
return wxUserMapper.updateWxUser(wxUser);
}
/**
* 批量删除微信用户
*
* @param ids 需要删除的微信用户主键
* @return 结果
*/
@Override
public int deleteWxUserByIds(Long[] ids)
{
return wxUserMapper.deleteWxUserByIds(ids);
}
/**
* 删除微信用户信息
*
* @param id 微信用户主键
* @return 结果
*/
@Override
public int deleteWxUserById(Long id)
{
return wxUserMapper.deleteWxUserById(id);
}
}

View File

@@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 192.168.1.211:30006
namespace: dev
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 192.168.1.211:30006
namespace: dev
# 配置文件格式
file-extension: yml
# 共享配置

View File

@@ -0,0 +1,161 @@
<?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.ruoyi.system.mapper.WxUserMapper">
<resultMap type="WxUser" id="WxUserResult">
<result property="id" column="ID" />
<result property="isDeleted" column="IS_DELETED" />
<result property="createdTime" column="CREATED_TIME" />
<result property="createdBy" column="CREATED_BY" />
<result property="modifiedBy" column="MODIFIED_BY" />
<result property="lastUpdatedTime" column="LAST_UPDATED_TIME" />
<result property="loginName" column="LOGIN_NAME" />
<result property="passWord" column="PASS_WORD" />
<result property="role" column="ROLE" />
<result property="openid" column="OPENID" />
<result property="avatar" column="AVATAR" />
<result property="gender" column="GENDER" />
<result property="userName" column="USER_NAME" />
<result property="telephone" column="TELEPHONE" />
<result property="birthday" column="BIRTHDAY" />
<result property="height" column="HEIGHT" />
<result property="weight" column="WEIGHT" />
<result property="teamPosition" column="TEAM_POSITION" />
<result property="tag" column="TAG" />
<result property="enabled" column="ENABLED" />
<result property="unionid" column="UNIONID" />
<result property="officialAccountOpenid" column="OFFICIAL_ACCOUNT_OPENID" />
<result property="realName" column="real_name" />
</resultMap>
<sql id="selectWxUserVo">
select ID, IS_DELETED, CREATED_TIME, CREATED_BY, MODIFIED_BY, LAST_UPDATED_TIME, LOGIN_NAME, PASS_WORD, ROLE, OPENID, AVATAR, GENDER, USER_NAME, TELEPHONE, BIRTHDAY, HEIGHT, WEIGHT, TEAM_POSITION, TAG, ENABLED, UNIONID, OFFICIAL_ACCOUNT_OPENID, real_name from user_info
</sql>
<select id="selectWxUserList" parameterType="WxUser" resultMap="WxUserResult">
<include refid="selectWxUserVo"/>
<where>
<if test="isDeleted != null "> and IS_DELETED = #{isDeleted}</if>
<if test="createdTime != null "> and CREATED_TIME = #{createdTime}</if>
<if test="createdBy != null and createdBy != ''"> and CREATED_BY = #{createdBy}</if>
<if test="modifiedBy != null and modifiedBy != ''"> and MODIFIED_BY = #{modifiedBy}</if>
<if test="lastUpdatedTime != null "> and LAST_UPDATED_TIME = #{lastUpdatedTime}</if>
<if test="loginName != null and loginName != ''"> and LOGIN_NAME like concat('%', #{loginName}, '%')</if>
<if test="passWord != null and passWord != ''"> and PASS_WORD = #{passWord}</if>
<if test="role != null and role != ''"> and ROLE = #{role}</if>
<if test="openid != null and openid != ''"> and OPENID = #{openid}</if>
<if test="avatar != null and avatar != ''"> and AVATAR = #{avatar}</if>
<if test="gender != null and gender != ''"> and GENDER = #{gender}</if>
<if test="userName != null and userName != ''"> and USER_NAME like concat('%', #{userName}, '%')</if>
<if test="telephone != null and telephone != ''"> and TELEPHONE = #{telephone}</if>
<if test="birthday != null "> and BIRTHDAY = #{birthday}</if>
<if test="height != null "> and HEIGHT = #{height}</if>
<if test="weight != null "> and WEIGHT = #{weight}</if>
<if test="teamPosition != null and teamPosition != ''"> and TEAM_POSITION = #{teamPosition}</if>
<if test="tag != null and tag != ''"> and TAG = #{tag}</if>
<if test="enabled != null and enabled != ''"> and ENABLED = #{enabled}</if>
<if test="unionid != null and unionid != ''"> and UNIONID = #{unionid}</if>
<if test="officialAccountOpenid != null and officialAccountOpenid != ''"> and OFFICIAL_ACCOUNT_OPENID = #{officialAccountOpenid}</if>
<if test="realName != null and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
</where>
</select>
<select id="selectWxUserById" parameterType="Long" resultMap="WxUserResult">
<include refid="selectWxUserVo"/>
where ID = #{id}
</select>
<insert id="insertWxUser" parameterType="WxUser" useGeneratedKeys="true" keyProperty="id">
insert into user_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="isDeleted != null">IS_DELETED,</if>
<if test="createdTime != null">CREATED_TIME,</if>
<if test="createdBy != null">CREATED_BY,</if>
<if test="modifiedBy != null">MODIFIED_BY,</if>
<if test="lastUpdatedTime != null">LAST_UPDATED_TIME,</if>
<if test="loginName != null">LOGIN_NAME,</if>
<if test="passWord != null">PASS_WORD,</if>
<if test="role != null">ROLE,</if>
<if test="openid != null">OPENID,</if>
<if test="avatar != null">AVATAR,</if>
<if test="gender != null">GENDER,</if>
<if test="userName != null">USER_NAME,</if>
<if test="telephone != null">TELEPHONE,</if>
<if test="birthday != null">BIRTHDAY,</if>
<if test="height != null">HEIGHT,</if>
<if test="weight != null">WEIGHT,</if>
<if test="teamPosition != null">TEAM_POSITION,</if>
<if test="tag != null">TAG,</if>
<if test="enabled != null">ENABLED,</if>
<if test="unionid != null">UNIONID,</if>
<if test="officialAccountOpenid != null">OFFICIAL_ACCOUNT_OPENID,</if>
<if test="realName != null">real_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="isDeleted != null">#{isDeleted},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="modifiedBy != null">#{modifiedBy},</if>
<if test="lastUpdatedTime != null">#{lastUpdatedTime},</if>
<if test="loginName != null">#{loginName},</if>
<if test="passWord != null">#{passWord},</if>
<if test="role != null">#{role},</if>
<if test="openid != null">#{openid},</if>
<if test="avatar != null">#{avatar},</if>
<if test="gender != null">#{gender},</if>
<if test="userName != null">#{userName},</if>
<if test="telephone != null">#{telephone},</if>
<if test="birthday != null">#{birthday},</if>
<if test="height != null">#{height},</if>
<if test="weight != null">#{weight},</if>
<if test="teamPosition != null">#{teamPosition},</if>
<if test="tag != null">#{tag},</if>
<if test="enabled != null">#{enabled},</if>
<if test="unionid != null">#{unionid},</if>
<if test="officialAccountOpenid != null">#{officialAccountOpenid},</if>
<if test="realName != null">#{realName},</if>
</trim>
</insert>
<update id="updateWxUser" parameterType="WxUser">
update user_info
<trim prefix="SET" suffixOverrides=",">
<if test="isDeleted != null">IS_DELETED = #{isDeleted},</if>
<if test="createdTime != null">CREATED_TIME = #{createdTime},</if>
<if test="createdBy != null">CREATED_BY = #{createdBy},</if>
<if test="modifiedBy != null">MODIFIED_BY = #{modifiedBy},</if>
<if test="lastUpdatedTime != null">LAST_UPDATED_TIME = #{lastUpdatedTime},</if>
<if test="loginName != null">LOGIN_NAME = #{loginName},</if>
<if test="passWord != null">PASS_WORD = #{passWord},</if>
<if test="role != null">ROLE = #{role},</if>
<if test="openid != null">OPENID = #{openid},</if>
<if test="avatar != null">AVATAR = #{avatar},</if>
<if test="gender != null">GENDER = #{gender},</if>
<if test="userName != null">USER_NAME = #{userName},</if>
<if test="telephone != null">TELEPHONE = #{telephone},</if>
<if test="birthday != null">BIRTHDAY = #{birthday},</if>
<if test="height != null">HEIGHT = #{height},</if>
<if test="weight != null">WEIGHT = #{weight},</if>
<if test="teamPosition != null">TEAM_POSITION = #{teamPosition},</if>
<if test="tag != null">TAG = #{tag},</if>
<if test="enabled != null">ENABLED = #{enabled},</if>
<if test="unionid != null">UNIONID = #{unionid},</if>
<if test="officialAccountOpenid != null">OFFICIAL_ACCOUNT_OPENID = #{officialAccountOpenid},</if>
<if test="realName != null">real_name = #{realName},</if>
</trim>
where ID = #{id}
</update>
<delete id="deleteWxUserById" parameterType="Long">
delete from user_info where ID = #{id}
</delete>
<delete id="deleteWxUserByIds" parameterType="String">
delete from user_info where ID in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>