修改密码问题

This commit is contained in:
wanggeng888 2021-04-12 18:23:32 +08:00
parent aa038fd207
commit 717628ed54
3 changed files with 7 additions and 11 deletions

View File

@ -107,7 +107,7 @@ public interface IApiConsts {
/** /**
* 修改密码 * 修改密码
*/ */
String UPDATE_USER_PASSWORD = "%s/resource/user/updateuserpassword"; String UPDATE_USER_PASSWORD = "%s/resource/user/updateuserpassword/%s";
/** /**
* 部门人员列表ZTree格式 * 部门人员列表ZTree格式

View File

@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.cm.common.base.AbstractService; import com.cm.common.base.AbstractService;
import com.cm.common.component.OAuthRestTemplateComponent; import com.cm.common.component.OAuthRestTemplateComponent;
import com.cm.common.config.properties.ApiPathProperties; import com.cm.common.config.properties.ApiPathProperties;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.AccessTokenException;
import com.cm.common.exception.SearchException; import com.cm.common.exception.SearchException;
import com.cm.common.plugin.IApiConsts; import com.cm.common.plugin.IApiConsts;
@ -18,14 +17,13 @@ import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.print.attribute.standard.PageRanges; import java.util.ArrayList;
import java.io.UnsupportedEncodingException; import java.util.HashMap;
import java.net.URLEncoder; import java.util.List;
import java.util.*; import java.util.Map;
/** /**
* When you feel like quitting. Think about why you started * When you feel like quitting. Think about why you started
@ -144,7 +142,7 @@ public class UserServiceImpl extends AbstractService implements IUserService {
@Override @Override
public SuccessResult updateUserPassword(Map<String, Object> params) throws AccessTokenException, SearchException { public SuccessResult updateUserPassword(Map<String, Object> params) throws AccessTokenException, SearchException {
params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken());
String result = restTemplateUtil.doPostFormNormal(String.format(IApiConsts.UPDATE_USER_PASSWORD, apiPathProperties.getUserCenter()), params); String result = restTemplateUtil.doPostFormNormal(String.format(IApiConsts.UPDATE_USER_PASSWORD, apiPathProperties.getUserCenter(), securityComponent.getCurrentUser().getUserId()), params);
updateResourceResult(result, "密码修改失败"); updateResourceResult(result, "密码修改失败");
return new SuccessResult(); return new SuccessResult();
} }

View File

@ -1,7 +1,6 @@
package com.cm.common.advice; package com.cm.common.advice;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cm.common.enums.ErrorResultCodeEnum; import com.cm.common.enums.ErrorResultCodeEnum;
import com.cm.common.exception.*; import com.cm.common.exception.*;
import com.cm.common.exception.base.SystemException; import com.cm.common.exception.base.SystemException;
@ -11,7 +10,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.authentication.InsufficientAuthenticationException; import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -77,7 +75,7 @@ public class ResponseAdvice {
result.setDetail(e.getMessage()); result.setDetail(e.getMessage());
} }
String contentType = request.getContentType(); String contentType = request.getContentType();
if (contentType != null && contentType.contains(MediaType.APPLICATION_JSON_VALUE)) { if (contentType != null && (contentType.contains(MediaType.APPLICATION_JSON_VALUE) || contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE))) {
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
response.setStatus(HttpStatus.BAD_REQUEST.value()); response.setStatus(HttpStatus.BAD_REQUEST.value());
response.getWriter().write(JSON.toJSONString(result)); response.getWriter().write(JSON.toJSONString(result));