|
|
@@ -7,9 +7,7 @@ package net.mingsoft.people.action.web;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
-import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
-import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
@@ -27,7 +25,6 @@ import net.mingsoft.basic.util.RestTemplateUtil;
|
|
|
import net.mingsoft.basic.util.StringUtil;
|
|
|
import net.mingsoft.mdiy.util.ConfigUtil;
|
|
|
import net.mingsoft.people.action.BaseAction;
|
|
|
-import net.mingsoft.people.action.people.PeopleUserAction;
|
|
|
import net.mingsoft.people.annotation.PeopleLogAnn;
|
|
|
import net.mingsoft.people.bean.PeopleBean;
|
|
|
import net.mingsoft.people.bean.PeopleLoginBean;
|
|
|
@@ -46,13 +43,15 @@ import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
/**
|
|
|
* 铭飞会员模块,前端调用(不需要用户登录进行的操作)
|
|
|
*
|
|
|
@@ -84,9 +83,6 @@ public class PeopleAction extends BaseAction {
|
|
|
*/
|
|
|
@Autowired
|
|
|
private IPeopleUserBiz peopleUserBiz;
|
|
|
- @Autowired
|
|
|
- private PeopleUserAction action;
|
|
|
-
|
|
|
|
|
|
@Operation(summary = "验证码验证,例如流程需要短信验证或邮箱验证,为有效防止恶意发送验证码。提供给ajax异步请求使用,注意:页面提交对验证码表单属性名称必须是rand_code,否则无效")
|
|
|
@Parameter(name = "rand_code", description = "验证码", required = true, in = ParameterIn.QUERY)
|
|
|
@@ -118,34 +114,6 @@ public class PeopleAction extends BaseAction {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "微信-登录")
|
|
|
- @Parameters({
|
|
|
- @Parameter(name = "peoplePassword", description = "用户密码", required = true, in = ParameterIn.QUERY),
|
|
|
- @Parameter(name = "peopleName", description = "登录帐号", required = true, in = ParameterIn.QUERY),
|
|
|
- })
|
|
|
- @PostMapping(value = "/wx_checkLogin")
|
|
|
- @ResponseBody
|
|
|
- @PeopleLogAnn(title = "登录", businessType = PeopleLogTypeEnum.LOGIN)
|
|
|
- public ResultData wxCheckLogin(String code, HttpServletRequest request,
|
|
|
- HttpServletResponse response) {
|
|
|
- return Optional.ofNullable(code)
|
|
|
- .map(c -> "https://api.weixin.qq.com/sns/jscode2session?appid=wx0a115eb69d6e9359&secret=d906c8ca51acfd61e13dd61b62364050&js_code=" + c + "&grant_type=authorization_code")
|
|
|
- .map(HttpUtil::get)
|
|
|
- .map(JSONObject::new)
|
|
|
- .map(json -> json.getStr("openid"))
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .map(openid -> {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("openid", openid);
|
|
|
- PeopleEntity user = this.peopleBiz.getEntityByUserName(openid);
|
|
|
- if (user != null) {
|
|
|
- return executeLogin(openid,request,response);
|
|
|
- }
|
|
|
- return ResultData.build().success(map);
|
|
|
- })
|
|
|
- .orElse(ResultData.build().error("登录失败"));
|
|
|
- }
|
|
|
-
|
|
|
@Operation(summary = "登录验证,登录必须存在验证码")
|
|
|
@Parameters({
|
|
|
@Parameter(name = "peoplePassword", description = "用户密码", required = true, in = ParameterIn.QUERY),
|
|
|
@@ -286,56 +254,6 @@ public class PeopleAction extends BaseAction {
|
|
|
return ResultData.build().error();
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "微信-用户注册")
|
|
|
- @Parameters({
|
|
|
- @Parameter(name = "peoplePassword", description = "登录密码", required = true, in = ParameterIn.QUERY),
|
|
|
- @Parameter(name = "peopleCode", description = "用户随机验证码", required = true, in = ParameterIn.QUERY),
|
|
|
- @Parameter(name = "peoplePhone", description = "用户电话", required = false, in = ParameterIn.QUERY),
|
|
|
- @Parameter(name = "peopleMail", description = "用户邮箱", required = false, in = ParameterIn.QUERY),
|
|
|
- @Parameter(name = "peopleName", description = "登录帐号", required = false, in = ParameterIn.QUERY),
|
|
|
- })
|
|
|
- @PostMapping(value = "/wx_register")
|
|
|
- @ResponseBody
|
|
|
- public ResultData wxRegister(@RequestBody PeopleBean people, HttpServletRequest request,
|
|
|
- HttpServletResponse response) {
|
|
|
- people.setPeoplePassword(RandomUtil.randomString(8));
|
|
|
- ResultData register = register(people, request, response);
|
|
|
- if (register.isSuccess()) {
|
|
|
- return executeLogin(people.getPeopleName(),request,response);
|
|
|
- }
|
|
|
- return register;
|
|
|
- }
|
|
|
-
|
|
|
- private ResultData executeLogin(String openid,HttpServletRequest request, HttpServletResponse response) {
|
|
|
- Subject subject = SecurityUtils.getSubject();
|
|
|
- WxCustomUserNamePasswordToken cupt = new WxCustomUserNamePasswordToken(openid);
|
|
|
- try {
|
|
|
- LOG.debug("people 尝试登陆");
|
|
|
- subject.login(cupt);
|
|
|
- LOG.debug("people 登陆成功");
|
|
|
- ResultData info = action.info(request, response);
|
|
|
- if (info.isSuccess()) {
|
|
|
- Map data = info.getData(Map.class);
|
|
|
- PeopleBean tempPeople = new PeopleBean();
|
|
|
- tempPeople.setId(peopleEntity.getId());
|
|
|
- tempPeople.setPeopleName(peopleEntity.getPeopleName());
|
|
|
- tempPeople.setPeoplePhone(peopleEntity.getPeoplePhone());
|
|
|
- tempPeople.setPuIcon(peopleEntity.getPuIcon());
|
|
|
- tempPeople.setPuNickname(peopleEntity.getPuNickname());
|
|
|
- return ResultData.build().success(tempPeople);
|
|
|
- }
|
|
|
- return info;
|
|
|
- } catch (Exception e) {
|
|
|
- LOG.debug("people 登陆失败");
|
|
|
- if (e.getCause() instanceof BusinessException) {
|
|
|
- throw (BusinessException) e.getCause();
|
|
|
- }
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return ResultData.build().error(
|
|
|
- this.getResString("err.error", this.getResString("people.no.exist")));
|
|
|
- }
|
|
|
-
|
|
|
@Operation(summary = "用户注册,用户可以根据用名称、手机号、邮箱进行注册")
|
|
|
@Parameters({
|
|
|
@Parameter(name = "peoplePassword", description = "登录密码", required = true, in = ParameterIn.QUERY),
|