1.添加修改求职者密码
2.添加修改管理员修改个人和企业密码接口 3.添加启用和禁用企业
This commit is contained in:
@@ -188,6 +188,7 @@ public class AppUserController extends BaseController
|
||||
public AjaxResult editUserSafety(@RequestBody AppUser appUser)
|
||||
{
|
||||
appUser.setUserId(SiteSecurityUtils.getUserId());
|
||||
appUser.setLcUserid(SiteSecurityUtils.getlcUserid());
|
||||
return AjaxResult.success(appUserService.editUserSafety(appUser));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.ruoyi.common.core.domain.entity.AppUserShow;
|
||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.SiteSecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -275,4 +274,65 @@ public class CmsAppUserController extends BaseController
|
||||
}
|
||||
return toAjax(appReviewJobService.insertAppReviewJob(appReviewJob));
|
||||
}
|
||||
|
||||
@ApiOperation("求职者求职安全保障")
|
||||
@PreAuthorize("@ss.hasPermi('cms:appUser:editUserSafety')")
|
||||
@PostMapping("/editUserSafety")
|
||||
public AjaxResult editUserSafety(@RequestBody AppUser appUser)
|
||||
{
|
||||
if(!SecurityUtils.isLogin()){
|
||||
return error("未登录");
|
||||
}
|
||||
appUser.setUserId(SecurityUtils.getAppuserId());
|
||||
appUser.setLcUserid(SecurityUtils.getlcUserid());
|
||||
return AjaxResult.success(appUserService.editUserSafety(appUser));
|
||||
}
|
||||
|
||||
@ApiOperation("浪潮修改密码")
|
||||
@PreAuthorize("@ss.hasPermi('cms:appUser:resetLcPsw')")
|
||||
@PostMapping("/resetLcPsw")
|
||||
public AjaxResult resetLcPsw(@RequestBody AppUser appUser){
|
||||
if (appUser == null) {
|
||||
return AjaxResult.error("请求参数不能为空");
|
||||
}
|
||||
if(!SecurityUtils.isLogin()){
|
||||
return error("未登录");
|
||||
}
|
||||
if(SecurityUtils.getlcUserid()==null){
|
||||
return error("门户会话失效,请重新在门户登录");
|
||||
}
|
||||
if(appUser.getUserId()==null){
|
||||
return error("用户id为空!");
|
||||
}
|
||||
if(StringUtils.isBlank(appUser.getPassword())){
|
||||
return error("密码为空!");
|
||||
}
|
||||
appUser.setLcUserid(SecurityUtils.getlcUserid());
|
||||
appUserService.resetLcPsw(appUser);
|
||||
return success("密码重置成功");
|
||||
}
|
||||
|
||||
@ApiOperation("浪潮启用和停用企业")
|
||||
@PreAuthorize("@ss.hasPermi('cms:appUser:changeLcCompanyStatus')")
|
||||
@PostMapping("/changeLcCompanyStatus")
|
||||
public AjaxResult changeLcCompanyStatus(@RequestBody AppUser appUser){
|
||||
if (appUser == null) {
|
||||
return AjaxResult.error("请求参数不能为空");
|
||||
}
|
||||
if(!SecurityUtils.isLogin()){
|
||||
return error("未登录");
|
||||
}
|
||||
if(SecurityUtils.getlcUserid()==null){
|
||||
return error("门户会话失效,请重新在门户登录");
|
||||
}
|
||||
if(appUser.getUserId()==null){
|
||||
return error("用户id为空!");
|
||||
}
|
||||
if(StringUtils.isBlank(appUser.getStatus())){
|
||||
return error("状态为空!");
|
||||
}
|
||||
appUser.setLcUserid(SecurityUtils.getlcUserid());
|
||||
appUserService.changeLcCompanyStatus(appUser);
|
||||
return success("密码重置成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +85,8 @@ public interface IAppUserService
|
||||
public List<AppUserShow> selectUserApplyList(AppUser appUser);
|
||||
|
||||
int editUserSafety(AppUser appUser);
|
||||
|
||||
void resetLcPsw(AppUser appUser);
|
||||
|
||||
void changeLcCompanyStatus(AppUser appUser);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ package com.ruoyi.cms.service.impl;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cms.util.http.HttpClientUtils;
|
||||
import com.ruoyi.cms.util.http.JsonUtil;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.domain.entity.MyChart;
|
||||
import com.ruoyi.common.core.domain.entity.File;
|
||||
@@ -58,6 +59,12 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
//互联网修改个人信息
|
||||
@Value("${lc_web_auth.editUserInfoUrl}")
|
||||
String WEB_UPDATE_USER_INFO;
|
||||
//修改密码接口
|
||||
@Value("${lc_cms_auth.resrtPwdUrl}")
|
||||
String JG_RESET_PASSWORD_URL;
|
||||
//启用和停用企业
|
||||
@Value("${lc_cms_auth.changeStatusUrl}")
|
||||
String JG_UPDATE_COMPANY_URL;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@@ -539,7 +546,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
public AppUser getUserInfo() {
|
||||
//查询用户信息
|
||||
LoginUser loginUser=SecurityUtils.getLoginUser();
|
||||
System.out.println("loginUser========================"+JSON.toJSONString(loginUser));
|
||||
System.out.println("loginUser========================"+ JSON.toJSONString(loginUser));
|
||||
SysUser sysUser=loginUser.getUser();
|
||||
System.out.println("sysUser========================"+JSON.toJSONString(sysUser));
|
||||
AppUser appUser=selectAppuserByIdcard(sysUser.getIdCard());
|
||||
@@ -648,28 +655,59 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
|
||||
@Override
|
||||
public int editUserSafety(AppUser appUser) {
|
||||
appUserMapper.updateById(appUser);
|
||||
String lcUserToken=redisCache.getCacheObject(CacheConstants.LC_HLW_TOKEN+appUser.getUserId());
|
||||
int i=appUserMapper.updateById(appUser);
|
||||
String lcUserToken=redisCache.getCacheObject(CacheConstants.LC_HLW_TOKEN+appUser.getLcUserid());
|
||||
if(StringUtils.isBlank(lcUserToken)){
|
||||
throw new RuntimeException("token已失效");
|
||||
}
|
||||
//修改门户个人信息
|
||||
JSONObject pJson = new JSONObject();
|
||||
if (StringUtils.isNotBlank(appUser.getEmail())) {
|
||||
pJson.put("personEmail", appUser.getEmail());
|
||||
pJson.put("email", appUser.getEmail());
|
||||
}
|
||||
if (StringUtils.isNotBlank(appUser.getPhone())) {
|
||||
pJson.put("personPhone", appUser.getPhone());
|
||||
pJson.put("phonenumber", appUser.getPhone());
|
||||
}
|
||||
if (StringUtils.isNotBlank(appUser.getPassword())) {
|
||||
pJson.put("password", appUser.getPassword());
|
||||
}
|
||||
String result=httpClientUtils.sendHttpPost(WEB_UPDATE_USER_INFO,lcUserToken,pJson.toJSONString());
|
||||
if (StringUtils.isBlank(result)) {
|
||||
throw new RuntimeException("调用门户修改用户信息接口响应为空");
|
||||
}
|
||||
JSONObject json = JSONObject.parseObject(result);
|
||||
System.out.println("门户修改个人信息返回:"+json);
|
||||
return 0;
|
||||
JSONObject respJson = JsonUtil.parsePortalResponse(result, "调用修改个人信息接口");
|
||||
JSONObject data = respJson.getJSONObject("data");
|
||||
System.out.println(data);
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetLcPsw(AppUser appUser) {
|
||||
String lcUserToken=redisCache.getCacheObject(CacheConstants.LC_HLW_TOKEN+appUser.getLcUserid());
|
||||
if(StringUtils.isBlank(lcUserToken)){
|
||||
throw new RuntimeException("token已失效");
|
||||
}
|
||||
//修改密码
|
||||
JSONObject pJson = new JSONObject();
|
||||
pJson.put("userId", appUser.getUserId());
|
||||
pJson.put("password", appUser.getPassword());
|
||||
String result=httpClientUtils.sendHttpPost(JG_RESET_PASSWORD_URL,lcUserToken,pJson.toJSONString());
|
||||
JSONObject respJson = JsonUtil.parsePortalResponse(result, "调用重置密码接口");
|
||||
JSONObject data = respJson.getJSONObject("data");
|
||||
System.out.println(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeLcCompanyStatus(AppUser appUser) {
|
||||
String lcUserToken=redisCache.getCacheObject(CacheConstants.LC_HLW_TOKEN+appUser.getLcUserid());
|
||||
if(StringUtils.isBlank(lcUserToken)){
|
||||
throw new RuntimeException("token已失效");
|
||||
}
|
||||
//启用禁用
|
||||
JSONObject pJson = new JSONObject();
|
||||
pJson.put("userId", appUser.getUserId());
|
||||
pJson.put("status", appUser.getStatus());
|
||||
String result=httpClientUtils.sendHttpPost(JG_UPDATE_COMPANY_URL,lcUserToken,pJson.toJSONString());
|
||||
JSONObject respJson = JsonUtil.parsePortalResponse(result, "调用停用和启用企业接口");
|
||||
JSONObject data = respJson.getJSONObject("data");
|
||||
System.out.println(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.cms.util.http;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
public class JsonUtil {
|
||||
|
||||
/**
|
||||
* 解析门户接口返回并统一校验
|
||||
* @param result 接口原始响应字符串
|
||||
* @param apiDesc 接口业务描述(如:修改用户邮箱、查询用户信息)
|
||||
* @return 解析后的JSONObject
|
||||
*/
|
||||
public static JSONObject parsePortalResponse(String result, String apiDesc) {
|
||||
// 空响应校验
|
||||
if (StrUtil.isBlank(result)) {
|
||||
throw new RuntimeException(apiDesc + "接口调用无返回数据,请检查服务连通性");
|
||||
}
|
||||
|
||||
// 2. JSON解析
|
||||
JSONObject respJson;
|
||||
try {
|
||||
respJson = JSON.parseObject(result);
|
||||
System.out.println(apiDesc + "返回:" + respJson);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(apiDesc + "接口返回数据格式异常,原始返回:" + result, e);
|
||||
}
|
||||
|
||||
//拦截404/500等SpringBoot错误体
|
||||
if (respJson.containsKey("status") && respJson.containsKey("error")) {
|
||||
Integer httpStatus = respJson.getInteger("status");
|
||||
String errorMsg = respJson.getString("error");
|
||||
String path = respJson.getString("path");
|
||||
String errTemplate = "%s接口访问失败,HTTP状态码:%s,错误:%s,请求路径:%s,请核对接口地址是否正确";
|
||||
throw new RuntimeException(String.format(errTemplate, apiDesc, httpStatus, errorMsg, path));
|
||||
}
|
||||
|
||||
//校验业务code=200
|
||||
Integer code = respJson.getInteger("code");
|
||||
if (!Integer.valueOf(200).equals(code)) {
|
||||
String msg = respJson.getString("msg");
|
||||
String tip = StrUtil.isNotBlank(msg) ? msg : "未知业务异常";
|
||||
throw new RuntimeException(apiDesc + "失败:" + tip);
|
||||
}
|
||||
|
||||
return respJson;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user