添加微信用户注册和小程序登入的接口

This commit is contained in:
keivn
2021-12-25 14:09:51 +08:00
parent f04023a492
commit 506ca3760b
10 changed files with 1296 additions and 2 deletions

View File

@ -0,0 +1,104 @@
package com.ruoyi.carpool.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.carpool.domain.PMember;
import com.ruoyi.carpool.service.IPMemberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 微信注册用户信息Controller
*
* @author ruoyi
* @date 2021-12-25
*/
@RestController
@RequestMapping("/carpool/member")
public class PMemberController extends BaseController
{
@Autowired
private IPMemberService pMemberService;
/**
* 查询微信注册用户信息列表
*/
@PreAuthorize("@ss.hasPermi('carpool:member:list')")
@GetMapping("/list")
public TableDataInfo list(PMember pMember)
{
startPage();
List<PMember> list = pMemberService.selectPMemberList(pMember);
return getDataTable(list);
}
/**
* 导出微信注册用户信息列表
*/
@PreAuthorize("@ss.hasPermi('carpool:member:export')")
@Log(title = "微信注册用户信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, PMember pMember)
{
List<PMember> list = pMemberService.selectPMemberList(pMember);
ExcelUtil<PMember> util = new ExcelUtil<PMember>(PMember.class);
util.exportExcel(response, list, "微信注册用户信息数据");
}
/**
* 获取微信注册用户信息详细信息
*/
@PreAuthorize("@ss.hasPermi('carpool:member:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return AjaxResult.success(pMemberService.selectPMemberById(id));
}
/**
* 新增微信注册用户信息
*/
@PreAuthorize("@ss.hasPermi('carpool:member:add')")
@Log(title = "微信注册用户信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PMember pMember)
{
return toAjax(pMemberService.insertPMember(pMember));
}
/**
* 修改微信注册用户信息
*/
@PreAuthorize("@ss.hasPermi('carpool:member:edit')")
@Log(title = "微信注册用户信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PMember pMember)
{
return toAjax(pMemberService.updatePMember(pMember));
}
/**
* 删除微信注册用户信息
*/
@PreAuthorize("@ss.hasPermi('carpool:member:remove')")
@Log(title = "微信注册用户信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(pMemberService.deletePMemberByIds(ids));
}
}

View File

@ -0,0 +1,269 @@
package com.ruoyi.carpool.domain;
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.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 微信注册用户信息对象 p_member
*
* @author ruoyi
* @date 2021-12-25
*/
public class PMember extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 自增id */
private Integer id;
/** 平台编号 */
@Excel(name = "平台编号")
private String custId;
/** 用户类型 */
@Excel(name = "用户类型")
private String custType;
/** 微信唯一标识 */
@Excel(name = "微信唯一标识")
private String openId;
/** 微信unionId */
@Excel(name = "微信unionId")
private Long unionId;
/** 姓名 */
@Excel(name = "姓名")
private String custName;
/** 微信昵称 */
@Excel(name = "微信昵称")
private String nickName;
/** 手机号1 */
@Excel(name = "手机号1")
private String custPhoneA;
/** 手机号2 */
@Excel(name = "手机号2")
private String custPhoneB;
/** 性别 */
@Excel(name = "性别")
private String sex;
/** 生日 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
/** 所在城市 */
@Excel(name = "所在城市")
private String city;
/** 所在省份 */
@Excel(name = "所在省份")
private String province;
/** 所在国家 */
@Excel(name = "所在国家")
private String country;
/** 用户头像 */
@Excel(name = "用户头像")
private String headimgurl;
/** 证件类型 */
@Excel(name = "证件类型")
private String idType;
/** 证件号 */
@Excel(name = "证件号")
private String idNo;
public void setId(Integer id)
{
this.id = id;
}
public Integer getId()
{
return id;
}
public void setCustId(String custId)
{
this.custId = custId;
}
public String getCustId()
{
return custId;
}
public void setCustType(String custType)
{
this.custType = custType;
}
public String getCustType()
{
return custType;
}
public void setOpenId(String openId)
{
this.openId = openId;
}
public String getOpenId()
{
return openId;
}
public void setUnionId(Long unionId)
{
this.unionId = unionId;
}
public Long getUnionId()
{
return unionId;
}
public void setCustName(String custName)
{
this.custName = custName;
}
public String getCustName()
{
return custName;
}
public void setNickName(String nickName)
{
this.nickName = nickName;
}
public String getNickName()
{
return nickName;
}
public void setCustPhoneA(String custPhoneA)
{
this.custPhoneA = custPhoneA;
}
public String getCustPhoneA()
{
return custPhoneA;
}
public void setCustPhoneB(String custPhoneB)
{
this.custPhoneB = custPhoneB;
}
public String getCustPhoneB()
{
return custPhoneB;
}
public void setSex(String sex)
{
this.sex = sex;
}
public String getSex()
{
return sex;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public Date getBirthday()
{
return birthday;
}
public void setCity(String city)
{
this.city = city;
}
public String getCity()
{
return city;
}
public void setProvince(String province)
{
this.province = province;
}
public String getProvince()
{
return province;
}
public void setCountry(String country)
{
this.country = country;
}
public String getCountry()
{
return country;
}
public void setHeadimgurl(String headimgurl)
{
this.headimgurl = headimgurl;
}
public String getHeadimgurl()
{
return headimgurl;
}
public void setIdType(String idType)
{
this.idType = idType;
}
public String getIdType()
{
return idType;
}
public void setIdNo(String idNo)
{
this.idNo = idNo;
}
public String getIdNo()
{
return idNo;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("custId", getCustId())
.append("custType", getCustType())
.append("openId", getOpenId())
.append("unionId", getUnionId())
.append("custName", getCustName())
.append("nickName", getNickName())
.append("custPhoneA", getCustPhoneA())
.append("custPhoneB", getCustPhoneB())
.append("sex", getSex())
.append("birthday", getBirthday())
.append("city", getCity())
.append("province", getProvince())
.append("country", getCountry())
.append("headimgurl", getHeadimgurl())
.append("idType", getIdType())
.append("idNo", getIdNo())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.carpool.mapper;
import java.util.List;
import com.ruoyi.carpool.domain.PMember;
/**
* 微信注册用户信息Mapper接口
*
* @author ruoyi
* @date 2021-12-25
*/
public interface PMemberMapper
{
/**
* 查询微信注册用户信息
*
* @param id 微信注册用户信息主键
* @return 微信注册用户信息
*/
public PMember selectPMemberById(Integer id);
/**
* 查询微信注册用户信息列表
*
* @param pMember 微信注册用户信息
* @return 微信注册用户信息集合
*/
public List<PMember> selectPMemberList(PMember pMember);
/**
* 新增微信注册用户信息
*
* @param pMember 微信注册用户信息
* @return 结果
*/
public int insertPMember(PMember pMember);
/**
* 修改微信注册用户信息
*
* @param pMember 微信注册用户信息
* @return 结果
*/
public int updatePMember(PMember pMember);
/**
* 删除微信注册用户信息
*
* @param id 微信注册用户信息主键
* @return 结果
*/
public int deletePMemberById(Integer id);
/**
* 批量删除微信注册用户信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePMemberByIds(Integer[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.carpool.service;
import java.util.List;
import com.ruoyi.carpool.domain.PMember;
/**
* 微信注册用户信息Service接口
*
* @author ruoyi
* @date 2021-12-25
*/
public interface IPMemberService
{
/**
* 查询微信注册用户信息
*
* @param id 微信注册用户信息主键
* @return 微信注册用户信息
*/
public PMember selectPMemberById(Integer id);
/**
* 查询微信注册用户信息列表
*
* @param pMember 微信注册用户信息
* @return 微信注册用户信息集合
*/
public List<PMember> selectPMemberList(PMember pMember);
/**
* 新增微信注册用户信息
*
* @param pMember 微信注册用户信息
* @return 结果
*/
public int insertPMember(PMember pMember);
/**
* 修改微信注册用户信息
*
* @param pMember 微信注册用户信息
* @return 结果
*/
public int updatePMember(PMember pMember);
/**
* 批量删除微信注册用户信息
*
* @param ids 需要删除的微信注册用户信息主键集合
* @return 结果
*/
public int deletePMemberByIds(Integer[] ids);
/**
* 删除微信注册用户信息信息
*
* @param id 微信注册用户信息主键
* @return 结果
*/
public int deletePMemberById(Integer id);
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.carpool.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.carpool.mapper.PMemberMapper;
import com.ruoyi.carpool.domain.PMember;
import com.ruoyi.carpool.service.IPMemberService;
/**
* 微信注册用户信息Service业务层处理
*
* @author ruoyi
* @date 2021-12-25
*/
@Service
public class PMemberServiceImpl implements IPMemberService
{
@Autowired
private PMemberMapper pMemberMapper;
/**
* 查询微信注册用户信息
*
* @param id 微信注册用户信息主键
* @return 微信注册用户信息
*/
@Override
public PMember selectPMemberById(Integer id)
{
return pMemberMapper.selectPMemberById(id);
}
/**
* 查询微信注册用户信息列表
*
* @param pMember 微信注册用户信息
* @return 微信注册用户信息
*/
@Override
public List<PMember> selectPMemberList(PMember pMember)
{
return pMemberMapper.selectPMemberList(pMember);
}
/**
* 新增微信注册用户信息
*
* @param pMember 微信注册用户信息
* @return 结果
*/
@Override
public int insertPMember(PMember pMember)
{
pMember.setCreateTime(DateUtils.getNowDate());
return pMemberMapper.insertPMember(pMember);
}
/**
* 修改微信注册用户信息
*
* @param pMember 微信注册用户信息
* @return 结果
*/
@Override
public int updatePMember(PMember pMember)
{
pMember.setUpdateTime(DateUtils.getNowDate());
return pMemberMapper.updatePMember(pMember);
}
/**
* 批量删除微信注册用户信息
*
* @param ids 需要删除的微信注册用户信息主键
* @return 结果
*/
@Override
public int deletePMemberByIds(Integer[] ids)
{
return pMemberMapper.deletePMemberByIds(ids);
}
/**
* 删除微信注册用户信息信息
*
* @param id 微信注册用户信息主键
* @return 结果
*/
@Override
public int deletePMemberById(Integer id)
{
return pMemberMapper.deletePMemberById(id);
}
}

View File

@ -0,0 +1,151 @@
<?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.carpool.mapper.PMemberMapper">
<resultMap type="PMember" id="PMemberResult">
<result property="id" column="id" />
<result property="custId" column="cust_id" />
<result property="custType" column="cust_type" />
<result property="openId" column="open_id" />
<result property="unionId" column="union_id" />
<result property="custName" column="cust_name" />
<result property="nickName" column="nick_name" />
<result property="custPhoneA" column="cust_phone_a" />
<result property="custPhoneB" column="cust_phone_b" />
<result property="sex" column="sex" />
<result property="birthday" column="birthday" />
<result property="city" column="city" />
<result property="province" column="province" />
<result property="country" column="country" />
<result property="headimgurl" column="headimgurl" />
<result property="idType" column="id_type" />
<result property="idNo" column="id_no" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPMemberVo">
select id, cust_id, cust_type, open_id, union_id, cust_name, nick_name, cust_phone_a, cust_phone_b, sex, birthday, city, province, country, headimgurl, id_type, id_no, remark, create_by, create_time, update_by, update_time from p_member
</sql>
<select id="selectPMemberList" parameterType="PMember" resultMap="PMemberResult">
<include refid="selectPMemberVo"/>
<where>
<if test="custId != null and custId != ''"> and cust_id = #{custId}</if>
<if test="custType != null and custType != ''"> and cust_type = #{custType}</if>
<if test="openId != null and openId != ''"> and open_id = #{openId}</if>
<if test="unionId != null "> and union_id = #{unionId}</if>
<if test="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="custPhoneA != null and custPhoneA != ''"> and cust_phone_a = #{custPhoneA}</if>
<if test="custPhoneB != null and custPhoneB != ''"> and cust_phone_b = #{custPhoneB}</if>
<if test="sex != null and sex != ''"> and sex = #{sex}</if>
<if test="birthday != null "> and birthday = #{birthday}</if>
<if test="city != null and city != ''"> and city = #{city}</if>
<if test="province != null and province != ''"> and province = #{province}</if>
<if test="country != null and country != ''"> and country = #{country}</if>
<if test="headimgurl != null and headimgurl != ''"> and headimgurl = #{headimgurl}</if>
<if test="idType != null and idType != ''"> and id_type = #{idType}</if>
<if test="idNo != null and idNo != ''"> and id_no = #{idNo}</if>
</where>
</select>
<select id="selectPMemberById" parameterType="Integer" resultMap="PMemberResult">
<include refid="selectPMemberVo"/>
where id = #{id}
</select>
<insert id="insertPMember" parameterType="PMember" useGeneratedKeys="true" keyProperty="id">
insert into p_member
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="custId != null">cust_id,</if>
<if test="custType != null">cust_type,</if>
<if test="openId != null">open_id,</if>
<if test="unionId != null">union_id,</if>
<if test="custName != null">cust_name,</if>
<if test="nickName != null">nick_name,</if>
<if test="custPhoneA != null">cust_phone_a,</if>
<if test="custPhoneB != null">cust_phone_b,</if>
<if test="sex != null">sex,</if>
<if test="birthday != null">birthday,</if>
<if test="city != null">city,</if>
<if test="province != null">province,</if>
<if test="country != null">country,</if>
<if test="headimgurl != null">headimgurl,</if>
<if test="idType != null">id_type,</if>
<if test="idNo != null">id_no,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="custId != null">#{custId},</if>
<if test="custType != null">#{custType},</if>
<if test="openId != null">#{openId},</if>
<if test="unionId != null">#{unionId},</if>
<if test="custName != null">#{custName},</if>
<if test="nickName != null">#{nickName},</if>
<if test="custPhoneA != null">#{custPhoneA},</if>
<if test="custPhoneB != null">#{custPhoneB},</if>
<if test="sex != null">#{sex},</if>
<if test="birthday != null">#{birthday},</if>
<if test="city != null">#{city},</if>
<if test="province != null">#{province},</if>
<if test="country != null">#{country},</if>
<if test="headimgurl != null">#{headimgurl},</if>
<if test="idType != null">#{idType},</if>
<if test="idNo != null">#{idNo},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updatePMember" parameterType="PMember">
update p_member
<trim prefix="SET" suffixOverrides=",">
<if test="custId != null">cust_id = #{custId},</if>
<if test="custType != null">cust_type = #{custType},</if>
<if test="openId != null">open_id = #{openId},</if>
<if test="unionId != null">union_id = #{unionId},</if>
<if test="custName != null">cust_name = #{custName},</if>
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="custPhoneA != null">cust_phone_a = #{custPhoneA},</if>
<if test="custPhoneB != null">cust_phone_b = #{custPhoneB},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="birthday != null">birthday = #{birthday},</if>
<if test="city != null">city = #{city},</if>
<if test="province != null">province = #{province},</if>
<if test="country != null">country = #{country},</if>
<if test="headimgurl != null">headimgurl = #{headimgurl},</if>
<if test="idType != null">id_type = #{idType},</if>
<if test="idNo != null">id_no = #{idNo},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deletePMemberById" parameterType="Integer">
delete from p_member where id = #{id}
</delete>
<delete id="deletePMemberByIds" parameterType="String">
delete from p_member where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>