新增微信二维码代码

This commit is contained in:
wuyibo
2022-10-19 16:55:55 +08:00
parent d05e3ddf72
commit 2f53a85bf6
21 changed files with 1284 additions and 98 deletions

View File

@@ -77,7 +77,10 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -0,0 +1,107 @@
package com.ruoyi.system.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.UserWxAqrCode;
import com.ruoyi.system.service.IUserWxAqrCodeService;
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 ruoyi
* @date 2022-10-18
*/
@RestController
@RequestMapping("/code")
public class UserWxAqrCodeController extends BaseController
{
@Autowired
private IUserWxAqrCodeService userWxAqrCodeService;
/**
* 查询微信用户小程序二维码列表
*/
@RequiresPermissions("system:code:list")
@GetMapping("/list")
public TableDataInfo list(UserWxAqrCode userWxAqrCode)
{
startPage();
List<UserWxAqrCode> list = userWxAqrCodeService.selectUserWxAqrCodeList(userWxAqrCode);
return getDataTable(list);
}
/**
* 导出微信用户小程序二维码列表
*/
@RequiresPermissions("system:code:export")
@Log(title = "微信用户小程序二维码", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, UserWxAqrCode userWxAqrCode)
{
List<UserWxAqrCode> list = userWxAqrCodeService.selectUserWxAqrCodeList(userWxAqrCode);
ExcelUtil<UserWxAqrCode> util = new ExcelUtil<UserWxAqrCode>(UserWxAqrCode.class);
util.exportExcel(response, list, "微信用户小程序二维码数据");
}
/**
* 获取微信用户小程序二维码详细信息
*/
@RequiresPermissions("system:code:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(userWxAqrCodeService.selectUserWxAqrCodeById(id));
}
/**
* 新增微信用户小程序二维码
*/
@RequiresPermissions("system:code:add")
@Log(title = "微信用户小程序二维码", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody UserWxAqrCode userWxAqrCode)
{
return toAjax(userWxAqrCodeService.insertUserWxAqrCode(userWxAqrCode));
}
/**
* 修改微信用户小程序二维码
*/
@RequiresPermissions("system:code:edit")
@Log(title = "微信用户小程序二维码", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody UserWxAqrCode userWxAqrCode)
{
return toAjax(userWxAqrCodeService.updateUserWxAqrCode(userWxAqrCode));
}
@RequiresPermissions("system:code:genAqrCode")
@Log(title = "微信用户小程序二维码", businessType = BusinessType.INSERT)
@PostMapping("/genAqrCode")
public AjaxResult genAqrCode(@RequestParam(required = false) Integer genNumbers, @RequestBody UserWxAqrCode userWxAqrCode)
{
return toAjax(userWxAqrCodeService.genAqrCode(genNumbers,userWxAqrCode));
}
/**
* 删除微信用户小程序二维码
*/
@RequiresPermissions("system:code:remove")
@Log(title = "微信用户小程序二维码", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(userWxAqrCodeService.deleteUserWxAqrCodeByIds(ids));
}
}

View File

