From a060f8d7b8d5e4b680f245973c5a86b560116a24 Mon Sep 17 00:00:00 2001 From: pig666 Date: Tue, 23 Jun 2020 17:40:26 +0800 Subject: [PATCH] :bookmark: Releasing / Version tags. 2.8 --- .../PigResourceServerAutoConfiguration.java | 14 +++++++++++++- .../pig/admin/controller/UserController.java | 2 +- .../pig/admin/service/SysUserService.java | 3 ++- .../admin/service/impl/SysUserServiceImpl.java | 16 ++++++++-------- .../service/impl/GeneratorServiceImpl.java | 2 -- pom.xml | 7 +++++++ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java index 5c5399e0..54a323a0 100644 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java @@ -24,14 +24,18 @@ import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Primary; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.client.ClientHttpResponse; import org.springframework.web.client.DefaultResponseErrorHandler; import org.springframework.web.client.RestTemplate; +import java.util.Collections; + /** * @author lengleng - * @date 2019/03/08 + * @date 2020-06-23 */ @ConfigurationPropertiesScan @ComponentScan("com.pig4cloud.pig.common.security") @@ -42,6 +46,14 @@ public class PigResourceServerAutoConfiguration { @LoadBalanced public RestTemplate lbRestTemplate() { RestTemplate restTemplate = new RestTemplate(); + + // 传递ACCEPT JSON + restTemplate.setInterceptors(Collections.singletonList((request, body, execution) -> { + request.getHeaders().set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE); + return execution.execute(request, body); + })); + + // 处理400 异常 restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override @SneakyThrows diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java index eb2f1f18..93a6cec2 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java @@ -153,7 +153,7 @@ public class UserController { @SysLog("修改个人信息") @PutMapping("/edit") public R updateUserInfo(@Valid @RequestBody UserDTO userDto) { - return R.ok(userService.updateUserInfo(userDto)); + return userService.updateUserInfo(userDto); } /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java index bd2b4aa5..f3bb8bea 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysUserService.java @@ -25,6 +25,7 @@ import com.pig4cloud.pig.admin.api.dto.UserDTO; import com.pig4cloud.pig.admin.api.dto.UserInfo; import com.pig4cloud.pig.admin.api.entity.SysUser; import com.pig4cloud.pig.admin.api.vo.UserVO; +import com.pig4cloud.pig.common.core.util.R; import java.util.List; @@ -61,7 +62,7 @@ public interface SysUserService extends IService { * @param userDto 用户信息 * @return Boolean */ - Boolean updateUserInfo(UserDTO userDto); + R updateUserInfo(UserDTO userDto); /** * 更新指定用户信息 diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java index 4dbb7b73..e0b260c8 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java @@ -36,6 +36,7 @@ import com.pig4cloud.pig.admin.mapper.SysUserMapper; import com.pig4cloud.pig.admin.service.*; import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CommonConstants; +import com.pig4cloud.pig.common.core.util.R; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -45,7 +46,6 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; import java.time.LocalDateTime; import java.util.HashSet; @@ -156,19 +156,19 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username") - public Boolean updateUserInfo(UserDTO userDto) { + public R updateUserInfo(UserDTO userDto) { UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername()); + + if (!ENCODER.matches(userDto.getPassword(), userVO.getPassword())) { + return R.failed("原密码错误,修改失败"); + } + SysUser sysUser = new SysUser(); - - Assert.notNull(userDto.getPassword(), "原密码不存在"); - Assert.notNull(userDto.getNewpassword1(), "新密码不存在"); - Assert.state(ENCODER.matches(userDto.getPassword(), userVO.getPassword()), "原密码错误,修改失败"); sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1())); - sysUser.setPhone(userDto.getPhone()); sysUser.setUserId(userVO.getUserId()); sysUser.setAvatar(userDto.getAvatar()); - return this.updateById(sysUser); + return R.ok(this.updateById(sysUser)); } @Override diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java index ed63fe56..76f37754 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java @@ -22,7 +22,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -77,7 +76,6 @@ public class GeneratorServiceImpl implements GeneratorService { List formConfList = genFormConfMapper.selectList(Wrappers.lambdaQuery() .eq(GenFormConf::getTableName, genConfig.getTableName()).orderByDesc(GenFormConf::getCreateTime)); - DynamicDataSourceContextHolder.push(genConfig.getDsName()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); diff --git a/pom.xml b/pom.xml index 842951b0..958ab9d3 100755 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,7 @@ 1.2.69 2.9.2 1.5.24 + 0.9.7.RELEASE 2.3.6.RELEASE 0.32.0 http://172.17.0.111:2375 @@ -139,6 +140,12 @@ spring-security-oauth2 ${security.oauth.version} + + + io.projectreactor.netty + reactor-netty + ${reactor.netty.version} + io.swagger