From 717628ed54e18d473e5b6cce368920de1ca83e45 Mon Sep 17 00:00:00 2001 From: wanggeng888 <450292408@qq.com> Date: Mon, 12 Apr 2021 18:23:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cm/common/plugin/IApiConsts.java | 2 +- .../oauth/service/user/impl/UserServiceImpl.java | 12 +++++------- .../java/com/cm/common/advice/ResponseAdvice.java | 4 +--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java index f0cbade..a88edc1 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java @@ -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格式) diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java index 2269585..e711469 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject; import com.cm.common.base.AbstractService; import com.cm.common.component.OAuthRestTemplateComponent; import com.cm.common.config.properties.ApiPathProperties; -import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.SearchException; 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.SuccessResultList; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.print.attribute.standard.PageRanges; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * When you feel like quitting. Think about why you started @@ -144,7 +142,7 @@ public class UserServiceImpl extends AbstractService implements IUserService { @Override public SuccessResult updateUserPassword(Map params) throws AccessTokenException, SearchException { 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, "密码修改失败"); return new SuccessResult(); } diff --git a/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java b/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java index 54180af..b4da165 100644 --- a/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java +++ b/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java @@ -1,7 +1,6 @@ package com.cm.common.advice; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.cm.common.enums.ErrorResultCodeEnum; import com.cm.common.exception.*; import com.cm.common.exception.base.SystemException; @@ -11,7 +10,6 @@ import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; 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.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; @@ -77,7 +75,7 @@ public class ResponseAdvice { result.setDetail(e.getMessage()); } 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.setStatus(HttpStatus.BAD_REQUEST.value()); response.getWriter().write(JSON.toJSONString(result));