1. 初始化
This commit is contained in:
parent
838cc49d5b
commit
b7c3fc5035
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.chushang.common.core.constant;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface ServiceNameConstants {
|
||||
|
||||
String SYSTEM_SERVICE_V2 = "system-service-v2";
|
||||
|
||||
String MANAGER_SERVICE = "manager-service";
|
||||
}
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
package com.chushang.common.core.constant;
|
||||
|
||||
/**
|
||||
* @author by zhaowenyuan create 2022/7/26 19:01
|
||||
*/
|
||||
public interface UnityLanguageConstants {
|
||||
//
|
||||
// 摘要:
|
||||
// Afrikaans.
|
||||
int Afrikaans = 0;
|
||||
//
|
||||
// 摘要:
|
||||
// Arabic.
|
||||
int Arabic = 1;
|
||||
//
|
||||
// 摘要:
|
||||
// Basque.
|
||||
int Basque = 2;
|
||||
//
|
||||
// 摘要:
|
||||
// Belarusian.
|
||||
int Belarusian = 3;
|
||||
//
|
||||
// 摘要:
|
||||
// Bulgarian.
|
||||
int Bulgarian = 4;
|
||||
//
|
||||
// 摘要:
|
||||
// Catalan.
|
||||
int Catalan = 5;
|
||||
//
|
||||
// 摘要:
|
||||
// Chinese.
|
||||
int Chinese = 6;
|
||||
//
|
||||
// 摘要:
|
||||
// Czech.
|
||||
int Czech = 7;
|
||||
//
|
||||
// 摘要:
|
||||
// Danish.
|
||||
int Danish = 8;
|
||||
//
|
||||
// 摘要:
|
||||
// Dutch.
|
||||
int Dutch = 9;
|
||||
//
|
||||
// 摘要:
|
||||
// English.
|
||||
int English = 10;
|
||||
//
|
||||
// 摘要:
|
||||
// Estonian.
|
||||
int Estonian = 11;
|
||||
//
|
||||
// 摘要:
|
||||
// Faroese.
|
||||
int Faroese = 12;
|
||||
//
|
||||
// 摘要:
|
||||
// Finnish.
|
||||
int Finnish = 13;
|
||||
//
|
||||
// 摘要:
|
||||
// French.
|
||||
int French = 14;
|
||||
//
|
||||
// 摘要:
|
||||
// German.
|
||||
int German = 15;
|
||||
//
|
||||
// 摘要:
|
||||
// Greek.
|
||||
int Greek = 16;
|
||||
//
|
||||
// 摘要:
|
||||
// Hebrew.
|
||||
int Hebrew = 17;
|
||||
int Hugarian = 18;
|
||||
//
|
||||
// 摘要:
|
||||
// Hungarian.
|
||||
int Hungarian = 18;
|
||||
//
|
||||
// 摘要:
|
||||
// Icelandic.
|
||||
int Icelandic = 19;
|
||||
//
|
||||
// 摘要:
|
||||
// Indonesian.
|
||||
int Indonesian = 20;
|
||||
//
|
||||
// 摘要:
|
||||
// Italian.
|
||||
int Italian = 21;
|
||||
//
|
||||
// 摘要:
|
||||
// Japanese.
|
||||
int Japanese = 22;
|
||||
//
|
||||
// 摘要:
|
||||
// Korean.
|
||||
int Korean = 23;
|
||||
//
|
||||
// 摘要:
|
||||
// Latvian.
|
||||
int Latvian = 24;
|
||||
//
|
||||
// 摘要:
|
||||
// Lithuanian.
|
||||
int Lithuanian = 25;
|
||||
//
|
||||
// 摘要:
|
||||
// Norwegian.
|
||||
int Norwegian = 26;
|
||||
//
|
||||
// 摘要:
|
||||
// Polish.
|
||||
int Polish = 27;
|
||||
//
|
||||
// 摘要:
|
||||
// Portuguese.
|
||||
int Portuguese = 28;
|
||||
//
|
||||
// 摘要:
|
||||
// Romanian.
|
||||
int Romanian = 29;
|
||||
//
|
||||
// 摘要:
|
||||
// Russian.
|
||||
int Russian = 30;
|
||||
//
|
||||
// 摘要:
|
||||
// Serbo-Croatian.
|
||||
int SerboCroatian = 31;
|
||||
//
|
||||
// 摘要:
|
||||
// Slovak.
|
||||
int Slovak = 32;
|
||||
//
|
||||
// 摘要:
|
||||
// Slovenian.
|
||||
int Slovenian = 33;
|
||||
//
|
||||
// 摘要:
|
||||
// Spanish.
|
||||
int Spanish = 34;
|
||||
//
|
||||
// 摘要:
|
||||
// Swedish.
|
||||
int Swedish = 35;
|
||||
//
|
||||
// 摘要:
|
||||
// Thai.
|
||||
int Thai = 36;
|
||||
//
|
||||
// 摘要:
|
||||
// Turkish.
|
||||
int Turkish = 37;
|
||||
//
|
||||
// 摘要:
|
||||
// Ukrainian.
|
||||
int Ukrainian = 38;
|
||||
//
|
||||
// 摘要:
|
||||
// Vietnamese.
|
||||
int Vietnamese = 39;
|
||||
//
|
||||
// 摘要:
|
||||
// ChineseSimplified.
|
||||
int ChineseSimplified = 40;
|
||||
//
|
||||
// 摘要:
|
||||
// ChineseTraditional.
|
||||
int ChineseTraditional = 41;
|
||||
//
|
||||
// 摘要:
|
||||
// Unknown.
|
||||
int Unknown = 42;
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@ package com.chushang.common.core.exception;
|
|||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 😴2018年06月22日16:21:57
|
||||
|
|
@ -25,6 +27,7 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
public class CheckedException extends RuntimeException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CheckedException(String message) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.chushang.common.core.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 内部认证异常
|
||||
*
|
||||
|
|
@ -7,6 +9,7 @@ package com.chushang.common.core.exception;
|
|||
*/
|
||||
public class InnerAuthException extends RuntimeException
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InnerAuthException(String message)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class ResultException extends RuntimeException {
|
|||
|
||||
private String msg;
|
||||
private String code = "500";
|
||||
private String detailMsg;
|
||||
|
||||
public ResultException(String msg) {
|
||||
super(msg);
|
||||
|
|
@ -34,6 +35,16 @@ public class ResultException extends RuntimeException {
|
|||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部 展示, 应当仅用于 调试 todo 怎么做没想好
|
||||
*/
|
||||
public ResultException(String msg,String detailMsg, String code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.detailMsg = detailMsg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ResultException(EnumUtils.CodeEnum<String, String> codeEnum){
|
||||
super(codeEnum.getMsg());
|
||||
this.msg = codeEnum.getMsg();
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
package com.chushang.common.core.exception;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public final class ServiceException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
*
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public ServiceException()
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceException(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ServiceException(String message, Integer code)
|
||||
{
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDetailMessage()
|
||||
{
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public ServiceException setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServiceException setDetailMessage(String detailMessage)
|
||||
{
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.chushang.common.core.exception.auth;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 未能通过的登录认证异常
|
||||
*
|
||||
|
|
@ -7,6 +9,7 @@ package com.chushang.common.core.exception.auth;
|
|||
*/
|
||||
public class NotLoginException extends RuntimeException
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotLoginException(String message)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.chushang.common.core.exception.auth;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 未能通过的权限认证异常
|
||||
*
|
||||
|
|
@ -9,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
*/
|
||||
public class NotPermissionException extends RuntimeException
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotPermissionException(String permission)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.chushang.common.core.exception.auth;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 未能通过的角色认证异常
|
||||
*
|
||||
|
|
@ -9,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
*/
|
||||
public class NotRoleException extends RuntimeException
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotRoleException(String role)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import cn.hutool.http.HttpStatus;
|
|||
import com.chushang.common.core.exception.CheckedException;
|
||||
import com.chushang.common.core.exception.InnerAuthException;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.exception.ServiceException;
|
||||
import com.chushang.common.core.exception.auth.NotLoginException;
|
||||
import com.chushang.common.core.exception.auth.NotPermissionException;
|
||||
import com.chushang.common.core.exception.auth.NotRoleException;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
import com.chushang.common.core.web.AjaxResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -16,7 +15,6 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -63,18 +61,6 @@ public class GlobalExceptionHandler
|
|||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public AjaxResult handleServiceException(ServiceException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
Integer code = e.getCode();
|
||||
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
|
|
@ -112,7 +98,7 @@ public class GlobalExceptionHandler
|
|||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
|
||||
public AjaxResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
String message = Objects.requireNonNull(e.getBindingResult().getFieldError()).getDefaultMessage();
|
||||
|
|
@ -128,17 +114,48 @@ public class GlobalExceptionHandler
|
|||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
@org.springframework.web.bind.annotation.ExceptionHandler(ResultException.class)
|
||||
@ExceptionHandler(ResultException.class)
|
||||
public AjaxResult handlerResultException(ResultException e, HttpServletRequest request){
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
@org.springframework.web.bind.annotation.ExceptionHandler(CheckedException.class)
|
||||
@ExceptionHandler(CheckedException.class)
|
||||
public AjaxResult handlerCheckedException(CheckedException e, HttpServletRequest request){
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录异常
|
||||
*/
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public AjaxResult handlerNotLoginException(NotLoginException e, HttpServletRequest request){
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限异常
|
||||
*/
|
||||
@ExceptionHandler(NotPermissionException.class)
|
||||
public AjaxResult handlerNotPermissionException(NotPermissionException e, HttpServletRequest request){
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色异常
|
||||
*/
|
||||
@ExceptionHandler(NotRoleException.class)
|
||||
public AjaxResult handlerNotRoleException(NotRoleException e, HttpServletRequest request){
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ public class CharsetKit
|
|||
public static final String GBK = "GBK";
|
||||
|
||||
/** ISO-8859-1 */
|
||||
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
|
||||
public static final Charset CHARSET_ISO_8859_1 = StandardCharsets.ISO_8859_1;
|
||||
/** UTF-8 */
|
||||
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
|
||||
public static final Charset CHARSET_UTF_8 = StandardCharsets.UTF_8;
|
||||
/** GBK */
|
||||
public static final Charset CHARSET_GBK = Charset.forName(GBK);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.chushang.common.core.util;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -13,6 +14,7 @@ import java.util.Map;
|
|||
@Data
|
||||
public class CommonParam implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
@ -28,11 +30,13 @@ public class CommonParam implements Serializable {
|
|||
*/
|
||||
private String sortStr;
|
||||
/**
|
||||
* 额外分组选项 --> 比如需要根据国家, 或者 pid 进行分组
|
||||
* 额外分组选项
|
||||
*/
|
||||
private String groupStr;
|
||||
|
||||
|
||||
/**
|
||||
* 内部使用 sql 查询, 仅用于 角色权限所需查询, 前端不能传递
|
||||
*/
|
||||
private Map<String, Object> sqlParam;
|
||||
|
||||
public Map<String, Object> getSqlParam()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import com.alibaba.fastjson2.JSON;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
|
||||
public class IPUtils {
|
||||
|
|
|
|||
|
|
@ -14,27 +14,6 @@ import java.math.BigInteger;
|
|||
@Slf4j
|
||||
@UtilityClass
|
||||
public class IdUtils {
|
||||
|
||||
private final static String sign = "sanyi_cloud_sign";
|
||||
|
||||
private final static MD5 md5 = new MD5();
|
||||
|
||||
/**
|
||||
* 生成 19位 数值类型 id
|
||||
* 字符串转数值类型 id
|
||||
* @param str 设备 id
|
||||
* @param sign 签名
|
||||
* @return 根据设备码生成的 数值
|
||||
*/
|
||||
public synchronized static String strConvertNum(String str,String sign) {
|
||||
BigInteger bigInteger = new BigInteger(1, md5.digest(str + ":" + sign));
|
||||
return Math.abs(bigInteger.longValue()) + "";
|
||||
}
|
||||
|
||||
public synchronized static String strConvertNum(String str) {
|
||||
return strConvertNum(str, sign);
|
||||
}
|
||||
|
||||
public synchronized String getId(){
|
||||
return getId(8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import java.util.Set;
|
|||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.chushang.common.core.text.ToolUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.chushang.auth.service;
|
||||
|
||||
import com.chushang.common.core.constant.SecurityConstants;
|
||||
import com.chushang.common.core.exception.ServiceException;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.util.IPUtils;
|
||||
import com.chushang.common.core.util.IdUtils;
|
||||
import com.chushang.common.core.util.ServletUtils;
|
||||
import com.chushang.common.core.web.Result;
|
||||
import com.chushang.security.utils.SecurityUtils;
|
||||
|
|
@ -42,12 +41,12 @@ public class UserService {
|
|||
long end = System.currentTimeMillis();
|
||||
log.info("time : {}",end - start);
|
||||
if (Result.FAIL_CODE == rLoginUser.getCode()){
|
||||
throw new ServiceException(rLoginUser.getMsg());
|
||||
throw new ResultException(rLoginUser.getMsg());
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(rLoginUser) || ObjectUtils.isEmpty(rLoginUser.getData()) ){
|
||||
recordLoginInfo(username, LoginStatusEnum.LOGIN_FAIL_STATUS, "登录用户不存在");
|
||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||
throw new ResultException("登录用户:" + username + " 不存在");
|
||||
}
|
||||
LoginUser loginUser = rLoginUser.getData();
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
|
|
@ -55,13 +54,13 @@ public class UserService {
|
|||
if (!status)
|
||||
{
|
||||
recordLoginInfo(username, LoginStatusEnum.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
throw new ResultException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
// 进行比较了
|
||||
if (!SecurityUtils.matchesPassword(password, sysUser.getSalt(), sysUser.getPassword()))
|
||||
{
|
||||
recordLoginInfo(username, LoginStatusEnum.LOGIN_FAIL_STATUS, "用户密码错误");
|
||||
throw new ServiceException("用户不存在/密码错误");
|
||||
throw new ResultException("用户不存在/密码错误");
|
||||
}
|
||||
recordLoginInfo(username, LoginStatusEnum.LOGIN_SUCCESS, "登录成功");
|
||||
sysUser.setPassword("");
|
||||
|
|
@ -81,8 +80,7 @@ public class UserService {
|
|||
* @param loginStatus 状态
|
||||
* @param message 消息内容
|
||||
*/
|
||||
public void recordLoginInfo(String username, LoginStatusEnum loginStatus, String message)
|
||||
{
|
||||
public void recordLoginInfo(String username, LoginStatusEnum loginStatus, String message) {
|
||||
SysLoginInfo loginInfo = new SysLoginInfo();
|
||||
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
|
|
@ -100,11 +98,4 @@ public class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String id = IdUtils.getId(10);
|
||||
System.out.println(id);
|
||||
String s = SecurityUtils.encryptPassword("12345678", id);
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.chushang.gateway.service.ValidateCodeService;
|
|||
import com.google.code.kaptcha.Producer;
|
||||
import com.chushang.common.core.constant.Constants;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.util.IdUtils;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
import com.chushang.common.core.web.AjaxResult;
|
||||
import com.chushang.gateway.config.properties.CaptchaProperties;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.chushang.oss.service;
|
||||
|
||||
import com.chushang.common.core.util.IdUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@
|
|||
<dependency>
|
||||
<groupId>com.chushang</groupId>
|
||||
<artifactId>chushang-common-mybatis</artifactId>
|
||||
<version>${common.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chushang</groupId>
|
||||
<artifactId>chushang-common-feign</artifactId>
|
||||
<version>${common.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.chushang.system.constants;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
* @date: 2024/5/6 10:24
|
||||
*/
|
||||
public interface SystemConstants {
|
||||
String SYSTEM_SERVICE = "system-service";
|
||||
String APPLICATION_NAME = "/cs/system";
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.chushang.system.feign;
|
||||
|
||||
import com.chushang.common.core.constant.SecurityConstants;
|
||||
import com.chushang.common.core.constant.ServiceNameConstants;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
/**
|
||||
* 用于远程调用 授权
|
||||
*/
|
||||
@FeignClient(contextId = "remoteAuthDataService",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE_V2,
|
||||
path = "/sanyi/system/data"
|
||||
)
|
||||
public interface RemoteAuthDataService {
|
||||
|
||||
@PostMapping(value = "/remote/app/{appId}")
|
||||
void authData(@PathVariable(value = "appId") Integer appId,
|
||||
@SpringQueryMap Integer authType,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.chushang.system.feign;
|
||||
|
||||
import com.chushang.common.core.constant.SecurityConstants;
|
||||
import com.chushang.common.core.constant.ServiceNameConstants;
|
||||
import com.chushang.common.core.web.Result;
|
||||
import com.chushang.system.constants.SystemConstants;
|
||||
import com.chushang.system.entity.po.SysLoginInfo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -11,10 +11,11 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
|||
|
||||
/**
|
||||
* by zhaowenyuan create 2022/5/20 10:28
|
||||
* 保存登录日志信息
|
||||
*/
|
||||
@FeignClient(contextId = "remoteLoginInfoService",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE_V2,
|
||||
path = "/sanyi/system/log"
|
||||
value = SystemConstants.SYSTEM_SERVICE,
|
||||
path = SystemConstants.APPLICATION_NAME + "/log"
|
||||
)
|
||||
public interface RemoteLoginInfoService {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
package com.chushang.system.feign;
|
||||
|
||||
import com.chushang.common.core.constant.SecurityConstants;
|
||||
import com.chushang.common.core.constant.ServiceNameConstants;
|
||||
import com.chushang.common.core.web.Result;
|
||||
import com.chushang.system.constants.SystemConstants;
|
||||
import com.chushang.system.entity.vo.LoginUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
/**
|
||||
* by zhaowenyuan create 2022/5/20 10:05
|
||||
*/
|
||||
@FeignClient(contextId = "remoteUserService",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE_V2,
|
||||
path = "/sanyi/system/user"
|
||||
value = SystemConstants.SYSTEM_SERVICE,
|
||||
path = SystemConstants.APPLICATION_NAME + "/user"
|
||||
)
|
||||
public interface RemoteUserService {
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,10 @@ import com.chushang.common.core.exception.ResultException;
|
|||
import com.chushang.common.core.web.AjaxResult;
|
||||
import com.chushang.common.core.web.EnumUtils;
|
||||
import com.chushang.common.log.annotation.SysLog;
|
||||
import com.chushang.security.annotation.InnerAuth;
|
||||
import com.chushang.security.annotation.Logical;
|
||||
import com.chushang.security.annotation.RequiresPermissions;
|
||||
import com.chushang.security.utils.SecurityUtils;
|
||||
import com.chushang.system.entity.bo.DataAuth;
|
||||
import com.chushang.system.entity.enums.AuthTypeEnum;
|
||||
import com.chushang.system.feign.RemoteAuthDataService;
|
||||
import com.chushang.system.service.ISysUserDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -24,7 +21,7 @@ import java.util.Map;
|
|||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/data")
|
||||
public class SysUserDataController implements RemoteAuthDataService {
|
||||
public class SysUserDataController {
|
||||
|
||||
@Autowired
|
||||
ISysUserDataService userDataService;
|
||||
|
|
@ -63,15 +60,4 @@ public class SysUserDataController implements RemoteAuthDataService {
|
|||
{
|
||||
return AjaxResult.success( userDataService.getUserAuthData(userId, authType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@InnerAuth
|
||||
@PostMapping(value = "/remote/app/{appId}")
|
||||
public void authData(Integer appId, Integer authType, String source) {
|
||||
log.info("{}", appId);
|
||||
// 登录人id
|
||||
Integer userId = SecurityUtils.getUserId();
|
||||
|
||||
AuthTypeEnum authTypeEnum = EnumUtils.getByCode(authType, AuthTypeEnum.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.chushang.system.service;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chushang.common.core.exception.ServiceException;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.text.Convert;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
import com.chushang.common.mybatis.enums.Operator;
|
||||
|
|
@ -60,7 +60,7 @@ public interface ISysDeptService extends IService<SysDept> {
|
|||
// 如果父节点不为正常状态,则不允许新增子节点
|
||||
if (!info.getStatus())
|
||||
{
|
||||
throw new ServiceException("部门停用,不允许新增");
|
||||
throw new ResultException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
save(dept);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.chushang.system.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chushang.common.core.exception.ServiceException;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.util.SpringUtils;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
import com.chushang.system.annotation.DataScope;
|
||||
|
|
@ -54,7 +54,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
List<SysDept> deptList = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
if (CollectionUtil.isEmpty(deptList))
|
||||
{
|
||||
throw new ServiceException("没有权限访问部门数据!");
|
||||
throw new ResultException("没有权限访问部门数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.chushang.system.service.impl;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chushang.common.core.exception.ServiceException;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.util.SpringUtils;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
import com.chushang.common.core.web.AjaxResult;
|
||||
|
|
@ -93,7 +93,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
if (!SecurityUtils.isAdmin()) {
|
||||
List<SysRole> roles = baseMapper.selectRoleList(role);
|
||||
if (CollectionUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
throw new ResultException("没有权限访问角色数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
SysRole role = selectRoleById(roleId);
|
||||
|
||||
if (userRoleService.countUserRoleByRoleId(roleId) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
throw new ResultException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
// 删除角色与菜单关联
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chushang.common.core.exception.ResultException;
|
||||
import com.chushang.common.core.exception.ServiceException;
|
||||
import com.chushang.common.core.util.IdUtils;
|
||||
import com.chushang.common.core.util.SpringUtils;
|
||||
import com.chushang.common.core.web.AjaxResult;
|
||||
import com.chushang.common.mybatis.base.BaseEntity;
|
||||
import com.chushang.common.mybatis.utils.PageUtils;
|
||||
import com.chushang.security.service.TokenService;
|
||||
import com.chushang.security.utils.SecurityUtils;
|
||||
|
|
@ -95,7 +93,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
List<SysUser> users = baseMapper.selectUserList(user);
|
||||
if (ObjectUtil.isEmpty(users))
|
||||
{
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
throw new ResultException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue