微信小程序微信用户
This commit is contained in:
parent
c142059d38
commit
1991842709
|
@ -0,0 +1,104 @@
|
|||
package com.ruoyi.abuwx.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.abuwx.domain.AbucoderWxuser;
|
||||
import com.ruoyi.abuwx.service.IAbucoderWxuserService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 微信用户Controller
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/abuwx/wxuser")
|
||||
public class AbucoderWxuserController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAbucoderWxuserService abucoderWxuserService;
|
||||
|
||||
/**
|
||||
* 查询微信用户列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('abuwx:wxuser:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
startPage();
|
||||
List<AbucoderWxuser> list = abucoderWxuserService.selectAbucoderWxuserList(abucoderWxuser);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出微信用户列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('abuwx:wxuser:export')")
|
||||
@Log(title = "微信用户", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
List<AbucoderWxuser> list = abucoderWxuserService.selectAbucoderWxuserList(abucoderWxuser);
|
||||
ExcelUtil<AbucoderWxuser> util = new ExcelUtil<AbucoderWxuser>(AbucoderWxuser.class);
|
||||
util.exportExcel(response, list, "微信用户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信用户详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('abuwx:wxuser:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(abucoderWxuserService.selectAbucoderWxuserById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('abuwx:wxuser:add')")
|
||||
@Log(title = "微信用户", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
return toAjax(abucoderWxuserService.insertAbucoderWxuser(abucoderWxuser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('abuwx:wxuser:edit')")
|
||||
@Log(title = "微信用户", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
return toAjax(abucoderWxuserService.updateAbucoderWxuser(abucoderWxuser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('abuwx:wxuser:remove')")
|
||||
@Log(title = "微信用户", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(abucoderWxuserService.deleteAbucoderWxuserByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.ruoyi.abuwx.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 小程序配置对象 abucoder_wxapp_config
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2022-06-28
|
||||
*/
|
||||
public class AbucoderWxappConfig extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** 小程序ID */
|
||||
@Excel(name = "小程序ID")
|
||||
private String appid;
|
||||
|
||||
/** 小程序密钥 */
|
||||
@Excel(name = "小程序密钥")
|
||||
private String appSecret;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private Integer state;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setAppid(String appid)
|
||||
{
|
||||
this.appid = appid;
|
||||
}
|
||||
|
||||
public String getAppid()
|
||||
{
|
||||
return appid;
|
||||
}
|
||||
public void setAppSecret(String appSecret)
|
||||
{
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
public String getAppSecret()
|
||||
{
|
||||
return appSecret;
|
||||
}
|
||||
public void setState(Integer state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Integer getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("appid", getAppid())
|
||||
.append("appSecret", getAppSecret())
|
||||
.append("state", getState())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.ruoyi.abuwx.domain;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 微信用户对象 abucoder_wxuser
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
public class AbucoderWxuser extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** 微信名称 */
|
||||
@Excel(name = "微信名称")
|
||||
private String nickname;
|
||||
|
||||
/** 头像 */
|
||||
@Excel(name = "头像")
|
||||
private String avatar;
|
||||
|
||||
/** OpenID */
|
||||
@Excel(name = "OpenID")
|
||||
private String openid;
|
||||
|
||||
/** 性别 */
|
||||
@Excel(name = "性别")
|
||||
private Integer gender;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setNickname(String nickname)
|
||||
{
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
public void setAvatar(String avatar)
|
||||
{
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatar()
|
||||
{
|
||||
return avatar;
|
||||
}
|
||||
public void setOpenid(String openid)
|
||||
{
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public String getOpenid()
|
||||
{
|
||||
return openid;
|
||||
}
|
||||
public void setGender(Integer gender)
|
||||
{
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public Integer getGender()
|
||||
{
|
||||
return gender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("nickname", getNickname())
|
||||
.append("avatar", getAvatar())
|
||||
.append("openid", getOpenid())
|
||||
.append("gender", getGender())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.ruoyi.abuwx.mapper;
|
||||
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxappConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序配置Mapper接口
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2022-06-28
|
||||
*/
|
||||
public interface AbucoderWxappConfigMapper
|
||||
{
|
||||
/**
|
||||
* 查询小程序配置
|
||||
*
|
||||
* @param id 小程序配置主键
|
||||
* @return 小程序配置
|
||||
*/
|
||||
public AbucoderWxappConfig selectAbucoderWxappConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询小程序配置列表
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 小程序配置集合
|
||||
*/
|
||||
public List<AbucoderWxappConfig> selectAbucoderWxappConfigList(AbucoderWxappConfig abucoderWxappConfig);
|
||||
|
||||
/**
|
||||
* 新增小程序配置
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAbucoderWxappConfig(AbucoderWxappConfig abucoderWxappConfig);
|
||||
|
||||
/**
|
||||
* 修改小程序配置
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAbucoderWxappConfig(AbucoderWxappConfig abucoderWxappConfig);
|
||||
|
||||
/**
|
||||
* 删除小程序配置
|
||||
*
|
||||
* @param id 小程序配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxappConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除小程序配置
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxappConfigByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询开启的小程序配置信息
|
||||
* @return
|
||||
*/
|
||||
AbucoderWxappConfig selectAbucoderWxappConfig();
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.abuwx.mapper;
|
||||
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxuser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信用户Mapper接口
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
public interface AbucoderWxuserMapper
|
||||
{
|
||||
/**
|
||||
* 查询微信用户
|
||||
*
|
||||
* @param id 微信用户主键
|
||||
* @return 微信用户
|
||||
*/
|
||||
public AbucoderWxuser selectAbucoderWxuserById(Long id);
|
||||
|
||||
/**
|
||||
* 查询微信用户列表
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 微信用户集合
|
||||
*/
|
||||
public List<AbucoderWxuser> selectAbucoderWxuserList(AbucoderWxuser abucoderWxuser);
|
||||
|
||||
/**
|
||||
* 新增微信用户
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAbucoderWxuser(AbucoderWxuser abucoderWxuser);
|
||||
|
||||
/**
|
||||
* 修改微信用户
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAbucoderWxuser(AbucoderWxuser abucoderWxuser);
|
||||
|
||||
/**
|
||||
* 删除微信用户
|
||||
*
|
||||
* @param id 微信用户主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxuserById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除微信用户
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxuserByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 通过OpenID查询微信用户信息
|
||||
* @param openid
|
||||
* @return
|
||||
*/
|
||||
public AbucoderWxuser selectAbucoderWxuserOpenID(String openid);
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.ruoyi.abuwx.service;
|
||||
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxappConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序配置Service接口
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2022-06-28
|
||||
*/
|
||||
public interface IAbucoderWxappConfigService
|
||||
{
|
||||
/**
|
||||
* 查询小程序配置
|
||||
*
|
||||
* @param id 小程序配置主键
|
||||
* @return 小程序配置
|
||||
*/
|
||||
public AbucoderWxappConfig selectAbucoderWxappConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询小程序配置列表
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 小程序配置集合
|
||||
*/
|
||||
public List<AbucoderWxappConfig> selectAbucoderWxappConfigList(AbucoderWxappConfig abucoderWxappConfig);
|
||||
|
||||
/**
|
||||
* 新增小程序配置
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAbucoderWxappConfig(AbucoderWxappConfig abucoderWxappConfig);
|
||||
|
||||
/**
|
||||
* 修改小程序配置
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAbucoderWxappConfig(AbucoderWxappConfig abucoderWxappConfig);
|
||||
|
||||
/**
|
||||
* 批量删除小程序配置
|
||||
*
|
||||
* @param ids 需要删除的小程序配置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxappConfigByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除小程序配置信息
|
||||
*
|
||||
* @param id 小程序配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxappConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询开启的小程序配置信息
|
||||
* @return
|
||||
*/
|
||||
public AbucoderWxappConfig selectAbucoderWxappConfig();
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.abuwx.service;
|
||||
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxuser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信用户Service接口
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
public interface IAbucoderWxuserService
|
||||
{
|
||||
/**
|
||||
* 查询微信用户
|
||||
*
|
||||
* @param id 微信用户主键
|
||||
* @return 微信用户
|
||||
*/
|
||||
public AbucoderWxuser selectAbucoderWxuserById(Long id);
|
||||
|
||||
/**
|
||||
* 查询微信用户列表
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 微信用户集合
|
||||
*/
|
||||
public List<AbucoderWxuser> selectAbucoderWxuserList(AbucoderWxuser abucoderWxuser);
|
||||
|
||||
/**
|
||||
* 新增微信用户
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAbucoderWxuser(AbucoderWxuser abucoderWxuser);
|
||||
|
||||
/**
|
||||
* 修改微信用户
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAbucoderWxuser(AbucoderWxuser abucoderWxuser);
|
||||
|
||||
/**
|
||||
* 批量删除微信用户
|
||||
*
|
||||
* @param ids 需要删除的微信用户主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxuserByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除微信用户信息
|
||||
*
|
||||
* @param id 微信用户主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAbucoderWxuserById(Long id);
|
||||
|
||||
/**
|
||||
* 通过OpenID查询微信用户信息
|
||||
* @param openid
|
||||
* @return
|
||||
*/
|
||||
public AbucoderWxuser selectAbucoderWxuserOpenID(String openid);
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.ruoyi.abuwx.service.impl;
|
||||
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxappConfig;
|
||||
import com.ruoyi.abuwx.mapper.AbucoderWxappConfigMapper;
|
||||
import com.ruoyi.abuwx.service.IAbucoderWxappConfigService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序配置Service业务层处理
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2022-06-28
|
||||
*/
|
||||
@Service
|
||||
public class AbucoderWxappConfigServiceImpl implements IAbucoderWxappConfigService
|
||||
{
|
||||
@Autowired
|
||||
private AbucoderWxappConfigMapper abucoderWxappConfigMapper;
|
||||
|
||||
/**
|
||||
* 查询小程序配置
|
||||
*
|
||||
* @param id 小程序配置主键
|
||||
* @return 小程序配置
|
||||
*/
|
||||
@Override
|
||||
public AbucoderWxappConfig selectAbucoderWxappConfigById(Long id)
|
||||
{
|
||||
return abucoderWxappConfigMapper.selectAbucoderWxappConfigById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小程序配置列表
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 小程序配置
|
||||
*/
|
||||
@Override
|
||||
public List<AbucoderWxappConfig> selectAbucoderWxappConfigList(AbucoderWxappConfig abucoderWxappConfig)
|
||||
{
|
||||
return abucoderWxappConfigMapper.selectAbucoderWxappConfigList(abucoderWxappConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增小程序配置
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAbucoderWxappConfig(AbucoderWxappConfig abucoderWxappConfig)
|
||||
{
|
||||
abucoderWxappConfig.setCreateTime(DateUtils.getNowDate());
|
||||
return abucoderWxappConfigMapper.insertAbucoderWxappConfig(abucoderWxappConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改小程序配置
|
||||
*
|
||||
* @param abucoderWxappConfig 小程序配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAbucoderWxappConfig(AbucoderWxappConfig abucoderWxappConfig)
|
||||
{
|
||||
abucoderWxappConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
return abucoderWxappConfigMapper.updateAbucoderWxappConfig(abucoderWxappConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除小程序配置
|
||||
*
|
||||
* @param ids 需要删除的小程序配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAbucoderWxappConfigByIds(Long[] ids)
|
||||
{
|
||||
return abucoderWxappConfigMapper.deleteAbucoderWxappConfigByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小程序配置信息
|
||||
*
|
||||
* @param id 小程序配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAbucoderWxappConfigById(Long id)
|
||||
{
|
||||
return abucoderWxappConfigMapper.deleteAbucoderWxappConfigById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询开启的小程序配置信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AbucoderWxappConfig selectAbucoderWxappConfig() {
|
||||
return abucoderWxappConfigMapper.selectAbucoderWxappConfig();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.ruoyi.abuwx.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.abuwx.mapper.AbucoderWxuserMapper;
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxuser;
|
||||
import com.ruoyi.abuwx.service.IAbucoderWxuserService;
|
||||
|
||||
/**
|
||||
* 微信用户Service业务层处理
|
||||
*
|
||||
* @author 阿卜Coder QQ932696181
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
@Service
|
||||
public class AbucoderWxuserServiceImpl implements IAbucoderWxuserService
|
||||
{
|
||||
@Autowired
|
||||
private AbucoderWxuserMapper abucoderWxuserMapper;
|
||||
|
||||
/**
|
||||
* 查询微信用户
|
||||
*
|
||||
* @param id 微信用户主键
|
||||
* @return 微信用户
|
||||
*/
|
||||
@Override
|
||||
public AbucoderWxuser selectAbucoderWxuserById(Long id)
|
||||
{
|
||||
return abucoderWxuserMapper.selectAbucoderWxuserById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信用户列表
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 微信用户
|
||||
*/
|
||||
@Override
|
||||
public List<AbucoderWxuser> selectAbucoderWxuserList(AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
return abucoderWxuserMapper.selectAbucoderWxuserList(abucoderWxuser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信用户
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAbucoderWxuser(AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
abucoderWxuser.setCreateTime(DateUtils.getNowDate());
|
||||
return abucoderWxuserMapper.insertAbucoderWxuser(abucoderWxuser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信用户
|
||||
*
|
||||
* @param abucoderWxuser 微信用户
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAbucoderWxuser(AbucoderWxuser abucoderWxuser)
|
||||
{
|
||||
abucoderWxuser.setUpdateTime(DateUtils.getNowDate());
|
||||
return abucoderWxuserMapper.updateAbucoderWxuser(abucoderWxuser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信用户
|
||||
*
|
||||
* @param ids 需要删除的微信用户主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAbucoderWxuserByIds(Long[] ids)
|
||||
{
|
||||
return abucoderWxuserMapper.deleteAbucoderWxuserByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信用户信息
|
||||
*
|
||||
* @param id 微信用户主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAbucoderWxuserById(Long id)
|
||||
{
|
||||
return abucoderWxuserMapper.deleteAbucoderWxuserById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过OpenID查询微信用户信息
|
||||
* @param openid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AbucoderWxuser selectAbucoderWxuserOpenID(String openid) {
|
||||
return abucoderWxuserMapper.selectAbucoderWxuserOpenID(openid);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package com.ruoyi.abuwxapi;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.abuwx.domain.AbucoderWxuser;
|
||||
import com.ruoyi.abuwx.service.IAbucoderWxappConfigService;
|
||||
import com.ruoyi.abuwx.service.IAbucoderWxuserService;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.framework.config.ServerConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wxapi/")
|
||||
public class WxLoginController {
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("test")
|
||||
public AjaxResult test(){
|
||||
return AjaxResult.success("小程序api调试成功!~");
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private IAbucoderWxuserService iAbucoderWxuserService;
|
||||
|
||||
@Autowired
|
||||
private IAbucoderWxappConfigService wxappConfigService;
|
||||
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
/**
|
||||
* 你自己的微信小程序APPID
|
||||
*/
|
||||
|
||||
private final static String AppID = "wxeda4365eac6838c5";
|
||||
/**
|
||||
* 你自己的微信APP密钥
|
||||
*/
|
||||
private final static String AppSecret = "5005219596b2fa77ad930d06101102b1";
|
||||
|
||||
/**
|
||||
* 登录时获取的 code(微信官方提供的临时凭证)
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/wxlogin")
|
||||
public AjaxResult wxLogin(@RequestBody JSONObject object){
|
||||
//微信官方提供的微信小程序登录授权时使用的URL地址
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
System.out.println(object);
|
||||
|
||||
/**
|
||||
* 拼接需要的参数
|
||||
* appid = AppID 你自己的微信小程序APPID
|
||||
* js_code = AppSecret 你自己的微信APP密钥
|
||||
* grant_type=authorization_code = code 微信官方提供的临时凭证
|
||||
*/
|
||||
String params = StrUtil.format("appid={}&secret={}&js_code={}&grant_type=authorization_code", AppID, AppSecret, object.get("code"));
|
||||
//开始发起网络请求,若依管理系统自带网络请求工具,直接使用即可
|
||||
String res = HttpUtils.sendGet(url,params);
|
||||
JSONObject jsonObject = JSON.parseObject(res);
|
||||
String openid = (String) jsonObject.get("openid");
|
||||
if (StrUtil.isEmpty(openid)) {
|
||||
return AjaxResult.error("未获取到openid");
|
||||
}
|
||||
/**先通过openid来查询是否存在*/
|
||||
AbucoderWxuser abucoderWxuser = iAbucoderWxuserService.selectAbucoderWxuserOpenID(openid);
|
||||
if (abucoderWxuser == null){
|
||||
/**如果不存在就插入到我们的数据库里*/
|
||||
AbucoderWxuser wxuser = new AbucoderWxuser();
|
||||
wxuser.setOpenid(openid);
|
||||
wxuser.setCreateTime(DateUtils.getNowDate());
|
||||
iAbucoderWxuserService.insertAbucoderWxuser(wxuser);
|
||||
/**返回结果集到前段*/
|
||||
return AjaxResult.success(wxuser);
|
||||
}else {
|
||||
/**返回结果集到前段*/
|
||||
return AjaxResult.success(abucoderWxuser);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/upload")
|
||||
@ResponseBody
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
System.out.println(file);
|
||||
try
|
||||
{
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("url", url);
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||
ajax.put("originalFilename", file.getOriginalFilename());
|
||||
return ajax;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存昵称与头像信息到用户信息里
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/saveUserInfo")
|
||||
@ResponseBody
|
||||
public AjaxResult saveUserInfo(@RequestBody JSONObject object){
|
||||
System.out.println(object);
|
||||
AbucoderWxuser abucoderWxuser = iAbucoderWxuserService.selectAbucoderWxuserOpenID(String.valueOf(object.get("openid")));
|
||||
if (StringUtils.hasLength(String.valueOf(object.get("nickName")))){
|
||||
abucoderWxuser.setNickname(String.valueOf(object.get("nickName")));
|
||||
abucoderWxuser.setCreateBy(String.valueOf(object.get("nickName")));
|
||||
}
|
||||
if (StringUtils.hasLength(String.valueOf(object.get("avatarUrl")))){
|
||||
abucoderWxuser.setAvatar(String.valueOf(object.get("avatarUrl")));
|
||||
}
|
||||
abucoderWxuser.setUpdateTime(DateUtils.getNowDate());
|
||||
iAbucoderWxuserService.updateAbucoderWxuser(abucoderWxuser);
|
||||
//返回前段需要的数据
|
||||
return AjaxResult.success(abucoderWxuser);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?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.abuwx.mapper.AbucoderWxappConfigMapper">
|
||||
|
||||
<resultMap type="AbucoderWxappConfig" id="AbucoderWxappConfigResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="appid" column="appid" />
|
||||
<result property="appSecret" column="app_secret" />
|
||||
<result property="state" column="state" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAbucoderWxappConfigVo">
|
||||
select id, appid, app_secret, state, create_by, create_time, update_by, update_time, remark from abucoder_wxapp_config
|
||||
</sql>
|
||||
|
||||
<select id="selectAbucoderWxappConfigList" parameterType="AbucoderWxappConfig" resultMap="AbucoderWxappConfigResult">
|
||||
<include refid="selectAbucoderWxappConfigVo"/>
|
||||
<where>
|
||||
<if test="appid != null and appid != ''"> and appid = #{appid}</if>
|
||||
<if test="appSecret != null and appSecret != ''"> and app_secret = #{appSecret}</if>
|
||||
<if test="state != null "> and state = #{state}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAbucoderWxappConfigById" parameterType="Long" resultMap="AbucoderWxappConfigResult">
|
||||
<include refid="selectAbucoderWxappConfigVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectAbucoderWxappConfig" resultMap="AbucoderWxappConfigResult">
|
||||
<include refid="selectAbucoderWxappConfigVo"/>
|
||||
where state = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertAbucoderWxappConfig" parameterType="AbucoderWxappConfig" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into abucoder_wxapp_config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="appid != null">appid,</if>
|
||||
<if test="appSecret != null">app_secret,</if>
|
||||
<if test="state != null">state,</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>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="appid != null">#{appid},</if>
|
||||
<if test="appSecret != null">#{appSecret},</if>
|
||||
<if test="state != null">#{state},</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>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAbucoderWxappConfig" parameterType="AbucoderWxappConfig">
|
||||
update abucoder_wxapp_config
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="appid != null">appid = #{appid},</if>
|
||||
<if test="appSecret != null">app_secret = #{appSecret},</if>
|
||||
<if test="state != null">state = #{state},</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>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAbucoderWxappConfigById" parameterType="Long">
|
||||
delete from abucoder_wxapp_config where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAbucoderWxappConfigByIds" parameterType="String">
|
||||
delete from abucoder_wxapp_config where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,93 @@
|
|||
<?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.abuwx.mapper.AbucoderWxuserMapper">
|
||||
|
||||
<resultMap type="AbucoderWxuser" id="AbucoderWxuserResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="nickname" column="nickname" />
|
||||
<result property="avatar" column="avatar" />
|
||||
<result property="openid" column="openid" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAbucoderWxuserVo">
|
||||
select id, nickname, avatar, openid, gender, create_by, create_time, update_by, update_time, remark from abucoder_wxuser
|
||||
</sql>
|
||||
|
||||
<select id="selectAbucoderWxuserList" parameterType="AbucoderWxuser" resultMap="AbucoderWxuserResult">
|
||||
<include refid="selectAbucoderWxuserVo"/>
|
||||
<where>
|
||||
<if test="openid != null and openid != ''"> and openid = #{openid}</if>
|
||||
<if test="gender != null "> and gender = #{gender}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAbucoderWxuserById" parameterType="Long" resultMap="AbucoderWxuserResult">
|
||||
<include refid="selectAbucoderWxuserVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertAbucoderWxuser" parameterType="AbucoderWxuser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into abucoder_wxuser
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="nickname != null">nickname,</if>
|
||||
<if test="avatar != null">avatar,</if>
|
||||
<if test="openid != null">openid,</if>
|
||||
<if test="gender != null">gender,</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>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="nickname != null">#{nickname},</if>
|
||||
<if test="avatar != null">#{avatar},</if>
|
||||
<if test="openid != null">#{openid},</if>
|
||||
<if test="gender != null">#{gender},</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>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAbucoderWxuser" parameterType="AbucoderWxuser">
|
||||
update abucoder_wxuser
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="nickname != null">nickname = #{nickname},</if>
|
||||
<if test="avatar != null">avatar = #{avatar},</if>
|
||||
<if test="openid != null">openid = #{openid},</if>
|
||||
<if test="gender != null">gender = #{gender},</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>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAbucoderWxuserById" parameterType="Long">
|
||||
delete from abucoder_wxuser where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAbucoderWxuserByIds" parameterType="String">
|
||||
delete from abucoder_wxuser where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="selectAbucoderWxuserOpenID" resultMap="AbucoderWxuserResult">
|
||||
<include refid="selectAbucoderWxuserVo"/>
|
||||
where openid = #{openid}
|
||||
</select>
|
||||
</mapper>
|
|
@ -22,7 +22,7 @@ import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
|
|||
|
||||
/**
|
||||
* spring security配置
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||
|
@ -33,7 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
*/
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
|
||||
/**
|
||||
* 认证失败处理类
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
*/
|
||||
@Autowired
|
||||
private JwtAuthenticationTokenFilter authenticationTokenFilter;
|
||||
|
||||
|
||||
/**
|
||||
* 跨域过滤器
|
||||
*/
|
||||
|
@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
// 过滤请求
|
||||
.authorizeRequests()
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
.antMatchers("/login", "/register", "/captchaImage","/wxapi/**","/profile/**").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
|
Loading…
Reference in New Issue