mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-26 11:51:55 +08:00
小程序接口迁移到ry
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.auth.controller;
|
||||
|
||||
/**
|
||||
* @author 吴一博
|
||||
* @date 2023年07月07日 17:47
|
||||
* @Description
|
||||
*/
|
||||
|
||||
import com.ruoyi.auth.form.WxLoginBody;
|
||||
import com.ruoyi.auth.service.SysLoginService;
|
||||
import com.ruoyi.auth.service.WxLoginService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.service.TokenService;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.ruoyi.system.api.model.WxLoginUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 微信小程序登录Controller
|
||||
*
|
||||
* @author wyb
|
||||
* @date 2023-07-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value="/wxLogin")
|
||||
@Api(description = "微信小程序-登录接口")
|
||||
public class WxLoginController {
|
||||
|
||||
@Resource
|
||||
private WxLoginService wxLoginService;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@ApiOperation("wx用户登录")
|
||||
@PostMapping("/loginInFromWx")
|
||||
@ResponseBody
|
||||
public R<?> loginInFromWx(@RequestBody LoginUser entity) {
|
||||
LoginUser loginUser = wxLoginService.loginInFromWx(entity);
|
||||
return R.ok(tokenService.createToken(loginUser));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/user/register")
|
||||
@ApiOperation(value = "wx用户注册接口")
|
||||
public AjaxResult register(@RequestBody WxLoginBody entity) {
|
||||
//loginFeign.register(entity);
|
||||
return AjaxResult.success("注册成功");
|
||||
}
|
||||
|
||||
@ApiOperation("用户登出")
|
||||
@GetMapping("/loginOut")
|
||||
@ResponseBody
|
||||
public AjaxResult loginOut(@PathVariable("id") Long id) throws Exception {
|
||||
return AjaxResult.success("登出成功");
|
||||
}
|
||||
}
|
||||
114
ruoyi-auth/src/main/java/com/ruoyi/auth/form/WxLoginBody.java
Normal file
114
ruoyi-auth/src/main/java/com/ruoyi/auth/form/WxLoginBody.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package com.ruoyi.auth.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import jdk.nashorn.internal.objects.annotations.Getter;
|
||||
import jdk.nashorn.internal.objects.annotations.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 吴一博
|
||||
* @date 2023年07月07日 17:49
|
||||
* @Description
|
||||
*/
|
||||
public class WxLoginBody {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 账号(手机号/微信code)
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value="账号(手机号/微信code)",required=false)
|
||||
@NotBlank(message = "登录账号不能为空")
|
||||
private String loginName;
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "用户密码")
|
||||
private String password;
|
||||
/**
|
||||
* 用户手机号(微信登录需要传)
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "用户手机号")
|
||||
private String telephone;
|
||||
/**
|
||||
*头像(微信登录需要传)
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
*性别(微信登录需要传)
|
||||
*/
|
||||
|
||||
private Integer gender;
|
||||
/**
|
||||
*昵称(微信登录需要传)
|
||||
*/
|
||||
|
||||
private String nickname;
|
||||
/**
|
||||
* 登录类型(1:pc;2:wx)
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "登录类型(1:pc;2:wx)")
|
||||
@NotBlank(message = "登录类型不能为空")
|
||||
private String type;
|
||||
|
||||
public String getLoginName() {
|
||||
return loginName;
|
||||
}
|
||||
|
||||
public void setLoginName(String loginName) {
|
||||
this.loginName = loginName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public Integer getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(Integer gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.auth.service;
|
||||
|
||||
import com.ruoyi.auth.form.WxLoginBody;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.system.api.RemoteUserService;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author 吴一博
|
||||
* @date 2023年07月07日 17:52
|
||||
* @Description
|
||||
*/
|
||||
@Component
|
||||
public class WxLoginService {
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
public LoginUser loginInFromWx(LoginUser entity) {
|
||||
// 查询用户信息
|
||||
R<LoginUser> userResult = remoteUserService.getWxUserInfo(entity,SecurityConstants.INNER);
|
||||
LoginUser userInfo = userResult.getData();
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user