|
@@ -8,9 +8,11 @@ import com.storlead.framework.auth.jwt.JwtUtil;
|
|
|
import com.storlead.framework.auth.vo.LoginUser;
|
|
import com.storlead.framework.auth.vo.LoginUser;
|
|
|
import com.storlead.framework.auth.vo.MenuPermis;
|
|
import com.storlead.framework.auth.vo.MenuPermis;
|
|
|
import com.storlead.framework.common.constant.CommonConstant;
|
|
import com.storlead.framework.common.constant.CommonConstant;
|
|
|
|
|
+import com.storlead.framework.common.constant.DefContants;
|
|
|
import com.storlead.framework.common.constant.RedisKeySaltConstant;
|
|
import com.storlead.framework.common.constant.RedisKeySaltConstant;
|
|
|
import com.storlead.framework.common.ecode.BCryptPasswordEncoder;
|
|
import com.storlead.framework.common.ecode.BCryptPasswordEncoder;
|
|
|
import com.storlead.framework.common.result.Result;
|
|
import com.storlead.framework.common.result.Result;
|
|
|
|
|
+import com.storlead.framework.common.util.ConvertUtils;
|
|
|
import com.storlead.framework.common.util.MD5Util;
|
|
import com.storlead.framework.common.util.MD5Util;
|
|
|
import com.storlead.framework.common.util.RsaUtils;
|
|
import com.storlead.framework.common.util.RsaUtils;
|
|
|
import com.storlead.framework.common.util.sso.CryptoZipUtil;
|
|
import com.storlead.framework.common.util.sso.CryptoZipUtil;
|
|
@@ -29,6 +31,7 @@ import com.storlead.user.pojo.dto.UserLoginDTO;
|
|
|
import com.storlead.user.pojo.entity.DeptEntity;
|
|
import com.storlead.user.pojo.entity.DeptEntity;
|
|
|
import com.storlead.user.pojo.entity.JobEntity;
|
|
import com.storlead.user.pojo.entity.JobEntity;
|
|
|
import com.storlead.user.pojo.entity.UserEntity;
|
|
import com.storlead.user.pojo.entity.UserEntity;
|
|
|
|
|
+import com.storlead.user.pojo.entity.UserForm;
|
|
|
import com.storlead.user.service.IDepartService;
|
|
import com.storlead.user.service.IDepartService;
|
|
|
import com.storlead.user.service.IJobService;
|
|
import com.storlead.user.service.IJobService;
|
|
|
import com.storlead.user.service.IUserService;
|
|
import com.storlead.user.service.IUserService;
|
|
@@ -39,6 +42,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -91,14 +95,14 @@ public class LoginApiController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private CorpWeChatService corpWeChatService;
|
|
private CorpWeChatService corpWeChatService;
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/redirect")
|
|
|
|
|
|
|
+ @PostMapping(value = "/redirect")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public Object redirect(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
public Object redirect(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
response.sendRedirect("http://www.baidu.com");
|
|
response.sendRedirect("http://www.baidu.com");
|
|
|
return Result.ok("");
|
|
return Result.ok("");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
|
|
|
|
|
+ @PostMapping(value = "/login")
|
|
|
@ApiOperation(value = "用户登录接口", notes = "用户登录接口")
|
|
@ApiOperation(value = "用户登录接口", notes = "用户登录接口")
|
|
|
public Result login(@RequestBody UserLoginDTO loginDTO) {
|
|
public Result login(@RequestBody UserLoginDTO loginDTO) {
|
|
|
|
|
|
|
@@ -293,6 +297,66 @@ public class LoginApiController {
|
|
|
return Result.ok(obj);
|
|
return Result.ok(obj);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @ApiOperation("修改密码")
|
|
|
|
|
+ @PostMapping("/modifyPass")
|
|
|
|
|
+ public Object updateUserPass(@RequestBody @Validated UserForm param) {
|
|
|
|
|
+ return sysUserService.updateUserPass(param);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 退出登录
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping(value = "/logout")
|
|
|
|
|
+ @ApiOperation(value = "用户退出登录接口", notes = "用户退出登录接口")
|
|
|
|
|
+ public Result<Object> logout(HttpServletRequest request) {
|
|
|
|
|
+ //用户退出逻辑
|
|
|
|
|
+ String token = request.getHeader(DefContants.ACCESS_TOKEN);
|
|
|
|
|
+ if(ConvertUtils.isEmpty(token)) {
|
|
|
|
|
+ return Result.error("退出登录失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean del = redisService.deleteObject(token);
|
|
|
|
|
+ if (del) {
|
|
|
|
|
+ return Result.ok("退出登录成功!");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Object obj = redisService.getCacheObject(token);
|
|
|
|
|
+ if (obj == null) {
|
|
|
|
|
+ return Result.error("退出登录成功!");
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result.error("退出登录失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/getUserBaseInfo")
|
|
|
|
|
+ @ApiOperation(value = "根据token获取用户基本信息", notes = "根据token获取用户基本信息(header中传token)")
|
|
|
|
|
+ public Result<JSONObject> getUserBaseInfo(HttpServletRequest request) {
|
|
|
|
|
+
|
|
|
|
|
+ LoginUser loginUser = LoginUserUtil.getLoginUser();
|
|
|
|
|
+ // 生成token
|
|
|
|
|
+ Result<JSONObject> result = new Result<JSONObject>();
|
|
|
|
|
+ //用户退出逻辑
|
|
|
|
|
+ String token = request.getHeader(DefContants.ACCESS_TOKEN);
|
|
|
|
|
+ UserEntity sysUser = sysUserService.getUserByName(loginUser.getUserName());
|
|
|
|
|
+ // 获取用户部门信息
|
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
|
+ DeptEntity dept = departService.getById(sysUser.getDeptId());
|
|
|
|
|
+ obj.put("dept", dept);
|
|
|
|
|
+ obj.put("userInfo", sysUser);
|
|
|
|
|
+ result.setResult(obj);
|
|
|
|
|
+ result.success("登录成功");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@RequestMapping(value = "/external_login", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/external_login", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "用户登录接口", notes = "用户登录接口")
|
|
@ApiOperation(value = "用户登录接口", notes = "用户登录接口")
|
|
|
public Result externalLogin(@RequestBody UserLoginDTO loginDTO) {
|
|
public Result externalLogin(@RequestBody UserLoginDTO loginDTO) {
|