bug 修改
This commit is contained in:
parent
b376304c1a
commit
d991c59ba7
|
|
@ -176,13 +176,11 @@ public class SysLoginService {
|
||||||
private LoginUser handleMobileLogin(String mobile, long startTime) {
|
private LoginUser handleMobileLogin(String mobile, long startTime) {
|
||||||
R<LoginUser> userResult = remoteUserService.getUserInfo(mobile, SecurityConstants.INNER);
|
R<LoginUser> userResult = remoteUserService.getUserInfo(mobile, SecurityConstants.INNER);
|
||||||
validateUserResult(mobile, userResult, startTime);
|
validateUserResult(mobile, userResult, startTime);
|
||||||
|
|
||||||
LoginUser userInfo = userResult.getData();
|
LoginUser userInfo = userResult.getData();
|
||||||
SysUser user = userInfo.getSysUser();
|
SysUser user = userInfo.getSysUser();
|
||||||
validateApprovalStatus(user.getUserName(), user, startTime);
|
validateApprovalStatus(user.getUserName(), user, startTime);
|
||||||
validateIpBlacklist(user.getUserName(), startTime);
|
validateIpBlacklist(user.getUserName(), startTime);
|
||||||
validateUserStatus(user.getUserName(), user, startTime);
|
validateUserStatus(user.getUserName(), user, startTime);
|
||||||
|
|
||||||
recordLogService.saveLogs(user.getUserName(), startTime, "登陆成功", "手机号验证码登录成功", user.getUserId().toString(), "成功");
|
recordLogService.saveLogs(user.getUserName(), startTime, "登陆成功", "手机号验证码登录成功", user.getUserId().toString(), "成功");
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,53 +36,46 @@ import reactor.core.publisher.Mono;
|
||||||
*
|
*
|
||||||
* @author bonus
|
* @author bonus
|
||||||
*/
|
*/
|
||||||
public class ServletUtils
|
public class ServletUtils {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 获取String参数
|
* 获取String参数
|
||||||
*/
|
*/
|
||||||
public static String getParameter(String name)
|
public static String getParameter(String name) {
|
||||||
{
|
|
||||||
return getRequest().getParameter(name);
|
return getRequest().getParameter(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取String参数
|
* 获取String参数
|
||||||
*/
|
*/
|
||||||
public static String getParameter(String name, String defaultValue)
|
public static String getParameter(String name, String defaultValue) {
|
||||||
{
|
|
||||||
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Integer参数
|
* 获取Integer参数
|
||||||
*/
|
*/
|
||||||
public static Integer getParameterToInt(String name)
|
public static Integer getParameterToInt(String name) {
|
||||||
{
|
|
||||||
return Convert.toInt(getRequest().getParameter(name));
|
return Convert.toInt(getRequest().getParameter(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Integer参数
|
* 获取Integer参数
|
||||||
*/
|
*/
|
||||||
public static Integer getParameterToInt(String name, Integer defaultValue)
|
public static Integer getParameterToInt(String name, Integer defaultValue) {
|
||||||
{
|
|
||||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Boolean参数
|
* 获取Boolean参数
|
||||||
*/
|
*/
|
||||||
public static Boolean getParameterToBool(String name)
|
public static Boolean getParameterToBool(String name) {
|
||||||
{
|
|
||||||
return Convert.toBool(getRequest().getParameter(name));
|
return Convert.toBool(getRequest().getParameter(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Boolean参数
|
* 获取Boolean参数
|
||||||
*/
|
*/
|
||||||
public static Boolean getParameterToBool(String name, Boolean defaultValue)
|
public static Boolean getParameterToBool(String name, Boolean defaultValue) {
|
||||||
{
|
|
||||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,8 +85,7 @@ public class ServletUtils
|
||||||
* @param request 请求对象{@link ServletRequest}
|
* @param request 请求对象{@link ServletRequest}
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public static Map<String, String[]> getParams(ServletRequest request)
|
public static Map<String, String[]> getParams(ServletRequest request) {
|
||||||
{
|
|
||||||
final Map<String, String[]> map = request.getParameterMap();
|
final Map<String, String[]> map = request.getParameterMap();
|
||||||
return Collections.unmodifiableMap(map);
|
return Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
@ -104,11 +96,9 @@ public class ServletUtils
|
||||||
* @param request 请求对象{@link ServletRequest}
|
* @param request 请求对象{@link ServletRequest}
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public static Map<String, String> getParamMap(ServletRequest request)
|
public static Map<String, String> getParamMap(ServletRequest request) {
|
||||||
{
|
|
||||||
Map<String, String> params = new HashMap<>(16);
|
Map<String, String> params = new HashMap<>(16);
|
||||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet())
|
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
||||||
{
|
|
||||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
|
|
@ -117,14 +107,10 @@ public class ServletUtils
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
public static HttpServletRequest getRequest()
|
public static HttpServletRequest getRequest() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return getRequestAttributes().getRequest();
|
return getRequestAttributes().getRequest();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -132,14 +118,10 @@ public class ServletUtils
|
||||||
/**
|
/**
|
||||||
* 获取response
|
* 获取response
|
||||||
*/
|
*/
|
||||||
public static HttpServletResponse getResponse()
|
public static HttpServletResponse getResponse() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return getRequestAttributes().getResponse();
|
return getRequestAttributes().getResponse();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,42 +129,32 @@ public class ServletUtils
|
||||||
/**
|
/**
|
||||||
* 获取session
|
* 获取session
|
||||||
*/
|
*/
|
||||||
public static HttpSession getSession()
|
public static HttpSession getSession() {
|
||||||
{
|
|
||||||
return getRequest().getSession();
|
return getRequest().getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServletRequestAttributes getRequestAttributes()
|
public static ServletRequestAttributes getRequestAttributes() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||||
return (ServletRequestAttributes) attributes;
|
return (ServletRequestAttributes) attributes;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHeader(HttpServletRequest request, String name)
|
public static String getHeader(HttpServletRequest request, String name) {
|
||||||
{
|
|
||||||
String value = request.getHeader(name);
|
String value = request.getHeader(name);
|
||||||
if (StringUtils.isEmpty(value))
|
if (StringUtils.isEmpty(value)) {
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
return urlDecode(value);
|
return urlDecode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getHeaders(HttpServletRequest request)
|
public static Map<String, String> getHeaders(HttpServletRequest request) {
|
||||||
{
|
|
||||||
Map<String, String> map = new LinkedCaseInsensitiveMap<>();
|
Map<String, String> map = new LinkedCaseInsensitiveMap<>();
|
||||||
Enumeration<String> enumeration = request.getHeaderNames();
|
Enumeration<String> enumeration = request.getHeaderNames();
|
||||||
if (enumeration != null)
|
if (enumeration != null) {
|
||||||
{
|
while (enumeration.hasMoreElements()) {
|
||||||
while (enumeration.hasMoreElements())
|
|
||||||
{
|
|
||||||
String key = enumeration.nextElement();
|
String key = enumeration.nextElement();
|
||||||
String value = request.getHeader(key);
|
String value = request.getHeader(key);
|
||||||
map.put(key, value);
|
map.put(key, value);
|
||||||
|
|
@ -195,19 +167,15 @@ public class ServletUtils
|
||||||
* 将字符串渲染到客户端
|
* 将字符串渲染到客户端
|
||||||
*
|
*
|
||||||
* @param response 渲染对象
|
* @param response 渲染对象
|
||||||
* @param string 待渲染的字符串
|
* @param string 待渲染的字符串
|
||||||
*/
|
*/
|
||||||
public static void renderString(HttpServletResponse response, String string)
|
public static void renderString(HttpServletResponse response, String string) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.getWriter().print(string);
|
response.getWriter().print(string);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -218,27 +186,23 @@ public class ServletUtils
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean isAjaxRequest(HttpServletRequest request)
|
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||||
{
|
|
||||||
final String jsonMimeType = "application/json";
|
final String jsonMimeType = "application/json";
|
||||||
final String xhrHeader = "XMLHttpRequest";
|
final String xhrHeader = "XMLHttpRequest";
|
||||||
final String jsonSuffix = ".json";
|
final String jsonSuffix = ".json";
|
||||||
final String xmlSuffix = ".xml";
|
final String xmlSuffix = ".xml";
|
||||||
String accept = request.getHeader("accept");
|
String accept = request.getHeader("accept");
|
||||||
if (accept != null && accept.contains(jsonMimeType))
|
if (accept != null && accept.contains(jsonMimeType)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||||
if (xRequestedWith != null && xRequestedWith.contains(xhrHeader))
|
if (xRequestedWith != null && xRequestedWith.contains(xhrHeader)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uri = request.getRequestURI();
|
String uri = request.getRequestURI();
|
||||||
if (StringUtils.inStringIgnoreCase(uri, jsonSuffix, xmlSuffix))
|
if (StringUtils.inStringIgnoreCase(uri, jsonSuffix, xmlSuffix)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,14 +216,10 @@ public class ServletUtils
|
||||||
* @param str 内容
|
* @param str 内容
|
||||||
* @return 编码后的内容
|
* @return 编码后的内容
|
||||||
*/
|
*/
|
||||||
public static String urlEncode(String str)
|
public static String urlEncode(String str) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return URLEncoder.encode(str, Constants.UTF8);
|
return URLEncoder.encode(str, Constants.UTF8);
|
||||||
}
|
} catch (UnsupportedEncodingException e) {
|
||||||
catch (UnsupportedEncodingException e)
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -270,14 +230,10 @@ public class ServletUtils
|
||||||
* @param str 内容
|
* @param str 内容
|
||||||
* @return 解码后的内容
|
* @return 解码后的内容
|
||||||
*/
|
*/
|
||||||
public static String urlDecode(String str)
|
public static String urlDecode(String str) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return URLDecoder.decode(str, Constants.UTF8);
|
return URLDecoder.decode(str, Constants.UTF8);
|
||||||
}
|
} catch (UnsupportedEncodingException e) {
|
||||||
catch (UnsupportedEncodingException e)
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,66 +242,53 @@ public class ServletUtils
|
||||||
* 设置webflux模型响应
|
* 设置webflux模型响应
|
||||||
*
|
*
|
||||||
* @param response ServerHttpResponse
|
* @param response ServerHttpResponse
|
||||||
* @param value 响应内容
|
* @param value 响应内容
|
||||||
* @return Mono
|
* @return Mono
|
||||||
*/
|
*/
|
||||||
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value,boolean jimi)
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value, boolean jimi) {
|
||||||
{
|
return webFluxResponseWriter(response, HttpStatus.OK, value, R.FAIL, jimi);
|
||||||
return webFluxResponseWriter(response, HttpStatus.OK, value, R.FAIL,jimi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置webflux模型响应
|
* 设置webflux模型响应
|
||||||
*
|
*
|
||||||
* @param response ServerHttpResponse
|
* @param response ServerHttpResponse
|
||||||
* @param code 响应状态码
|
* @param code 响应状态码
|
||||||
* @param value 响应内容
|
* @param value 响应内容
|
||||||
* @return Mono<Void>
|
* @return Mono<Void>
|
||||||
*/
|
*/
|
||||||
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value, int code,boolean jimi)
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value, int code, boolean jimi) {
|
||||||
{
|
return webFluxResponseWriter(response, HttpStatus.OK, value, code, jimi);
|
||||||
return webFluxResponseWriter(response, HttpStatus.OK, value, code,jimi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置webflux模型响应
|
* 设置webflux模型响应
|
||||||
*
|
*
|
||||||
* @param response ServerHttpResponse
|
* @param response ServerHttpResponse
|
||||||
* @param status http状态码
|
* @param status http状态码
|
||||||
* @param code 响应状态码
|
* @param code 响应状态码
|
||||||
* @param value 响应内容
|
* @param value 响应内容
|
||||||
* @return Mono<Void>
|
* @return Mono<Void>
|
||||||
*/
|
*/
|
||||||
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, HttpStatus status, Object value, int code,boolean jimi)
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, HttpStatus status, Object value, int code, boolean jimi) {
|
||||||
{
|
|
||||||
return webFluxResponseWriter(response, MediaType.APPLICATION_JSON_VALUE, status, value, code, jimi);
|
return webFluxResponseWriter(response, MediaType.APPLICATION_JSON_VALUE, status, value, code, jimi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置webflux模型响应
|
* 设置webflux模型响应
|
||||||
*
|
*
|
||||||
* @param response ServerHttpResponse
|
* @param response ServerHttpResponse
|
||||||
* @param contentType content-type
|
* @param contentType content-type
|
||||||
* @param status http状态码
|
* @param status http状态码
|
||||||
* @param code 响应状态码
|
* @param code 响应状态码
|
||||||
* @param value 响应内容
|
* @param value 响应内容
|
||||||
* @return Mono<Void>
|
* @return Mono<Void>
|
||||||
*/
|
*/
|
||||||
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, String contentType, HttpStatus status, Object value, int code,boolean jimi)
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, String contentType, HttpStatus status, Object value, int code, boolean jimi) {
|
||||||
{
|
|
||||||
response.setStatusCode(status);
|
response.setStatusCode(status);
|
||||||
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, contentType);
|
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, contentType);
|
||||||
R<?> result = R.fail(code, value.toString());
|
R<?> result = R.fail(code, value.toString());
|
||||||
Map maps= Maps.newHashMap();
|
DataBuffer dataBuffer = response.bufferFactory().wrap(JSON.toJSONString(result).getBytes());
|
||||||
if(jimi){
|
|
||||||
String responseData= AesCbcUtils.encrypt( JSON.toJSONString(result));
|
|
||||||
maps.put("data",responseData);
|
|
||||||
maps.put(SystemGlobal.KEY_DECRYPT,true);
|
|
||||||
}else{
|
|
||||||
maps.put("data",result);
|
|
||||||
maps.put(SystemGlobal.KEY_DECRYPT,false);
|
|
||||||
}
|
|
||||||
DataBuffer dataBuffer = response.bufferFactory().wrap(JSON.toJSONString(maps).getBytes());
|
|
||||||
return response.writeWith(Mono.just(dataBuffer));
|
return response.writeWith(Mono.just(dataBuffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ public class TokenService {
|
||||||
loginUser.setUsername(userName);
|
loginUser.setUsername(userName);
|
||||||
loginUser.setIpaddr(IpUtils.getIpAddr());
|
loginUser.setIpaddr(IpUtils.getIpAddr());
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
|
|
||||||
// Jwt存储信息
|
// Jwt存储信息
|
||||||
Map<String, Object> claimsMap = new HashMap<String, Object>(16);
|
Map<String, Object> claimsMap = new HashMap<String, Object>(16);
|
||||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||||
|
|
@ -79,13 +78,23 @@ public class TokenService {
|
||||||
return rspMap;
|
return rspMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLogin(String userId) {
|
||||||
|
String existingTokenKey = redisService.getCacheObject(LOGIN_USER_KEY + userId);
|
||||||
|
return existingTokenKey != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isKey(String key) {
|
||||||
|
return redisService.hasKey(getTokenKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除已有的token
|
* 删除已有的token
|
||||||
*/
|
*/
|
||||||
private void delExistingToken(Long userId) {
|
public void delExistingToken(Long userId) {
|
||||||
String existingTokenKey = redisService.getCacheObject(LOGIN_USER_KEY + userId);
|
String existingTokenKey = redisService.getCacheObject(LOGIN_USER_KEY + userId);
|
||||||
if (existingTokenKey != null) {
|
if (existingTokenKey != null) {
|
||||||
redisService.deleteObject(getTokenKey(existingTokenKey));
|
redisService.deleteObject(getTokenKey(existingTokenKey));
|
||||||
|
redisService.deleteObject(LOGIN_USER_KEY + userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(), jaData);
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(), jaData);
|
||||||
}
|
}
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ import com.bonus.system.service.ISysPostService;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/post")
|
@RequestMapping("/post")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysPostController extends BaseController
|
public class SysPostController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPostService postService;
|
private ISysPostService postService;
|
||||||
|
|
||||||
|
|
@ -45,29 +44,29 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:post:list")
|
@RequiresPermissions("system:post:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@SysLog(title = "岗位管理", businessType = OperaType.QUERY,logType = 0,module = "系统管理->岗位管理")
|
@SysLog(title = "岗位管理", businessType = OperaType.QUERY, logType = 0, module = "系统管理->岗位管理")
|
||||||
public TableDataInfo list(SysPost post) {
|
public TableDataInfo list(SysPost post) {
|
||||||
try{
|
try {
|
||||||
startPage();
|
startPage();
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
return getDataTableError(new ArrayList<>());
|
return getDataTableError(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:post:export")
|
@RequiresPermissions("system:post:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@SysLog(title = "岗位管理", businessType = OperaType.EXPORT,logType = 0,module = "系统管理->岗位管理")
|
@SysLog(title = "岗位管理", businessType = OperaType.EXPORT, logType = 0, module = "系统管理->岗位管理")
|
||||||
public void export(HttpServletResponse response, SysPost post) {
|
public void export(HttpServletResponse response, SysPost post) {
|
||||||
try{
|
try {
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||||
util.exportExcel(response, list, "岗位数据");
|
util.exportExcel(response, list, "岗位数据");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -76,10 +75,10 @@ public class SysPostController extends BaseController
|
||||||
@RequiresPermissions("system:post:query")
|
@RequiresPermissions("system:post:query")
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long postId) {
|
public AjaxResult getInfo(@PathVariable Long postId) {
|
||||||
try{
|
try {
|
||||||
return success(postService.selectPostById(postId));
|
return success(postService.selectPostById(postId));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
return error("系统异常");
|
return error("系统异常");
|
||||||
}
|
}
|
||||||
|
|
@ -89,9 +88,9 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:post:add")
|
@RequiresPermissions("system:post:add")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@SysLog(title = "岗位管理", businessType = OperaType.INSERT,logType = 0,module = "系统管理->岗位管理",details ="新增岗位" )
|
@SysLog(title = "岗位管理", businessType = OperaType.INSERT, logType = 0, module = "系统管理->岗位管理", details = "新增岗位")
|
||||||
public AjaxResult add(@Validated @RequestBody SysPost post) {
|
public AjaxResult add(@Validated @RequestBody SysPost post) {
|
||||||
try{
|
try {
|
||||||
if (!postService.checkPostNameUnique(post)) {
|
if (!postService.checkPostNameUnique(post)) {
|
||||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (!postService.checkPostCodeUnique(post)) {
|
} else if (!postService.checkPostCodeUnique(post)) {
|
||||||
|
|
@ -99,8 +98,8 @@ public class SysPostController extends BaseController
|
||||||
}
|
}
|
||||||
post.setCreateBy(SecurityUtils.getUsername());
|
post.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(postService.insertPost(post));
|
return toAjax(postService.insertPost(post));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
return error("系统异常");
|
return error("系统异常");
|
||||||
}
|
}
|
||||||
|
|
@ -110,9 +109,9 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:post:edit")
|
@RequiresPermissions("system:post:edit")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@SysLog(title = "岗位管理", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->岗位管理")
|
@SysLog(title = "岗位管理", businessType = OperaType.UPDATE, logType = 0, module = "系统管理->岗位管理")
|
||||||
public AjaxResult edit(@Validated @RequestBody SysPost post) {
|
public AjaxResult edit(@Validated @RequestBody SysPost post) {
|
||||||
try{
|
try {
|
||||||
if (!postService.checkPostNameUnique(post)) {
|
if (!postService.checkPostNameUnique(post)) {
|
||||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (!postService.checkPostCodeUnique(post)) {
|
} else if (!postService.checkPostCodeUnique(post)) {
|
||||||
|
|
@ -120,8 +119,8 @@ public class SysPostController extends BaseController
|
||||||
}
|
}
|
||||||
post.setUpdateBy(SecurityUtils.getUsername());
|
post.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
return error("系统异常");
|
return error("系统异常");
|
||||||
}
|
}
|
||||||
|
|
@ -131,14 +130,15 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:post:remove")
|
@RequiresPermissions("system:post:remove")
|
||||||
@DeleteMapping("/{postIds}")
|
@DeleteMapping("/{postIds}")
|
||||||
@SysLog(title = "岗位管理", businessType = OperaType.DELETE,logType = 0,module = "系统管理->岗位管理")
|
@SysLog(title = "岗位管理", businessType = OperaType.DELETE, logType = 0, module = "系统管理->岗位管理")
|
||||||
public AjaxResult remove(@PathVariable Long[] postIds) {
|
public AjaxResult remove(@PathVariable Long[] postIds) {
|
||||||
try{
|
try {
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
return error("人力资源已分配,不能删除");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -146,11 +146,11 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect() {
|
public AjaxResult optionselect() {
|
||||||
try{
|
try {
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
return success(posts);
|
return success(posts);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
return error("系统异常");
|
return error("系统异常");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,9 @@ public class SysUserController extends BaseController {
|
||||||
return success(message);
|
return success(message);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.toString(), e);
|
logger.error(e.toString(), e);
|
||||||
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
return error("系统异常,请联系管理员");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/importTemplate")
|
@PostMapping("/importTemplate")
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ public class SysPostServiceImpl implements ISysPostService
|
||||||
SysPost post = selectPostById(postId);
|
SysPost post = selectPostById(postId);
|
||||||
if (countUserPostById(postId) > 0)
|
if (countUserPostById(postId) > 0)
|
||||||
{
|
{
|
||||||
throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
throw new ServiceException(String.format("%1$s已分配用户,不能删除", post.getPostName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return postMapper.deletePostByIds(postIds);
|
return postMapper.deletePostByIds(postIds);
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
SysRole role = selectRoleById(roleId);
|
SysRole role = selectRoleById(roleId);
|
||||||
if (countUserRoleByRoleId(roleId) > 0)
|
if (countUserRoleByRoleId(roleId) > 0)
|
||||||
{
|
{
|
||||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
throw new ServiceException(String.format("%1$s已分配用户,不能删除", role.getRoleName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除角色与菜单关联
|
// 删除角色与菜单关联
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue