Compare commits
2 Commits
806f1fe08f
...
ea52f8e363
Author | SHA1 | Date |
---|---|---|
|
ea52f8e363 | |
|
4e2416fee1 |
|
@ -20,9 +20,6 @@ import java.util.Map;
|
|||
public interface RemoteProService
|
||||
{
|
||||
|
||||
@GetMapping("/wxCallBack/maLogin/{code}")
|
||||
public R<Map<String,Object>> maLogin(@PathVariable("code") String code, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 项目详情
|
||||
*
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.yanzhu.system.api;
|
||||
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
import com.yanzhu.system.api.model.LoginUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -20,6 +21,24 @@ import java.util.Map;
|
|||
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
||||
public interface RemoteUserService
|
||||
{
|
||||
/**
|
||||
* 获取小程序授权
|
||||
* @param code 授权码
|
||||
* @param source 请求来源
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sysUserUniopen/getMaOpenId/{code}")
|
||||
public R<Map<String,Object>> getMaOpenId(@PathVariable("code") String code, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 查询小程序授权
|
||||
* @param maOpenId 小程序授权id
|
||||
* @param source 请求来源
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sysUserUniopen/findByMaOpenId/{maOpenId}")
|
||||
public R<SysUserUniopen> findByMaOpenId(@PathVariable("maOpenId") String maOpenId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
*
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package com.yanzhu.system.api.domain;
|
||||
|
||||
import com.yanzhu.common.core.annotation.Excel;
|
||||
import com.yanzhu.common.core.web.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用户授权对象 sys_user_uniopen
|
||||
*
|
||||
* @author JiangYuQi
|
||||
* @date 2024-10-13
|
||||
*/
|
||||
public class SysUserUniopen extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 用户主键 */
|
||||
@Excel(name = "用户主键")
|
||||
private Long userId;
|
||||
|
||||
/** 用户账号 */
|
||||
@Excel(name = "用户账号")
|
||||
private String userName;
|
||||
|
||||
/** 用户昵称 */
|
||||
@Excel(name = "用户昵称")
|
||||
private String userNick;
|
||||
|
||||
/** 唯一关联id */
|
||||
@Excel(name = "唯一关联id")
|
||||
private String unionid;
|
||||
|
||||
/** 小程序授权id */
|
||||
@Excel(name = "小程序授权id")
|
||||
private String maOpenId;
|
||||
|
||||
/** 公众号授权id */
|
||||
@Excel(name = "公众号授权id")
|
||||
private String mpOpenId;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
public void setUserName(String userName)
|
||||
{
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
public void setUserNick(String userNick)
|
||||
{
|
||||
this.userNick = userNick;
|
||||
}
|
||||
|
||||
public String getUserNick()
|
||||
{
|
||||
return userNick;
|
||||
}
|
||||
public void setUnionid(String unionid)
|
||||
{
|
||||
this.unionid = unionid;
|
||||
}
|
||||
|
||||
public String getUnionid()
|
||||
{
|
||||
return unionid;
|
||||
}
|
||||
public void setMaOpenId(String maOpenId)
|
||||
{
|
||||
this.maOpenId = maOpenId;
|
||||
}
|
||||
|
||||
public String getMaOpenId()
|
||||
{
|
||||
return maOpenId;
|
||||
}
|
||||
public void setMpOpenId(String mpOpenId)
|
||||
{
|
||||
this.mpOpenId = mpOpenId;
|
||||
}
|
||||
|
||||
public String getMpOpenId()
|
||||
{
|
||||
return mpOpenId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("userId", getUserId())
|
||||
.append("userName", getUserName())
|
||||
.append("userNick", getUserNick())
|
||||
.append("unionid", getUnionid())
|
||||
.append("maOpenId", getMaOpenId())
|
||||
.append("mpOpenId", getMpOpenId())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -26,12 +26,6 @@ public class RemoteProFallbackFactory implements FallbackFactory<RemoteProServic
|
|||
log.error("项目服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteProService()
|
||||
{
|
||||
@Override
|
||||
public R<Map<String,Object>> maLogin(String code, String source)
|
||||
{
|
||||
return R.fail("小程序登录失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Map<String,Object>> info(Long id, String source)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.yanzhu.system.api.factory;
|
||||
|
||||
import com.yanzhu.system.api.RemoteUserService;
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
import com.yanzhu.system.api.model.LoginUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -28,6 +29,18 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteUserService()
|
||||
{
|
||||
@Override
|
||||
public R<Map<String,Object>> getMaOpenId(String code, String source)
|
||||
{
|
||||
return R.fail("获取小程序授权失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<SysUserUniopen> findByMaOpenId(String maOpenId, String source)
|
||||
{
|
||||
return R.fail("查询小程序授权失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<LoginUser> getUserInfo(String username, String source)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,8 @@ package com.yanzhu.auth.controller;
|
|||
|
||||
import com.yanzhu.auth.form.LoginBody;
|
||||
import com.yanzhu.auth.form.RegisterBody;
|
||||
import com.yanzhu.auth.form.WxLoginBody;
|
||||
import com.yanzhu.auth.form.WxMaLoginBody;
|
||||
import com.yanzhu.auth.form.WxMaOpenIdBody;
|
||||
import com.yanzhu.auth.service.SysLoginService;
|
||||
import com.yanzhu.common.core.constant.SecurityConstants;
|
||||
import com.yanzhu.common.core.domain.R;
|
||||
|
@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -57,16 +59,29 @@ public class TokenController
|
|||
return R.ok(tokenService.createToken(userInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序授权
|
||||
* @param body 请求参数
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("getMaOpenId")
|
||||
public R<?> getMaOpenId(@RequestBody @Valid WxMaOpenIdBody body)
|
||||
{
|
||||
String maOpenId = sysLoginService.getMaOpenId(body.getCode());
|
||||
// 获取授权openId
|
||||
return R.ok(maOpenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序一键登录
|
||||
* @param form
|
||||
* @param body 请求参数
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("maLogin")
|
||||
public R<?> maLogin(@RequestBody WxLoginBody form)
|
||||
public R<?> maLogin(@RequestBody @Valid WxMaLoginBody body)
|
||||
{
|
||||
// 用户登录
|
||||
Map<String,Object> result = sysLoginService.maLogin(form.getCode(), form.getAppId());
|
||||
Map<String,Object> result = sysLoginService.maLogin(body);
|
||||
// 获取登录token
|
||||
return R.ok(result);
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package com.yanzhu.auth.form;
|
||||
|
||||
/**
|
||||
* 微信登录对象
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class WxLoginBody {
|
||||
|
||||
/**
|
||||
* 用户代码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 应用代码
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.yanzhu.auth.form;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 微信小程序登录对象
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "微信小程序登录对象")
|
||||
public class WxMaLoginBody {
|
||||
|
||||
/**
|
||||
* 授权项目
|
||||
*/
|
||||
private Long proId;
|
||||
|
||||
/**
|
||||
* 授权编号
|
||||
*/
|
||||
@NotBlank(message = "授权编号不能为空")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 加密代码
|
||||
*/
|
||||
@NotBlank(message = "加密代码不能为空")
|
||||
private String encryptedData;
|
||||
|
||||
/**
|
||||
* 加密方式
|
||||
*/
|
||||
@NotBlank(message = "加密方式不能为空")
|
||||
private String iv;
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.yanzhu.auth.form;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 微信小程序授权
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "微信小程序授权对象")
|
||||
public class WxMaOpenIdBody {
|
||||
|
||||
/**
|
||||
* 授权码
|
||||
*/
|
||||
@NotBlank(message = "授权码不能为空")
|
||||
private String code;
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.yanzhu.auth.service;
|
||||
|
||||
import com.yanzhu.auth.form.WxMaLoginBody;
|
||||
import com.yanzhu.system.api.RemoteProService;
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.yanzhu.common.core.constant.CacheConstants;
|
||||
|
@ -124,14 +126,31 @@ public class SysLoginService
|
|||
}
|
||||
|
||||
/**
|
||||
* 微信小程序登录
|
||||
* 获取小程序授权
|
||||
*/
|
||||
public Map<String,Object> maLogin(String code, String appId)
|
||||
public String getMaOpenId(String code)
|
||||
{
|
||||
Map<String,Object> loginResult = remoteProService.maLogin(code,SecurityConstants.INNER).getData();
|
||||
return loginResult;
|
||||
Map<String,Object> loginResult = remoteUserService.getMaOpenId(code,SecurityConstants.INNER).getData();
|
||||
return Convert.toStr(loginResult.get("openid"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信小程序登录
|
||||
*/
|
||||
public Map<String,Object> maLogin(WxMaLoginBody loginBody)
|
||||
{
|
||||
// 查询小程序授权情况
|
||||
R<SysUserUniopen> uniResult = remoteUserService.findByMaOpenId(loginBody.getOpenId(),SecurityConstants.INNER);
|
||||
if(Objects.isNull(uniResult) || Objects.isNull(uniResult.getData())){
|
||||
throw new ServiceException("当前微信还未绑定账号!!!请使用账号登录一次");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public void logout(String loginName)
|
||||
{
|
||||
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
||||
|
|
|
@ -113,6 +113,11 @@
|
|||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Belerweb Pinyin4j -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
|
|
|
@ -77,12 +77,6 @@
|
|||
<artifactId>yanzhu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
|
|
|
@ -31,11 +31,11 @@ public class WxCallBackController {
|
|||
* 小程序登录
|
||||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/maLogin/{code}")
|
||||
public R<Map<String, Object>> maLogin(@PathVariable("code") String code) {
|
||||
@GetMapping("/getMaOpenId/{code}")
|
||||
public R<Map<String, Object>> getMaOpenId(@PathVariable("code") String code) {
|
||||
WxMaJscode2SessionResult sessionInfo =
|
||||
wxMaService.getUserService().getSessionInfo(code);
|
||||
log.info("wxLogin==>{}...{}",code,sessionInfo.getOpenid());
|
||||
log.info("getMaOpenId==>{}...{}",code,sessionInfo.getOpenid());
|
||||
try {
|
||||
return R.ok(BeanUtils.beanToMap(sessionInfo));
|
||||
}catch (Exception e){
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package com.yanzhu.system.config;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 微信配置
|
||||
*/
|
||||
@Configuration
|
||||
public class WeChatConfig {
|
||||
|
||||
@Autowired
|
||||
private WeChatProperties weChatProperties;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WeChatConfig.class);
|
||||
|
||||
/**
|
||||
* 公众号
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public WxMpService wxMpService() {
|
||||
WxMpInMemoryConfigStorage config = new WxMpInMemoryConfigStorage();
|
||||
log.info("weChatProperties.mpAppId...{}",weChatProperties.getMpAppId());
|
||||
log.info("weChatProperties.mpAppSecret...{}",weChatProperties.getMpAppSecret());
|
||||
config.setAppId(weChatProperties.getMpAppId());
|
||||
config.setSecret(weChatProperties.getMpAppSecret());
|
||||
|
||||
WxMpServiceImpl wxMpService = new WxMpServiceImpl();
|
||||
wxMpService.setWxMpConfigStorage(config);
|
||||
|
||||
return wxMpService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public WxMaService wxMaService() {
|
||||
WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();
|
||||
log.info("weChatProperties.maAppId...{}",weChatProperties.getMaAppId());
|
||||
log.info("weChatProperties.maAppSecret...{}",weChatProperties.getMaAppSecret());
|
||||
wxMaConfig.setAppid(weChatProperties.getMaAppId());
|
||||
wxMaConfig.setSecret(weChatProperties.getMaAppSecret());
|
||||
|
||||
WxMaService wxMaService = new WxMaServiceImpl();
|
||||
wxMaService.setWxMaConfig(wxMaConfig);
|
||||
|
||||
return wxMaService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.yanzhu.system.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 微信配置文件
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "wechat")
|
||||
public class WeChatProperties {
|
||||
|
||||
/**
|
||||
* 公众号
|
||||
*/
|
||||
private String mpAppId;
|
||||
private String mpAppSecret;
|
||||
|
||||
/**
|
||||
* 小程序
|
||||
*/
|
||||
private String maAppId;
|
||||
private String maAppSecret;
|
||||
}
|
|
@ -1,33 +1,9 @@
|
|||
package com.yanzhu.system.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.yanzhu.common.core.constant.Constants;
|
||||
import com.yanzhu.common.core.domain.R;
|
||||
import com.yanzhu.common.core.enums.UserTypeEnums;
|
||||
import com.yanzhu.common.core.text.Convert;
|
||||
import com.yanzhu.common.redis.service.RedisService;
|
||||
import com.yanzhu.system.domain.vo.TreeSelect;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.yanzhu.common.core.domain.R;
|
||||
import com.yanzhu.common.core.utils.StringUtils;
|
||||
import com.yanzhu.common.core.utils.poi.ExcelUtil;
|
||||
import com.yanzhu.common.core.web.controller.BaseController;
|
||||
|
@ -35,6 +11,7 @@ import com.yanzhu.common.core.web.domain.AjaxResult;
|
|||
import com.yanzhu.common.core.web.page.TableDataInfo;
|
||||
import com.yanzhu.common.log.annotation.Log;
|
||||
import com.yanzhu.common.log.enums.BusinessType;
|
||||
import com.yanzhu.common.redis.service.RedisService;
|
||||
import com.yanzhu.common.security.annotation.InnerAuth;
|
||||
import com.yanzhu.common.security.annotation.RequiresPermissions;
|
||||
import com.yanzhu.common.security.utils.SecurityUtils;
|
||||
|
@ -42,12 +19,23 @@ import com.yanzhu.system.api.domain.SysDept;
|
|||
import com.yanzhu.system.api.domain.SysRole;
|
||||
import com.yanzhu.system.api.domain.SysUser;
|
||||
import com.yanzhu.system.api.model.LoginUser;
|
||||
import com.yanzhu.system.service.ISysConfigService;
|
||||
import com.yanzhu.system.service.ISysDeptService;
|
||||
import com.yanzhu.system.service.ISysPermissionService;
|
||||
import com.yanzhu.system.service.ISysPostService;
|
||||
import com.yanzhu.system.service.ISysRoleService;
|
||||
import com.yanzhu.system.service.ISysUserService;
|
||||
import com.yanzhu.system.domain.vo.TreeSelect;
|
||||
import com.yanzhu.system.service.*;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
|
@ -57,6 +45,7 @@ import com.yanzhu.system.service.ISysUserService;
|
|||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class SysUserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
@ -387,4 +376,5 @@ public class SysUserController extends BaseController {
|
|||
List<SysUser> list = userService.selectUserList(user);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
package com.yanzhu.system.controller;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import com.yanzhu.common.core.domain.R;
|
||||
import com.yanzhu.common.core.utils.bean.BeanUtils;
|
||||
import com.yanzhu.common.core.utils.poi.ExcelUtil;
|
||||
import com.yanzhu.common.core.web.controller.BaseController;
|
||||
import com.yanzhu.common.core.web.domain.AjaxResult;
|
||||
import com.yanzhu.common.core.web.page.TableDataInfo;
|
||||
import com.yanzhu.common.log.annotation.Log;
|
||||
import com.yanzhu.common.log.enums.BusinessType;
|
||||
import com.yanzhu.common.security.annotation.InnerAuth;
|
||||
import com.yanzhu.common.security.annotation.RequiresPermissions;
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
import com.yanzhu.system.service.ISysUserUniopenService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户授权Controller
|
||||
*
|
||||
* @author JiangYuQi
|
||||
* @date 2024-10-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sysUserUniopen")
|
||||
public class SysUserUniopenController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserUniopenService sysUserUniopenService;
|
||||
|
||||
@Autowired
|
||||
private WxMaService wxMaService;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserController.class);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*/
|
||||
@RequiresPermissions("@ss.hasPermi('system:sysUserUniopen:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
startPage();
|
||||
List<SysUserUniopen> list = sysUserUniopenService.selectSysUserUniopenList(sysUserUniopen);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户授权列表
|
||||
*/
|
||||
@RequiresPermissions("@ss.hasPermi('system:sysUserUniopen:export')")
|
||||
@Log(title = "用户授权", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
List<SysUserUniopen> list = sysUserUniopenService.selectSysUserUniopenList(sysUserUniopen);
|
||||
ExcelUtil<SysUserUniopen> util = new ExcelUtil<SysUserUniopen>(SysUserUniopen.class);
|
||||
util.exportExcel(response, list, "用户授权数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户授权详细信息
|
||||
*/
|
||||
@RequiresPermissions("@ss.hasPermi('system:sysUserUniopen:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(sysUserUniopenService.selectSysUserUniopenById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户授权
|
||||
*/
|
||||
@RequiresPermissions("@ss.hasPermi('system:sysUserUniopen:add')")
|
||||
@Log(title = "用户授权", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
return toAjax(sysUserUniopenService.insertSysUserUniopen(sysUserUniopen));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户授权
|
||||
*/
|
||||
@RequiresPermissions("@ss.hasPermi('system:sysUserUniopen:edit')")
|
||||
@Log(title = "用户授权", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
return toAjax(sysUserUniopenService.updateSysUserUniopen(sysUserUniopen));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户授权
|
||||
*/
|
||||
@RequiresPermissions("@ss.hasPermi('system:sysUserUniopen:remove')")
|
||||
@Log(title = "用户授权", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(sysUserUniopenService.deleteSysUserUniopenByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序授权
|
||||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/getMaOpenId/{code}")
|
||||
public R<Map<String, Object>> getMaOpenId(@PathVariable("code") String code) {
|
||||
WxMaJscode2SessionResult sessionInfo =
|
||||
wxMaService.getUserService().getSessionInfo(code);
|
||||
log.info("getMaOpenId==>{}...{}",code,sessionInfo.getOpenid());
|
||||
try {
|
||||
return R.ok(BeanUtils.beanToMap(sessionInfo));
|
||||
}catch (Exception e){
|
||||
return R.fail("小程序授权异常!!!");
|
||||
}
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/findByUserId/{userId}")
|
||||
public R<List<SysUserUniopen>> findByUserId(@PathVariable("userId") Long userId) {
|
||||
return R.ok(sysUserUniopenService.selectSysUserUniopenByUserId(userId));
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/findByUserName/{userName}")
|
||||
public R<List<SysUserUniopen>> findByUserName(@PathVariable("userName") String userName) {
|
||||
return R.ok(sysUserUniopenService.selectSysUserUniopenByUserName(userName));
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/findByUnionid/{unionid}")
|
||||
public R<SysUserUniopen> findByUnionid(@PathVariable("unionid") String unionid) {
|
||||
return R.ok(sysUserUniopenService.selectSysUserUniopenByUnionid(unionid));
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/findByMaOpenId/{maOpenId}")
|
||||
public R<SysUserUniopen> findByMaOpenId(@PathVariable("maOpenId") String maOpenId) {
|
||||
return R.ok(sysUserUniopenService.selectSysUserUniopenByMaOpenId(maOpenId));
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/findByMpOpenId/{mpOpenId}")
|
||||
public R<SysUserUniopen> findByMpOpenId(@PathVariable("mpOpenId") String mpOpenId) {
|
||||
return R.ok(sysUserUniopenService.selectSysUserUniopenByMpOpenId(mpOpenId));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.yanzhu.system.mapper;
|
||||
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户授权Mapper接口
|
||||
*
|
||||
* @author JiangYuQi
|
||||
* @date 2024-10-13
|
||||
*/
|
||||
public interface SysUserUniopenMapper
|
||||
{
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param id 用户授权主键
|
||||
* @return 用户授权
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenById(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param userId 用户主键
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public List<SysUserUniopen> selectSysUserUniopenByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public List<SysUserUniopen> selectSysUserUniopenByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param unionid 唯一关联id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenByUnionid(String unionid);
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param maOpenId 小程序授权id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenByMaOpenId(String maOpenId);
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param mpOpenId 公众号授权id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenByMpOpenId(String mpOpenId);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public List<SysUserUniopen> selectSysUserUniopenList(SysUserUniopen sysUserUniopen);
|
||||
|
||||
/**
|
||||
* 新增用户授权
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysUserUniopen(SysUserUniopen sysUserUniopen);
|
||||
|
||||
/**
|
||||
* 修改用户授权
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysUserUniopen(SysUserUniopen sysUserUniopen);
|
||||
|
||||
/**
|
||||
* 删除用户授权
|
||||
*
|
||||
* @param id 用户授权主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUserUniopenById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除用户授权
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUserUniopenByIds(Long[] ids);
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.yanzhu.system.service;
|
||||
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户授权Service接口
|
||||
*
|
||||
* @author JiangYuQi
|
||||
* @date 2024-10-13
|
||||
*/
|
||||
public interface ISysUserUniopenService
|
||||
{
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param id 用户授权主键
|
||||
* @return 用户授权
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenById(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param userId 用户主键
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public List<SysUserUniopen> selectSysUserUniopenByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public List<SysUserUniopen> selectSysUserUniopenByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param unionid 唯一关联id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenByUnionid(String unionid);
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param maOpenId 小程序授权id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenByMaOpenId(String maOpenId);
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param mpOpenId 公众号授权id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public SysUserUniopen selectSysUserUniopenByMpOpenId(String mpOpenId);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
public List<SysUserUniopen> selectSysUserUniopenList(SysUserUniopen sysUserUniopen);
|
||||
|
||||
/**
|
||||
* 新增用户授权
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysUserUniopen(SysUserUniopen sysUserUniopen);
|
||||
|
||||
/**
|
||||
* 修改用户授权
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysUserUniopen(SysUserUniopen sysUserUniopen);
|
||||
|
||||
/**
|
||||
* 批量删除用户授权
|
||||
*
|
||||
* @param ids 需要删除的用户授权主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUserUniopenByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除用户授权信息
|
||||
*
|
||||
* @param id 用户授权主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUserUniopenById(Long id);
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package com.yanzhu.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.yanzhu.system.api.domain.SysUserUniopen;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.yanzhu.system.mapper.SysUserUniopenMapper;
|
||||
import com.yanzhu.system.service.ISysUserUniopenService;
|
||||
|
||||
/**
|
||||
* 用户授权Service业务层处理
|
||||
*
|
||||
* @author JiangYuQi
|
||||
* @date 2024-10-13
|
||||
*/
|
||||
@Service
|
||||
public class SysUserUniopenServiceImpl implements ISysUserUniopenService
|
||||
{
|
||||
@Autowired
|
||||
private SysUserUniopenMapper sysUserUniopenMapper;
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param id 用户授权主键
|
||||
* @return 用户授权
|
||||
*/
|
||||
@Override
|
||||
public SysUserUniopen selectSysUserUniopenById(Long id)
|
||||
{
|
||||
return sysUserUniopenMapper.selectSysUserUniopenById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param userId 用户主键
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserUniopen> selectSysUserUniopenByUserId(Long userId){
|
||||
return sysUserUniopenMapper.selectSysUserUniopenByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserUniopen> selectSysUserUniopenByUserName(String userName){
|
||||
return sysUserUniopenMapper.selectSysUserUniopenByUserName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param unionid 唯一关联id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
@Override
|
||||
public SysUserUniopen selectSysUserUniopenByUnionid(String unionid){
|
||||
return sysUserUniopenMapper.selectSysUserUniopenByUnionid(unionid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param maOpenId 小程序授权id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
@Override
|
||||
public SysUserUniopen selectSysUserUniopenByMaOpenId(String maOpenId){
|
||||
return sysUserUniopenMapper.selectSysUserUniopenByMaOpenId(maOpenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户授权
|
||||
*
|
||||
* @param mpOpenId 公众号授权id
|
||||
* @return 用户授权集合
|
||||
*/
|
||||
@Override
|
||||
public SysUserUniopen selectSysUserUniopenByMpOpenId(String mpOpenId){
|
||||
return sysUserUniopenMapper.selectSysUserUniopenByMpOpenId(mpOpenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 用户授权
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserUniopen> selectSysUserUniopenList(SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
return sysUserUniopenMapper.selectSysUserUniopenList(sysUserUniopen);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户授权
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysUserUniopen(SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
return sysUserUniopenMapper.insertSysUserUniopen(sysUserUniopen);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户授权
|
||||
*
|
||||
* @param sysUserUniopen 用户授权
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysUserUniopen(SysUserUniopen sysUserUniopen)
|
||||
{
|
||||
return sysUserUniopenMapper.updateSysUserUniopen(sysUserUniopen);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除用户授权
|
||||
*
|
||||
* @param ids 需要删除的用户授权主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysUserUniopenByIds(Long[] ids)
|
||||
{
|
||||
return sysUserUniopenMapper.deleteSysUserUniopenByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户授权信息
|
||||
*
|
||||
* @param id 用户授权主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysUserUniopenById(Long id)
|
||||
{
|
||||
return sysUserUniopenMapper.deleteSysUserUniopenById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
<?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.yanzhu.system.mapper.SysUserUniopenMapper">
|
||||
|
||||
<resultMap type="SysUserUniopen" id="SysUserUniopenResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="userNick" column="user_nick" />
|
||||
<result property="unionid" column="unionid" />
|
||||
<result property="maOpenId" column="ma_open_id" />
|
||||
<result property="mpOpenId" column="mp_open_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysUserUniopenVo">
|
||||
select id, user_id, user_name, user_nick, unionid, ma_open_id, mp_open_id from sys_user_uniopen
|
||||
</sql>
|
||||
|
||||
<select id="selectSysUserUniopenList" parameterType="SysUserUniopen" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name = #{userName}</if>
|
||||
<if test="unionid != null and unionid != ''"> and unionid = #{unionid}</if>
|
||||
<if test="maOpenId != null and maOpenId != ''"> and ma_open_id = #{maOpenId}</if>
|
||||
<if test="mpOpenId != null and mpOpenId != ''"> and mp_open_id = #{mpOpenId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserUniopenById" parameterType="Long" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserUniopenByUserId" parameterType="Long" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserUniopenByUserName" parameterType="String" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
where user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserUniopenByUnionid" parameterType="String" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
where unionid = #{unionid}
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserUniopenByMaOpenId" parameterType="String" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
where ma_open_id = #{maOpenId}
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserUniopenByMpOpenId" parameterType="String" resultMap="SysUserUniopenResult">
|
||||
<include refid="selectSysUserUniopenVo"/>
|
||||
where mp_open_id = #{mpOpenId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysUserUniopen" parameterType="SysUserUniopen" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_user_uniopen
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="userName != null">user_name,</if>
|
||||
<if test="userNick != null">user_nick,</if>
|
||||
<if test="unionid != null">unionid,</if>
|
||||
<if test="maOpenId != null">ma_open_id,</if>
|
||||
<if test="mpOpenId != null">mp_open_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="userName != null">#{userName},</if>
|
||||
<if test="userNick != null">#{userNick},</if>
|
||||
<if test="unionid != null">#{unionid},</if>
|
||||
<if test="maOpenId != null">#{maOpenId},</if>
|
||||
<if test="mpOpenId != null">#{mpOpenId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysUserUniopen" parameterType="SysUserUniopen">
|
||||
update sys_user_uniopen
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="userName != null">user_name = #{userName},</if>
|
||||
<if test="userNick != null">user_nick = #{userNick},</if>
|
||||
<if test="unionid != null">unionid = #{unionid},</if>
|
||||
<if test="maOpenId != null">ma_open_id = #{maOpenId},</if>
|
||||
<if test="mpOpenId != null">mp_open_id = #{mpOpenId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysUserUniopenById" parameterType="Long">
|
||||
delete from sys_user_uniopen where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysUserUniopenByIds" parameterType="String">
|
||||
delete from sys_user_uniopen where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -17,6 +17,24 @@ export function login(data) {
|
|||
})
|
||||
}
|
||||
|
||||
// 获取授权
|
||||
export function getMaOpenId(code) {
|
||||
return request({
|
||||
url: '/getMaOpenId',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 登录方法
|
||||
export function maLogin(data) {
|
||||
return request({
|
||||
url: '/maLogin',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 登录方法
|
||||
export function updatePwd(data) {
|
||||
return request({
|
||||
|
|
|
@ -38,7 +38,7 @@ App({
|
|||
projectInfoList: [],
|
||||
},
|
||||
|
||||
onLaunch: function () {
|
||||
onLaunch: function (options) {
|
||||
if (!wx.cloud) {
|
||||
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
|
||||
} else {
|
||||
|
@ -56,14 +56,18 @@ App({
|
|||
/**
|
||||
* 初始化页面未登录时跳转到登录页
|
||||
*/
|
||||
if (!getToken()) {
|
||||
setTimeout(() => {
|
||||
this.toast("请使用手机号码登录");
|
||||
}, 1000);
|
||||
wx.redirectTo({
|
||||
url: '/pages/login/index',
|
||||
});
|
||||
return false;
|
||||
if(options && options.proId){
|
||||
//扫码进入时不效验登录...跳转授权登录页
|
||||
}else{
|
||||
if (!getToken()) {
|
||||
// setTimeout(() => {
|
||||
// this.toast("请使用手机号码登录");
|
||||
// }, 1000);
|
||||
wx.redirectTo({
|
||||
url: '/pages/login/index',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
module.exports = {
|
||||
timeout: 60000,
|
||||
appId: "wx2350a5efb3f28e66",
|
||||
baseUrl: 'https://guangzhou.sxyanzhu.com/YZLJXM',
|
||||
//baseUrl: 'http://127.0.0.1:8080/yanZhuProject',
|
||||
noSecuritys:['/captchaImage','/wxApi/login']
|
||||
baseUrl: 'http://127.0.0.1:8080',
|
||||
noSecuritys:['/captchaImage','/login','/']
|
||||
};
|
|
@ -1,10 +1,14 @@
|
|||
import {
|
||||
getToken,
|
||||
setToken
|
||||
setToken,
|
||||
getOpenId,
|
||||
setOpenId
|
||||
} from '../../utils/auth'
|
||||
import {
|
||||
login,
|
||||
maLogin,
|
||||
getCodeImg,
|
||||
getMaOpenId,
|
||||
refreshUser,
|
||||
} from '../../api/login'
|
||||
|
||||
|
@ -20,7 +24,6 @@ Page({
|
|||
code: '',
|
||||
uuid: '',
|
||||
codeUrl: '',
|
||||
show: false,
|
||||
checked: true
|
||||
},
|
||||
|
||||
|
@ -43,19 +46,8 @@ Page({
|
|||
})
|
||||
},
|
||||
|
||||
onClickShow() {
|
||||
this.setData({
|
||||
show: true
|
||||
});
|
||||
},
|
||||
|
||||
onClickHide() {
|
||||
this.setData({
|
||||
show: false
|
||||
});
|
||||
},
|
||||
|
||||
onLoad: function (option) {
|
||||
this.getMaOpenId();
|
||||
if (getToken()) {
|
||||
console.log("Authorization...{}", getToken());
|
||||
//刷新权限信息
|
||||
|
@ -74,6 +66,19 @@ Page({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 授权登录
|
||||
*/
|
||||
getMaOpenId: function () {
|
||||
wx.login({
|
||||
success: res => {
|
||||
getMaOpenId(res.code).then(response => {
|
||||
//
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
loadCodeImage: function () {
|
||||
getCodeImg().then(res => {
|
||||
let captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
||||
|
@ -104,7 +109,6 @@ Page({
|
|||
return;
|
||||
}
|
||||
//启动蒙版
|
||||
//this.onClickShow();
|
||||
let that = this;
|
||||
//发送请求
|
||||
login({
|
||||
|
@ -126,7 +130,17 @@ Page({
|
|||
},
|
||||
|
||||
getPhoneNumber(e) {
|
||||
var_this = this
|
||||
if(e.detail.code){
|
||||
let data = {
|
||||
code:e.detail.code,
|
||||
iv: e.detail.iv,
|
||||
encryptedData: e.detail.encryptedData
|
||||
}
|
||||
maLogin({})
|
||||
}else{
|
||||
//用户决绝授权
|
||||
app.toast("请允许微信手机号一键登录");
|
||||
}
|
||||
console.log("getPhoneNumber", e)
|
||||
},
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
</van-row>
|
||||
|
||||
<view class="login_btn" bindtap="userLogin">
|
||||
立 即 登 录
|
||||
账 号 登 录
|
||||
</view>
|
||||
|
||||
<view class="wxlogin_btn">
|
||||
<button open-type="getPhoneNumber">微 信 登 录</button>
|
||||
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">微 信 登 录</button>
|
||||
</view>
|
||||
</view>
|
|
@ -1,12 +1,22 @@
|
|||
const TokenKey = 'YanZhu-App-Token'
|
||||
const TokenKey = 'YanZhu-XD-App-Token'
|
||||
const OpenIdKey = 'YanZhu-XD-App-OpenId'
|
||||
|
||||
export function getToken() {
|
||||
return wx.getStorageSync(TokenKey)
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return wx.setStorageSync(TokenKey, token)
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
return wx.removeStorageSync(TokenKey)
|
||||
}
|
||||
|
||||
export function getOpenId() {
|
||||
return wx.getStorageSync(OpenIdKey)
|
||||
}
|
||||
export function setOpenId(openId) {
|
||||
return wx.setStorageSync(OpenIdKey, openId)
|
||||
}
|
||||
export function removeOpenId() {
|
||||
return wx.removeStorageSync(OpenIdKey)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ function doRequest(url, method = 'GET', data, header = {}) {
|
|||
}
|
||||
wx.showLoading({
|
||||
mask: true,
|
||||
title: url == config.noSecuritys[1] ? '登录中' : '请等待'
|
||||
title: url == config.noSecuritys[1] ? '登录中' : '加载中'
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
|
|
Loading…
Reference in New Issue