diff --git a/db/2pigxx.sql b/db/2pigxx.sql index 2df352ac7..a689e26f1 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -49,7 +49,7 @@ DROP TABLE IF EXISTS `sys_dept`; CREATE TABLE `sys_dept` ( `dept_id` int(20) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL COMMENT '部门名称', - `sort` int(11) DEFAULT NULL COMMENT '排序', + `sort` int(11) DEFAULT '1' COMMENT '排序', `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `del_flag` char(1) DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常', @@ -62,7 +62,7 @@ CREATE TABLE `sys_dept` ( -- Records of `sys_dept` -- ---------------------------- BEGIN; -INSERT INTO `sys_dept` VALUES ('1', '山东', '1', '2018-01-22 19:00:23', '2019-05-18 14:56:06', '0', '0', '1'), ('2', '沙县国际', '2', '2018-01-22 19:00:38', '2019-05-18 14:12:07', '0', '0', '1'), ('3', '潍坊', '3', '2018-01-22 19:00:44', '2019-05-18 14:56:11', '0', '1', '1'), ('4', '高新', '4', '2018-01-22 19:00:52', '2019-05-18 14:56:09', '0', '3', '1'), ('5', '院校', '5', '2018-01-22 19:00:57', '2019-05-18 14:56:13', '0', '4', '1'), ('6', '潍院', '6', '2018-01-22 19:01:06', '2019-05-18 14:56:16', '1', '5', '1'), ('7', '山东沙县', '7', '2018-01-22 19:01:57', '2019-05-18 14:12:17', '0', '2', '1'), ('8', '潍坊沙县', '8', '2018-01-22 19:02:03', '2019-05-18 14:12:19', '0', '7', '1'), ('9', '高新沙县', '9', '2018-01-22 19:02:14', '2019-05-18 14:12:22', '1', '8', '1'), ('10', '租户2', '1', '2018-11-18 13:27:11', '2019-05-18 14:12:31', '0', '0', '2'), ('11', '院校沙县', '2', '2018-12-10 21:19:26', '2019-05-18 14:12:33', '0', '8', '1'), ('12', '小院沙县', '3', '2019-04-28 17:33:31', '2019-05-18 14:12:36', '0', '11', '1'); +INSERT INTO `sys_dept` VALUES ('1', '山东', '1', '2018-01-22 19:00:23', '2019-05-18 14:56:06', '0', '0', '1'), ('2', '沙县国际', '2', '2018-01-22 19:00:38', '2019-05-18 14:12:07', '0', '0', '1'), ('3', '潍坊', '3', '2018-01-22 19:00:44', '2019-05-18 14:56:11', '0', '1', '1'), ('4', '高新', '4', '2018-01-22 19:00:52', '2019-05-18 14:56:09', '0', '3', '1'), ('5', '院校', '5', '2018-01-22 19:00:57', '2019-05-18 14:56:13', '0', '4', '1'), ('6', '潍院', '6', '2018-01-22 19:01:06', '2019-05-18 14:56:16', '1', '5', '1'), ('7', '山东沙县', '7', '2018-01-22 19:01:57', '2019-05-18 14:12:17', '0', '2', '1'), ('8', '潍坊沙县', '8', '2018-01-22 19:02:03', '2019-05-18 14:12:19', '0', '7', '1'), ('9', '高新沙县', '9', '2018-01-22 19:02:14', '2019-05-18 14:12:22', '1', '8', '1'), ('10', '租户部门', '1', '2018-11-18 13:27:11', '2019-06-06 16:22:58', '0', '0', '2'), ('11', '院校沙县', '2', '2018-12-10 21:19:26', '2019-05-18 14:12:33', '0', '8', '1'), ('12', '小院沙县', '3', '2019-04-28 17:33:31', '2019-05-18 14:12:36', '0', '11', '1'); COMMIT; -- ---------------------------- @@ -289,7 +289,7 @@ CREATE TABLE `sys_role_menu` ( -- Records of `sys_role_menu` -- ---------------------------- BEGIN; -INSERT INTO `sys_role_menu` VALUES ('1', '1000'), ('1', '1100'), ('1', '1101'), ('1', '1102'), ('1', '1103'), ('1', '1200'), ('1', '1201'), ('1', '1202'), ('1', '1203'), ('1', '1300'), ('1', '1301'), ('1', '1302'), ('1', '1303'), ('1', '1304'), ('1', '1400'), ('1', '1401'), ('1', '1402'), ('1', '1403'), ('1', '1500'), ('1', '1501'), ('1', '1502'), ('1', '1503'), ('1', '2000'), ('1', '2100'), ('1', '2101'), ('1', '2200'), ('1', '2201'), ('1', '2202'), ('1', '2203'), ('1', '2210'), ('1', '2211'), ('1', '2212'), ('1', '2213'), ('1', '2300'), ('1', '2400'), ('1', '2401'), ('1', '2402'), ('1', '2403'), ('1', '2500'), ('1', '2501'), ('1', '2502'), ('1', '2503'), ('1', '2600'), ('1', '2601'), ('1', '2700'), ('1', '2800'), ('1', '2810'), ('1', '2820'), ('1', '2830'), ('1', '2840'), ('1', '2850'), ('1', '2860'), ('1', '3000'), ('1', '3100'), ('1', '3110'), ('1', '3200'), ('1', '3300'), ('1', '3400'), ('1', '3500'), ('1', '3600'), ('1', '3601'), ('1', '3620'), ('1', '3630'), ('1', '4000'), ('1', '4100'), ('1', '4101'), ('1', '4200'), ('1', '4201'), ('1', '4300'), ('1', '4301'), ('1', '4302'), ('1', '4303'), ('1', '4400'), ('1', '4401'), ('1', '6000'), ('1', '6100'), ('1', '6101'), ('1', '6102'), ('1', '6103'), ('1', '6200'), ('1', '6201'), ('1', '6202'), ('1', '6203'), ('1', '6300'), ('1', '6301'), ('1', '6302'), ('1', '6303'), ('1', '6304'), ('1', '6305'), ('1', '6400'), ('1', '6401'), ('1', '6402'), ('1', '6500'), ('1', '9999'), ('2', '1000'), ('2', '1100'), ('2', '1101'), ('2', '1102'), ('2', '1103'), ('2', '1200'), ('2', '1201'), ('2', '1202'), ('2', '1203'), ('2', '1300'), ('2', '1301'), ('2', '1302'), ('2', '1303'), ('2', '1304'), ('2', '1400'), ('2', '1401'), ('2', '1402'), ('2', '1403'); +INSERT INTO `sys_role_menu` VALUES ('1', '1000'), ('1', '1100'), ('1', '1101'), ('1', '1102'), ('1', '1103'), ('1', '1200'), ('1', '1201'), ('1', '1202'), ('1', '1203'), ('1', '1300'), ('1', '1301'), ('1', '1302'), ('1', '1303'), ('1', '1304'), ('1', '1400'), ('1', '1401'), ('1', '1402'), ('1', '1403'), ('1', '1500'), ('1', '1501'), ('1', '1502'), ('1', '1503'), ('1', '2000'), ('1', '2100'), ('1', '2101'), ('1', '2200'), ('1', '2201'), ('1', '2202'), ('1', '2203'), ('1', '2210'), ('1', '2211'), ('1', '2212'), ('1', '2213'), ('1', '2300'), ('1', '2400'), ('1', '2401'), ('1', '2402'), ('1', '2403'), ('1', '2500'), ('1', '2501'), ('1', '2502'), ('1', '2503'), ('1', '2600'), ('1', '2601'), ('1', '2700'), ('1', '2800'), ('1', '2810'), ('1', '2820'), ('1', '2830'), ('1', '2840'), ('1', '2850'), ('1', '2860'), ('1', '3000'), ('1', '3100'), ('1', '3110'), ('1', '3200'), ('1', '3300'), ('1', '3400'), ('1', '3500'), ('1', '3600'), ('1', '3601'), ('1', '3620'), ('1', '3630'), ('1', '4000'), ('1', '4100'), ('1', '4101'), ('1', '4200'), ('1', '4201'), ('1', '4300'), ('1', '4301'), ('1', '4302'), ('1', '4303'), ('1', '4400'), ('1', '4401'), ('1', '6000'), ('1', '6100'), ('1', '6101'), ('1', '6102'), ('1', '6103'), ('1', '6200'), ('1', '6201'), ('1', '6202'), ('1', '6203'), ('1', '6300'), ('1', '6301'), ('1', '6302'), ('1', '6303'), ('1', '6304'), ('1', '6305'), ('1', '6400'), ('1', '6401'), ('1', '6402'), ('1', '6500'), ('1', '9999'); COMMIT; -- ---------------------------- diff --git a/docker-compose.yml b/docker-compose.yml index 601ec505e..8bfd8b417 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -# 使用说明 V3.0.0 +# 使用说明 V3.1.0 # 1. 使用docker-compose 宿主机不需要配置host来发现 # 2. 无需修改源码,根目录 docker-compose up 即可 # 3. 静静等待服务启动 diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java index 68d5c2f34..6d9338f10 100644 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java @@ -21,10 +21,17 @@ import javax.servlet.http.HttpServletResponse; @AllArgsConstructor public class DynamicDatasourceInterceptor implements HandlerInterceptor { + /** + * TODO 根据上线文判断路由哪个数据库 + * + * @param request + * @param response + * @param handler + * @return + */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { DynamicDataSourceContextHolder.setDataSourceType(1); - log.info("数据源切换:{}", 1); return true; } diff --git a/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java b/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java index 1057d4620..2671288b9 100755 --- a/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java +++ b/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java @@ -38,102 +38,102 @@ import java.util.List; @Component public class JwtTokenUtils { - private final Logger log = LoggerFactory.getLogger(JwtTokenUtils.class); + private final Logger log = LoggerFactory.getLogger(JwtTokenUtils.class); - private static final String AUTHORITIES_KEY = "auth"; + private static final String AUTHORITIES_KEY = "auth"; - /** - * secret key - */ - private String secretKey; + /** + * secret key + */ + private String secretKey; - /** - * Token validity time(ms) - */ - private long tokenValidityInMilliseconds; + /** + * Token validity time(ms) + */ + private long tokenValidityInMilliseconds; - @PostConstruct - public void init() { - this.secretKey = "SecretKey012345678901234567890123456789012345678901234567890123456789"; - this.tokenValidityInMilliseconds = 1000 * 60 * 30L; - } + @PostConstruct + public void init() { + this.secretKey = "SecretKey012345678901234567890123456789012345678901234567890123456789"; + this.tokenValidityInMilliseconds = 1000 * 60 * 30L; + } - /** - * Create token - * - * @param authentication auth info - * @return token - */ - public String createToken(Authentication authentication) { - /** - * Current time - */ - long now = (new Date()).getTime(); - /** - * Validity date - */ - Date validity; - validity = new Date(now + this.tokenValidityInMilliseconds); + /** + * Create token + * + * @param authentication auth info + * @return token + */ + public String createToken(Authentication authentication) { + /** + * Current time + */ + long now = (new Date()).getTime(); + /** + * Validity date + */ + Date validity; + validity = new Date(now + this.tokenValidityInMilliseconds); - /** - * create token - */ - return Jwts.builder() - .setSubject(authentication.getName()) - .claim(AUTHORITIES_KEY, "") - .setExpiration(validity) - .signWith(SignatureAlgorithm.HS256, secretKey) - .compact(); - } + /** + * create token + */ + return Jwts.builder() + .setSubject(authentication.getName()) + .claim(AUTHORITIES_KEY, "") + .setExpiration(validity) + .signWith(SignatureAlgorithm.HS256, secretKey) + .compact(); + } - /** - * Get auth Info - * - * @param token token - * @return auth info - */ - public Authentication getAuthentication(String token) { - /** - * parse the payload of token - */ - Claims claims = Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(token) - .getBody(); + /** + * Get auth Info + * + * @param token token + * @return auth info + */ + public Authentication getAuthentication(String token) { + /** + * parse the payload of token + */ + Claims claims = Jwts.parser() + .setSigningKey(secretKey) + .parseClaimsJws(token) + .getBody(); - List authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY)); + List authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY)); - User principal = new User(claims.getSubject(), "", authorities); - return new UsernamePasswordAuthenticationToken(principal, "", authorities); - } + User principal = new User(claims.getSubject(), "", authorities); + return new UsernamePasswordAuthenticationToken(principal, "", authorities); + } - /** - * validate token - * - * @param token token - * @return whether valid - */ - public boolean validateToken(String token) { - try { - Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token); - return true; - } catch (SignatureException e) { - log.info("Invalid JWT signature."); - log.trace("Invalid JWT signature trace: {}", e); - } catch (MalformedJwtException e) { - log.info("Invalid JWT token."); - log.trace("Invalid JWT token trace: {}", e); - } catch (ExpiredJwtException e) { - log.info("Expired JWT token."); - log.trace("Expired JWT token trace: {}", e); - } catch (UnsupportedJwtException e) { - log.info("Unsupported JWT token."); - log.trace("Unsupported JWT token trace: {}", e); - } catch (IllegalArgumentException e) { - log.info("JWT token compact of handler are invalid."); - log.trace("JWT token compact of handler are invalid trace: {}", e); - } - return false; - } + /** + * validate token + * + * @param token token + * @return whether valid + */ + public boolean validateToken(String token) { + try { + Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token); + return true; + } catch (SecurityException e) { + log.info("Invalid JWT signature."); + log.trace("Invalid JWT signature trace: {}", e); + } catch (MalformedJwtException e) { + log.info("Invalid JWT token."); + log.trace("Invalid JWT token trace: {}", e); + } catch (ExpiredJwtException e) { + log.info("Expired JWT token."); + log.trace("Expired JWT token trace: {}", e); + } catch (UnsupportedJwtException e) { + log.info("Unsupported JWT token."); + log.trace("Unsupported JWT token trace: {}", e); + } catch (IllegalArgumentException e) { + log.info("JWT token compact of handler are invalid."); + log.trace("JWT token compact of handler are invalid trace: {}", e); + } + return false; + } } diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java index 8ef35dde0..5d08a6d57 100755 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java @@ -16,6 +16,7 @@ */ package com.pig4cloud.pigx.admin.api.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.extension.activerecord.Model; @@ -59,6 +60,7 @@ public class SysDict extends Model { /** * 是否是系统内置 */ + @TableField(value = "`system`") private String system; /** * 备注信息 diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPublicParam.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPublicParam.java index d922fe27b..73b7075ea 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPublicParam.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPublicParam.java @@ -17,6 +17,7 @@ package com.pig4cloud.pigx.admin.api.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.extension.activerecord.Model; @@ -104,6 +105,7 @@ public class SysPublicParam extends Model { * 是否是系统内置 */ @ApiModelProperty(value = "是否是系统内置") + @TableField(value = "`system`") private String system; diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java index d5383a05e..277c1493c 100755 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java @@ -21,11 +21,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pigx.admin.api.entity.SysTenant; import com.pig4cloud.pigx.admin.service.SysTenantService; +import com.pig4cloud.pigx.common.core.constant.CacheConstants; import com.pig4cloud.pigx.common.core.util.R; import com.pig4cloud.pigx.common.log.annotation.SysLog; import com.pig4cloud.pigx.common.security.annotation.Inner; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -89,6 +91,7 @@ public class SysTenantController { */ @SysLog("修改租户") @PutMapping + @CacheEvict(value = CacheConstants.TENANT_DETAILS) @PreAuthorize("@pms.hasPermission('admin_systenant_edit')") public R updateById(@RequestBody SysTenant sysTenant) { return R.ok(sysTenantService.updateById(sysTenant)); @@ -102,6 +105,7 @@ public class SysTenantController { */ @SysLog("删除租户") @DeleteMapping("/{id}") + @CacheEvict(value = CacheConstants.TENANT_DETAILS) @PreAuthorize("@pms.hasPermission('admin_systenant_del')") public R removeById(@PathVariable Integer id) { return R.ok(sysTenantService.removeById(id)); diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java index 7879ae3b9..579e46afa 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java @@ -60,7 +60,7 @@ public class UserController { SysUser user = userService.getOne(Wrappers.query() .lambda().eq(SysUser::getUsername, username)); if (user == null) { - return R.failed(Boolean.FALSE, "获取当前用户信息失败"); + return R.failed(null, "获取当前用户信息失败"); } return R.ok(userService.findUserInfo(user)); } @@ -76,7 +76,7 @@ public class UserController { SysUser user = userService.getOne(Wrappers.query() .lambda().eq(SysUser::getUsername, username)); if (user == null) { - return R.failed(Boolean.FALSE, String.format("用户信息为空 %s", username)); + return R.failed(null, String.format("用户信息为空 %s", username)); } return R.ok(userService.findUserInfo(user)); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java index 3d06fe8bc..f3d2266c2 100755 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java @@ -19,9 +19,9 @@ package com.pig4cloud.pigx.admin.service.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pigx.admin.api.entity.*; -import com.pig4cloud.pigx.admin.api.entity.SysTenant; import com.pig4cloud.pigx.admin.mapper.SysTenantMapper; import com.pig4cloud.pigx.admin.service.*; +import com.pig4cloud.pigx.common.core.constant.CacheConstants; import com.pig4cloud.pigx.common.core.constant.CommonConstants; import com.pig4cloud.pigx.common.core.constant.enums.DictTypeEnum; import com.pig4cloud.pigx.common.core.exception.CheckedException; @@ -31,10 +31,12 @@ import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.springframework.beans.BeanUtils; +import org.springframework.cache.annotation.CacheEvict; 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 springfox.documentation.annotations.Cacheable; import java.time.LocalDate; import java.util.List; @@ -70,6 +72,7 @@ public class SysTenantServiceImpl extends ServiceImpl getNormal() { return list(Wrappers.lambdaQuery() .eq(SysTenant::getStatus, CommonConstants.STATUS_NORMAL) @@ -94,6 +97,7 @@ public class SysTenantServiceImpl extends ServiceImpl