@@ -0,0 +1,208 @@
package com.ruoyi.system.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.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* 微信用户小程序二维码对象 user_wx_aqr_code
*
* @author ruoyi
* @date 2022-10-19
*/
public class UserWxAqrCode 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 scene;
/** 微信二维码的base64编码 */
@Excel(name = "微信二维码的base64编码")
private String base64;
/** 二维码地址 */
@Excel(name = "二维码地址")
private String codeImgUrl;
/** 用户ID */
@Excel(name = "用户ID")
private Long userId;
/** 业务分类枚举 */
@Excel(name = "业务分类枚举")
private String busType;
/** 页面路径 */
@Excel(name = "页面路径")
private String page;
/** 宽度 */
@Excel(name = "宽度")
private Integer width;
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 setScene(String scene)
{
this.scene = scene;
}
public String getScene()
{
return scene;
}
public void setBase64(String base64)
{
this.base64 = base64;
}
public String getBase64()
{
return base64;
}
public void setCodeImgUrl(String codeImgUrl)
{
this.codeImgUrl = codeImgUrl;
}
public String getCodeImgUrl()
{
return codeImgUrl;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setBusType(String busType)
{
this.busType = busType;
}
public String getBusType()
{
return busType;
}
public void setPage(String page)
{
this.page = page;
}
public String getPage()
{
return page;
}
public void setWidth(Integer width)
{
this.width = width;
}
public Integer getWidth()
{
return width;
}
@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("scene", getScene())
.append("base64", getBase64())
.append("codeImgUrl", getCodeImgUrl())
.append("userId", getUserId())
.append("busType", getBusType())
.append("page", getPage())
.append("width", getWidth())
.toString();
}
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.UserWxAqrCode;
/**
* 微信用户小程序二维码Mapper接口
*
* @author ruoyi
* @date 2022-10-18
*/
public interface UserWxAqrCodeMapper
{
/**
* 查询微信用户小程序二维码
*
* @param id 微信用户小程序二维码主键
* @return 微信用户小程序二维码
*/
public UserWxAqrCode selectUserWxAqrCodeById(Long id);
/**
* 查询微信用户小程序二维码列表
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 微信用户小程序二维码集合
*/
public List<UserWxAqrCode> selectUserWxAqrCodeList(UserWxAqrCode userWxAqrCode);
/**
* 新增微信用户小程序二维码
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 结果
*/
public int insertUserWxAqrCode(UserWxAqrCode userWxAqrCode);
/**
* 修改微信用户小程序二维码
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 结果
*/
public int updateUserWxAqrCode(UserWxAqrCode userWxAqrCode);
/**
* 删除微信用户小程序二维码
*
* @param id 微信用户小程序二维码主键
* @return 结果
*/
public int deleteUserWxAqrCodeById(Long id);
/**
* 批量删除微信用户小程序二维码
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteUserWxAqrCodeByIds(Long[] ids);
}

View File

@@ -0,0 +1,63 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.UserWxAqrCode;
/**
* 微信用户小程序二维码Service接口
*
* @author ruoyi
* @date 2022-10-18
*/
public interface IUserWxAqrCodeService
{
/**
* 查询微信用户小程序二维码
*
* @param id 微信用户小程序二维码主键
* @return 微信用户小程序二维码
*/
public UserWxAqrCode selectUserWxAqrCodeById(Long id);
/**
* 查询微信用户小程序二维码列表
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 微信用户小程序二维码集合
*/
public List<UserWxAqrCode> selectUserWxAqrCodeList(UserWxAqrCode userWxAqrCode);
/**
* 新增微信用户小程序二维码
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 结果
*/
public int insertUserWxAqrCode(UserWxAqrCode userWxAqrCode);
/**
* 修改微信用户小程序二维码
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 结果
*/
public int updateUserWxAqrCode(UserWxAqrCode userWxAqrCode);
/**
* 批量删除微信用户小程序二维码
*
* @param ids 需要删除的微信用户小程序二维码主键集合
* @return 结果
*/
public int deleteUserWxAqrCodeByIds(Long[] ids);
/**
* 删除微信用户小程序二维码信息
*
* @param id 微信用户小程序二维码主键
* @return 结果
*/
public int deleteUserWxAqrCodeById(Long id);
Boolean genAqrCode(Integer genNumbers, UserWxAqrCode userWxAqrCode);
}

View File

@@ -0,0 +1,124 @@
package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.vo.WxAppletsCodeVo;
import com.ruoyi.system.api.feign.WxAppletsFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.UserWxAqrCodeMapper;
import com.ruoyi.system.domain.UserWxAqrCode;
import com.ruoyi.system.service.IUserWxAqrCodeService;
import javax.annotation.Resource;
/**
* 微信用户小程序二维码Service业务层处理
*
* @author ruoyi
* @date 2022-10-18
*/
@Service
public class UserWxAqrCodeServiceImpl implements IUserWxAqrCodeService
{
@Autowired
private UserWxAqrCodeMapper userWxAqrCodeMapper;
@Resource
private WxAppletsFeign wxAppletsFeign;
/**
* 查询微信用户小程序二维码
*
* @param id 微信用户小程序二维码主键
* @return 微信用户小程序二维码
*/
@Override
public UserWxAqrCode selectUserWxAqrCodeById(Long id)
{
return userWxAqrCodeMapper.selectUserWxAqrCodeById(id);
}
/**
* 查询微信用户小程序二维码列表
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 微信用户小程序二维码
*/
@Override
public List<UserWxAqrCode> selectUserWxAqrCodeList(UserWxAqrCode userWxAqrCode)
{
return userWxAqrCodeMapper.selectUserWxAqrCodeList(userWxAqrCode);
}
/**
* 新增微信用户小程序二维码
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 结果
*/
@Override
public int insertUserWxAqrCode(UserWxAqrCode userWxAqrCode)
{
return userWxAqrCodeMapper.insertUserWxAqrCode(userWxAqrCode);
}
/**
* 修改微信用户小程序二维码
*
* @param userWxAqrCode 微信用户小程序二维码
* @return 结果
*/
@Override
public int updateUserWxAqrCode(UserWxAqrCode userWxAqrCode)
{
return userWxAqrCodeMapper.updateUserWxAqrCode(userWxAqrCode);
}
/**
* 批量删除微信用户小程序二维码
*
* @param ids 需要删除的微信用户小程序二维码主键
* @return 结果
*/
@Override
public int deleteUserWxAqrCodeByIds(Long[] ids)
{
return userWxAqrCodeMapper.deleteUserWxAqrCodeByIds(ids);
}
/**
* 删除微信用户小程序二维码信息
*
* @param id 微信用户小程序二维码主键
* @return 结果
*/
@Override
public int deleteUserWxAqrCodeById(Long id)
{
return userWxAqrCodeMapper.deleteUserWxAqrCodeById(id);
}
@Override
public Boolean genAqrCode(Integer genNumbers, UserWxAqrCode userWxAqrCode) {
String accessToken = wxAppletsFeign.getAccessToken();
userWxAqrCode.setCreatedBy(SecurityUtils.getUsername());
userWxAqrCode.setCreatedTime(new Date());
int id = userWxAqrCodeMapper.insertUserWxAqrCode(userWxAqrCode);
System.out.println("id = "+userWxAqrCode.getId()+" accessToken = "+ accessToken);
WxAppletsCodeVo wxAppletsCodeVo = new WxAppletsCodeVo();
wxAppletsCodeVo.setScene(String.valueOf(userWxAqrCode.getId()));
wxAppletsCodeVo.setPage("pages/index2/index2");
wxAppletsCodeVo = wxAppletsFeign.getWxacodeunlimit(wxAppletsCodeVo,accessToken);
//更新二维码表
userWxAqrCode.setCodeImgUrl(wxAppletsCodeVo.getCodeImgUrl());
userWxAqrCode.setBase64(wxAppletsCodeVo.getBase64());
userWxAqrCode.setPage(wxAppletsCodeVo.getPage());
userWxAqrCode.setScene(wxAppletsCodeVo.getScene());
userWxAqrCode.setWidth(wxAppletsCodeVo.getWidth());
userWxAqrCodeMapper.updateUserWxAqrCode(userWxAqrCode);
return Boolean.TRUE;
}
}

View File

@@ -58,11 +58,11 @@
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<logger name="com.ruoyi" level="debug" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<root level="debug">
<appender-ref ref="console" />
</root>

View File

@@ -0,0 +1,111 @@
<?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.UserWxAqrCodeMapper">
<resultMap type="UserWxAqrCode" id="UserWxAqrCodeResult">
<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="scene" column="scene" />
<result property="base64" column="base64" />
<result property="codeImgUrl" column="code_img_url" />
<result property="userId" column="user_id" />
<result property="busType" column="bus_type" />
<result property="page" column="page" />
<result property="width" column="width" />
</resultMap>
<sql id="selectUserWxAqrCodeVo">
select ID, IS_DELETED, CREATED_TIME, CREATED_BY, MODIFIED_BY, LAST_UPDATED_TIME, scene, base64, code_img_url, user_id, bus_type, page, width from user_wx_aqr_code
</sql>
<select id="selectUserWxAqrCodeList" parameterType="UserWxAqrCode" resultMap="UserWxAqrCodeResult">
<include refid="selectUserWxAqrCodeVo"/>
<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 like concat('%', #{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="scene != null and scene != ''"> and scene = #{scene}</if>
<if test="base64 != null and base64 != ''"> and base64 = #{base64}</if>
<if test="codeImgUrl != null and codeImgUrl != ''"> and code_img_url = #{codeImgUrl}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="busType != null and busType != ''"> and bus_type = #{busType}</if>
<if test="page != null and page != ''"> and page = #{page}</if>
<if test="width != null "> and width = #{width}</if>
</where>
</select>
<select id="selectUserWxAqrCodeById" parameterType="Long" resultMap="UserWxAqrCodeResult">
<include refid="selectUserWxAqrCodeVo"/>
where ID = #{id}
</select>
<insert id="insertUserWxAqrCode" parameterType="UserWxAqrCode" useGeneratedKeys="true" keyProperty="id">
insert into user_wx_aqr_code
<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="scene != null">scene,</if>
<if test="base64 != null">base64,</if>
<if test="codeImgUrl != null">code_img_url,</if>
<if test="userId != null">user_id,</if>
<if test="busType != null">bus_type,</if>
<if test="page != null">page,</if>
<if test="width != null">width,</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="scene != null">#{scene},</if>
<if test="base64 != null">#{base64},</if>
<if test="codeImgUrl != null">#{codeImgUrl},</if>
<if test="userId != null">#{userId},</if>
<if test="busType != null">#{busType},</if>
<if test="page != null">#{page},</if>
<if test="width != null">#{width},</if>
</trim>
</insert>
<update id="updateUserWxAqrCode" parameterType="UserWxAqrCode">
update user_wx_aqr_code
<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="scene != null">scene = #{scene},</if>
<if test="base64 != null">base64 = #{base64},</if>
<if test="codeImgUrl != null">code_img_url = #{codeImgUrl},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="busType != null">bus_type = #{busType},</if>
<if test="page != null">page = #{page},</if>
<if test="width != null">width = #{width},</if>
</trim>
where ID = #{id}
</update>
<delete id="deleteUserWxAqrCodeById" parameterType="Long">
delete from user_wx_aqr_code where ID = #{id}
</delete>
<delete id="deleteUserWxAqrCodeByIds" parameterType="String">
delete from user_wx_aqr_code where ID in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>