mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-05-31 14:12:10 +08:00
调整目录结构
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.hxkj.admin;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* 启动器
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {"com.hxkj"})
|
||||
@MapperScan(basePackages = {"com.hxkj.*.mapper"})
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication(exclude = {RedisRepositoriesAutoConfiguration.class})
|
||||
public class LikeAdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LikeAdminApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.hxkj.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.hxkj.admin.config.AdminConfig;
|
||||
import com.hxkj.admin.service.ISystemAdminService;
|
||||
import com.hxkj.admin.service.ISystemRoleMenuService;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.enums.HttpEnum;
|
||||
import com.hxkj.common.utils.RedisUtil;
|
||||
import com.hxkj.common.utils.ToolsUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 拦截器
|
||||
*/
|
||||
@Component
|
||||
public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
ISystemAdminService iSystemAdminService;
|
||||
|
||||
@Resource
|
||||
ISystemRoleMenuService iSystemRoleMenuService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 404拦截
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
if (response.getStatus() == 404) {
|
||||
AjaxResult result = AjaxResult.failed(HttpEnum.REQUEST_404_ERROR.getCode(), HttpEnum.REQUEST_404_ERROR.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 判断请求接口
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 免登录接口
|
||||
List<String> notLoginUri = Arrays.asList(AdminConfig.notLoginUri);
|
||||
if (notLoginUri.contains(request.getRequestURI())) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// Token是否为空
|
||||
String token = request.getHeader("token");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
AjaxResult result = AjaxResult.failed(HttpEnum.TOKEN_EMPTY.getCode(), HttpEnum.TOKEN_EMPTY.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token是否过期
|
||||
token = AdminConfig.backstageTokenKey + token;
|
||||
if (!RedisUtil.exists(token)) {
|
||||
AjaxResult result = AjaxResult.failed(HttpEnum.TOKEN_INVALID.getCode(), HttpEnum.TOKEN_INVALID.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 用户信息缓存
|
||||
String uid = RedisUtil.get(token).toString();
|
||||
if (!RedisUtil.hExists(AdminConfig.backstageManageKey, uid)) {
|
||||
iSystemAdminService.cacheAdminUserByUid(Integer.parseInt(uid));
|
||||
}
|
||||
|
||||
// 校验用户被删除
|
||||
Map<String, Object> map = ToolsUtil.jsonToMap(RedisUtil.hGet(AdminConfig.backstageManageKey, uid).toString());
|
||||
if (map == null || map.get("isDelete").toString().equals("1")) {
|
||||
RedisUtil.del(token);
|
||||
RedisUtil.hDel(AdminConfig.backstageManageKey, uid);
|
||||
AjaxResult result = AjaxResult.failed(HttpEnum.TOKEN_INVALID.getCode(), HttpEnum.TOKEN_INVALID.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 校验用户被禁用
|
||||
if (map.get("isDisable").toString().equals("1")) {
|
||||
AjaxResult result = AjaxResult.failed(HttpEnum.LOGIN_DISABLE_ERROR.getCode(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 令牌剩余30分钟自动续签
|
||||
if (RedisUtil.ttl(token) < 1800) {
|
||||
RedisUtil.expire(token, 7200L);
|
||||
}
|
||||
|
||||
// 写入本地线程
|
||||
LikeAdminThreadLocal.put("adminId", uid);
|
||||
LikeAdminThreadLocal.put("roleId", map.get("role").toString());
|
||||
LikeAdminThreadLocal.put("username", map.get("username").toString());
|
||||
LikeAdminThreadLocal.put("nickname", map.get("nickname").toString());
|
||||
|
||||
// 免权限验证接口
|
||||
List<String> notAuthUri = Arrays.asList(AdminConfig.notLoginUri);
|
||||
if (notAuthUri.contains(request.getRequestURI()) || Integer.parseInt(uid) == 1) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 校验角色权限是否存在
|
||||
String roleId = map.get("role").toString();
|
||||
if (!RedisUtil.hExists(AdminConfig.backstageRolesKey, roleId)) {
|
||||
iSystemRoleMenuService.cacheRoleMenusByRoleId(Integer.parseInt(roleId));
|
||||
}
|
||||
|
||||
// 验证是否有权限操作
|
||||
String menus = RedisUtil.hGet(AdminConfig.backstageRolesKey, roleId).toString();
|
||||
if (menus.equals("") || !Arrays.asList(menus.split(",")).contains(request.getRequestURI())) {
|
||||
AjaxResult result = AjaxResult.failed(HttpEnum.NO_PERMISSION.getCode(), HttpEnum.NO_PERMISSION.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证通过继续操作
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
LikeAdminThreadLocal.remove();
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.hxkj.admin;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* 本地线程
|
||||
*/
|
||||
public class LikeAdminThreadLocal {
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
public LikeAdminThreadLocal() {}
|
||||
|
||||
/**
|
||||
* 取得本地线程对象
|
||||
*/
|
||||
private static final java.lang.ThreadLocal<LinkedHashMap<String, Object>> MY_LOCAL = new java.lang.ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 写入本地线程
|
||||
*/
|
||||
public static void put(String key, Object val) {
|
||||
LinkedHashMap<String, Object> map = MY_LOCAL.get();
|
||||
if (map == null) {
|
||||
map = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
map.put(key, val);
|
||||
MY_LOCAL.set(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地线程
|
||||
*/
|
||||
public static Object get(String key) {
|
||||
return MY_LOCAL.get().getOrDefault(key, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取管理员ID
|
||||
*/
|
||||
public static Integer getAdminId() {
|
||||
String adminId = LikeAdminThreadLocal.get("adminId").toString();
|
||||
if (adminId.equals("")) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(adminId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色ID
|
||||
*/
|
||||
public static Integer getRoleId() {
|
||||
String roleId = LikeAdminThreadLocal.get("roleId").toString();
|
||||
if (roleId.equals("")) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除本地线程
|
||||
*/
|
||||
public static void remove() {
|
||||
MY_LOCAL.remove();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.hxkj.admin.config;
|
||||
|
||||
/**
|
||||
* 后台公共配置
|
||||
*/
|
||||
public class AdminConfig {
|
||||
|
||||
// 管理缓存键
|
||||
public static final String backstageManageKey = "backstage:manage";
|
||||
|
||||
// 角色缓存键
|
||||
public static final String backstageRolesKey = "backstage:roles";
|
||||
|
||||
// 令牌缓存键
|
||||
public static final String backstageTokenKey = "backstage:token:";
|
||||
|
||||
// 免登录验证
|
||||
public static String[] notLoginUri = new String[]{
|
||||
"/api/system/login"
|
||||
};
|
||||
|
||||
// 免权限验证
|
||||
public static String[] notAuthUri = new String[]{};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.hxkj.admin.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* MybatisPlus配置
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件集成
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.hxkj.admin.config;
|
||||
|
||||
import com.hxkj.admin.LikeAdminInterceptor;
|
||||
import com.hxkj.common.config.GlobalConfig;
|
||||
import com.hxkj.common.utils.YmlUtil;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Web配置
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Resource
|
||||
LikeAdminInterceptor likeAdminInterceptor;
|
||||
|
||||
/**
|
||||
* 配置允许跨域
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedHeaders("*")
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT")
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录拦截器
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(likeAdminInterceptor).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源目录映射
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
String directory = YmlUtil.get("like.upload-directory");
|
||||
if (directory == null || directory.equals("")) {
|
||||
directory = GlobalConfig.uploadDirectory;
|
||||
}
|
||||
|
||||
registry.addResourceHandler("/"+ GlobalConfig.publicPrefix +"/**")
|
||||
.addResourceLocations("file:" + directory);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hxkj.admin.config.aop;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Log {
|
||||
|
||||
/**
|
||||
* 模块
|
||||
* @return String
|
||||
*/
|
||||
String title() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.hxkj.admin.config.aop;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.hxkj.admin.LikeAdminThreadLocal;
|
||||
import com.hxkj.common.entity.system.SystemLogOperate;
|
||||
import com.hxkj.common.mapper.system.SystemLogOperateMapper;
|
||||
import com.hxkj.common.utils.HttpUtil;
|
||||
import com.hxkj.common.utils.IpUtil;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class LogAspect {
|
||||
|
||||
@Resource
|
||||
SystemLogOperateMapper systemLogOperateMapper;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
|
||||
private Long beginTime = 0L;
|
||||
|
||||
/**
|
||||
* 声明切面点拦截那些类
|
||||
*/
|
||||
@Pointcut("@annotation(com.hxkj.admin.config.aop.Log)")
|
||||
private void pointCutMethodController() {}
|
||||
|
||||
/**
|
||||
* 环绕通知前后增强
|
||||
*/
|
||||
@Around(value = "pointCutMethodController()")
|
||||
public Object doAroundService(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// 开始时间
|
||||
this.beginTime = System.currentTimeMillis();
|
||||
// 执行方法
|
||||
Object result = joinPoint.proceed();
|
||||
// 保存日志
|
||||
recordLog(joinPoint, null);
|
||||
// 返回结果
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截异常操作
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param e 异常
|
||||
*/
|
||||
@AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
|
||||
public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) {
|
||||
recordLog(joinPoint, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志信息
|
||||
*
|
||||
* @param joinPointObj joinPoint
|
||||
* @param e Exception 错误异常
|
||||
*/
|
||||
private void recordLog(Object joinPointObj, final Exception e) {
|
||||
try {
|
||||
long endTime = System.currentTimeMillis();
|
||||
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (requestAttributes != null) {
|
||||
// 取得请求对象
|
||||
HttpServletRequest request = requestAttributes.getRequest();
|
||||
|
||||
// 获取当前的用户
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
|
||||
// 获取日志注解
|
||||
ProceedingJoinPoint joinPoint = (ProceedingJoinPoint) joinPointObj;
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
Log logAnnotation = method.getAnnotation(Log.class);
|
||||
|
||||
// 方法名称
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
|
||||
// 获取请求参数
|
||||
String queryString = request.getQueryString();
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String params = "";
|
||||
if(args.length>0){
|
||||
if("POST".equals(request.getMethod())){
|
||||
params = JSON.toJSONString(args);
|
||||
} else if("GET".equals(request.getMethod())){
|
||||
params = queryString;
|
||||
}
|
||||
}
|
||||
|
||||
// 错误信息
|
||||
String error = "";
|
||||
int status = 1;
|
||||
if (e != null) {
|
||||
error = e.getMessage();
|
||||
status = 2; // 1=成功, 2=失败
|
||||
}
|
||||
|
||||
// 数据库日志
|
||||
SystemLogOperate model = new SystemLogOperate();
|
||||
model.setAdminId(adminId);
|
||||
model.setTitle(logAnnotation.title());
|
||||
model.setIp(IpUtil.getIpAddress(request));
|
||||
model.setType(request.getMethod());
|
||||
model.setMethod(className + "." + methodName + "()");
|
||||
model.setUrl(HttpUtil.route());
|
||||
model.setArgs(params);
|
||||
model.setError(error);
|
||||
model.setAddress(IpUtil.getRealAddressByIP(IpUtil.getIpAddress(request)));
|
||||
model.setStatus(status);
|
||||
model.setStartTime(this.beginTime / 1000);
|
||||
model.setEndTime(endTime / 1000);
|
||||
model.setTaskTime(endTime - this.beginTime);
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
systemLogOperateMapper.insert(model);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("异常信息:{}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.hxkj.admin.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.IAlbumService;
|
||||
import com.hxkj.admin.validate.AlbumParam;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.album.AlbumVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 相册管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/album")
|
||||
public class AlbumController {
|
||||
|
||||
@Resource
|
||||
IAlbumService iAlbumService;
|
||||
|
||||
/**
|
||||
* 相册列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/albumList")
|
||||
public Object albumList(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<AlbumVo> voPageResult = iAlbumService.albumList(pageParam, params);
|
||||
return AjaxResult.success(voPageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册重命名
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册重命名")
|
||||
@PostMapping("/albumRename")
|
||||
public Object albumRename(@Validated(value = AlbumParam.rename.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.albumRename(albumParam.getId(), albumParam.getName());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册移动
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册移动")
|
||||
@PostMapping("/albumMove")
|
||||
public Object albumMove(@Validated(value = AlbumParam.albumMove.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.albumMove(albumParam.getId(), albumParam.getCid());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册删除
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册删除")
|
||||
@PostMapping("/albumDel")
|
||||
public Object albumDel(@Validated(value = AlbumParam.delete.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.albumDel(albumParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/cateList")
|
||||
public Object cateList(@RequestParam Map<String, String> params) {
|
||||
JSONArray jsonArray = iAlbumService.cateList(params);
|
||||
return AjaxResult.success(jsonArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册分类新增")
|
||||
@PostMapping("/cateAdd")
|
||||
public Object cateAdd(@Validated(value = AlbumParam.cateAdd.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.cateAdd(albumParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类重命名
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册分类重命名")
|
||||
@PostMapping("/cateRename")
|
||||
public Object cateRename(@Validated(value = AlbumParam.rename.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.cateRename(albumParam.getId(), albumParam.getName());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册分类删除")
|
||||
@PostMapping("/cateDel")
|
||||
public Object cateDel(@Validated(value = AlbumParam.delete.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.cateDel(albumParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.hxkj.admin.controller;
|
||||
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.IArticleService;
|
||||
import com.hxkj.admin.validate.article.CategoryParam;
|
||||
import com.hxkj.admin.validate.article.ArticleParam;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.article.ArticleDetailVo;
|
||||
import com.hxkj.admin.vo.article.ArticleListVo;
|
||||
import com.hxkj.admin.vo.article.CategoryVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/article")
|
||||
public class ArticleController {
|
||||
|
||||
@Resource
|
||||
IArticleService iArticleService;
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/articleList")
|
||||
public Object articleList(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<ArticleListVo> vos = iArticleService.articleList(pageParam, params);
|
||||
return AjaxResult.success(vos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文章ID
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/articleDetail")
|
||||
public Object articleDetail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
try {
|
||||
ArticleDetailVo vo = iArticleService.articleDetail(id);
|
||||
return AjaxResult.success(vo);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章新增")
|
||||
@PostMapping("/articleAdd")
|
||||
public Object articleAdd(
|
||||
@Validated(value = ArticleParam.create.class)
|
||||
@RequestBody ArticleParam articleParam) {
|
||||
try {
|
||||
iArticleService.articleAdd(articleParam);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章编辑")
|
||||
@PostMapping("/articleEdit")
|
||||
public Object articleEdit(@Validated(value = ArticleParam.update.class)
|
||||
@RequestBody ArticleParam articleParam) {
|
||||
try {
|
||||
iArticleService.articleEdit(articleParam);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章删除")
|
||||
@PostMapping("/articleDel")
|
||||
public Object articleDel(@Validated(value = ArticleParam.delete.class)
|
||||
@RequestBody ArticleParam articleParam) {
|
||||
try {
|
||||
iArticleService.articleDel(articleParam.getId());
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/cateList")
|
||||
public Object cateList(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
try {
|
||||
PageResult<CategoryVo> voPageResult = iArticleService.cateList(pageParam, params);
|
||||
return AjaxResult.success(voPageResult);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/cateDetail")
|
||||
public Object cateDetail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
CategoryVo vo = iArticleService.cateDetail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleCateParam 分类参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章分类新增")
|
||||
@PostMapping("/cateAdd")
|
||||
public Object cateAdd(@Validated(value = CategoryParam.create.class)
|
||||
@RequestBody CategoryParam articleCateParam) {
|
||||
try {
|
||||
iArticleService.cateAdd(articleCateParam);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleCateParam 分类编辑
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章分类编辑")
|
||||
@PostMapping("/cateEdit")
|
||||
public Object cateEdit(@Validated(value = CategoryParam.update.class)
|
||||
@RequestBody CategoryParam articleCateParam) {
|
||||
try {
|
||||
iArticleService.cateEdit(articleCateParam);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleCateParam 分类删除
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章分类删除")
|
||||
@PostMapping("/cateDel")
|
||||
public Object cateDel(@Validated(value = CategoryParam.delete.class)
|
||||
@RequestBody CategoryParam articleCateParam) {
|
||||
try {
|
||||
iArticleService.cateDel(articleCateParam.getId());
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.hxkj.admin.controller;
|
||||
|
||||
import com.hxkj.admin.service.IIndexService;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主页管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/index")
|
||||
public class IndexController {
|
||||
|
||||
@Resource
|
||||
IIndexService iIndexService;
|
||||
|
||||
/**
|
||||
* 控制台
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/console")
|
||||
public Object console() {
|
||||
Map<String, Object> map = iIndexService.console();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.hxkj.admin.controller;
|
||||
|
||||
import com.hxkj.admin.LikeAdminThreadLocal;
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.IAlbumService;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.enums.AlbumEnum;
|
||||
import com.hxkj.common.exception.OperateException;
|
||||
import com.hxkj.common.plugin.storage.StorageDriver;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
public class UploadController {
|
||||
|
||||
@Resource
|
||||
IAlbumService iAlbumService;
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求对象
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "上传图片")
|
||||
@PostMapping("/image")
|
||||
public Object image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
if (multipartFile == null) {
|
||||
return AjaxResult.failed("请选择上传图片");
|
||||
}
|
||||
|
||||
try {
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
Map<String, Object> map = storageDriver.upload(multipartFile, "image", AlbumEnum.IMAGE.getCode());
|
||||
|
||||
Map<String, String> album = new LinkedHashMap<>();
|
||||
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
||||
album.put("cid", request.getParameter("cid"));
|
||||
album.put("type", String.valueOf(AlbumEnum.IMAGE.getCode()));
|
||||
album.put("size", map.get("size").toString());
|
||||
album.put("ext", map.get("ext").toString());
|
||||
album.put("url", map.get("url").toString());
|
||||
Integer id = iAlbumService.albumAdd(album);
|
||||
|
||||
map.put("id", id);
|
||||
|
||||
return AjaxResult.success(map);
|
||||
} catch (OperateException e) {
|
||||
return AjaxResult.failed(e.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传视频
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求对象
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "上传视频")
|
||||
@PostMapping("/video")
|
||||
public Object video(HttpServletRequest request) {
|
||||
MultipartFile multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
if (multipartFile == null) {
|
||||
return AjaxResult.failed("请选择上传视频");
|
||||
}
|
||||
|
||||
try {
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
Map<String, Object> map = storageDriver.upload(multipartFile, "video", AlbumEnum.Video.getCode());
|
||||
|
||||
Map<String, String> album = new LinkedHashMap<>();
|
||||
album.put("cid", request.getParameter("cid"));
|
||||
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
||||
album.put("type", String.valueOf(AlbumEnum.Video.getCode()));
|
||||
album.put("ext", map.get("ext").toString());
|
||||
album.put("size", map.get("size").toString());
|
||||
album.put("url", map.get("url").toString());
|
||||
Integer id = iAlbumService.albumAdd(album);
|
||||
|
||||
map.put("id", id);
|
||||
|
||||
return AjaxResult.success(map);
|
||||
} catch (OperateException e) {
|
||||
return AjaxResult.failed(e.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hxkj.admin.controller.monitor;
|
||||
|
||||
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.utils.StringUtil;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 缓存监控管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/monitor")
|
||||
public class CacheController {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
/**
|
||||
* 缓存监控
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "缓存监控")
|
||||
@GetMapping("/cache")
|
||||
public Object info() {
|
||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info);
|
||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize);
|
||||
|
||||
if (commandStats == null) {
|
||||
return AjaxResult.failed("获取异常");
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>(3);
|
||||
result.put("info", info);
|
||||
result.put("dbSize", dbSize);
|
||||
|
||||
List<Map<String, String>> pieList = new ArrayList<>();
|
||||
commandStats.stringPropertyNames().forEach(key -> {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
String property = commandStats.getProperty(key);
|
||||
data.put("name", StringUtil.removeStart(key, "cmdstat_"));
|
||||
data.put("value", StringUtil.substringBetween(property, "calls=", ",usec"));
|
||||
pieList.add(data);
|
||||
});
|
||||
|
||||
result.put("commandStats", pieList);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.hxkj.admin.controller.monitor;
|
||||
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.ServerResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 服务监控管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/monitor")
|
||||
public class ServerController {
|
||||
/**
|
||||
* 服务器信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "服务监控")
|
||||
@GetMapping("/server")
|
||||
public Object info() {
|
||||
ServerResult server = new ServerResult();
|
||||
return AjaxResult.success(server.copyTo());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.hxkj.admin.controller.setting;
|
||||
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.IBasicsService;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.utils.HttpUtil;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基础设置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/setting")
|
||||
public class BasicsController {
|
||||
|
||||
@Resource
|
||||
IBasicsService iBasicsService;
|
||||
|
||||
/**
|
||||
* 网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "网站信息")
|
||||
@RequestMapping("/website")
|
||||
public Object website(@RequestBody Map<String, String> params) {
|
||||
if (HttpUtil.isGet()) {
|
||||
Map<String, String> map = iBasicsService.getWebsite();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
try {
|
||||
iBasicsService.setWebsite(params);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.success(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 备案信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "备案信息")
|
||||
@RequestMapping("/copyright")
|
||||
public Object copyright(@RequestBody Map<String, String> params) {
|
||||
if (HttpUtil.isGet()) {
|
||||
Map<String, String> map = iBasicsService.getCopyright();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
try {
|
||||
iBasicsService.setCopyright(params);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.success(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.hxkj.admin.controller.system;
|
||||
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.ISystemAdminService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemAdminParam;
|
||||
import com.hxkj.admin.vo.system.SystemAdminVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统管理员管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/system/admin")
|
||||
public class SystemAdminController {
|
||||
|
||||
@Resource
|
||||
ISystemAdminService iSystemAdminService;
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/lists")
|
||||
public Object lists(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<SystemAdminVo> list = iSystemAdminService.lists(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemAdminVo vo = iSystemAdminService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAdminParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemAdminParam.create.class) @RequestBody SystemAdminParam systemAdminParam) {
|
||||
iSystemAdminService.add(systemAdminParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAdminParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemAdminParam.update.class) @RequestBody SystemAdminParam systemAdminParam) {
|
||||
iSystemAdminService.edit(systemAdminParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemAdminParam.delete.class) @RequestBody SystemAdminParam systemAdminParam) {
|
||||
iSystemAdminService.del(systemAdminParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.hxkj.admin.controller.system;
|
||||
|
||||
import com.hxkj.admin.service.ISystemLogServer;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.system.LogLoginVo;
|
||||
import com.hxkj.admin.vo.system.LogOperateVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统日志管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/system/log")
|
||||
public class SystemLogController {
|
||||
|
||||
@Resource
|
||||
ISystemLogServer iSystemLogServer;
|
||||
|
||||
/**
|
||||
* 系统操作日志
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/operate")
|
||||
public Object operate(@Validated PageParam pageParam, @RequestParam Map<String, String> params) {
|
||||
PageResult<LogOperateVo> list = iSystemLogServer.operate(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统登录日志
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/login")
|
||||
public Object login(@Validated PageParam pageParam, @RequestParam Map<String, String> params) {
|
||||
PageResult<LogLoginVo> list = iSystemLogServer.login(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.hxkj.admin.controller.system;
|
||||
|
||||
import com.hxkj.admin.service.ISystemLoginService;
|
||||
import com.hxkj.admin.validate.system.SystemLoginParam;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.exception.LoginException;
|
||||
import com.hxkj.common.exception.OperateException;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统登录管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/system")
|
||||
public class SystemLoginController {
|
||||
|
||||
@Resource
|
||||
ISystemLoginService iSystemLoginService;
|
||||
|
||||
/**
|
||||
* 登录系统
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemLoginParam 登录参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Object login(@Validated() @RequestBody SystemLoginParam systemLoginParam) {
|
||||
try {
|
||||
Map<String, Object> map = iSystemLoginService.login(systemLoginParam);
|
||||
return AjaxResult.success(map);
|
||||
} catch (LoginException e) {
|
||||
return AjaxResult.failed(e.getCode(), e.getMsg());
|
||||
} catch (OperateException e) {
|
||||
return AjaxResult.failed(e.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求接口
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public Object logout(HttpServletRequest request) {
|
||||
try {
|
||||
iSystemLoginService.logout(request.getHeader("token"));
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.hxkj.admin.controller.system;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.hxkj.admin.LikeAdminThreadLocal;
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.ISystemMenuService;
|
||||
import com.hxkj.admin.validate.system.SystemMenuParam;
|
||||
import com.hxkj.admin.vo.system.SystemMenuVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 系统菜单管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/system/menu")
|
||||
public class SystemMenuController {
|
||||
|
||||
@Resource
|
||||
ISystemMenuService iSystemMenuService;
|
||||
|
||||
/**
|
||||
* 获取系统菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/menus")
|
||||
public Object menus() {
|
||||
Integer roleId = LikeAdminThreadLocal.getRoleId();
|
||||
JSONArray lists = iSystemMenuService.selectMenuByRoleId(roleId);
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/lists")
|
||||
public Object lists() {
|
||||
JSONArray lists = iSystemMenuService.lists();
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemMenuVo vo = iSystemMenuService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "菜单新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemMenuParam.create.class) @RequestBody SystemMenuParam systemMenuParam) {
|
||||
iSystemMenuService.add(systemMenuParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "菜单编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemMenuParam.update.class) @RequestBody SystemMenuParam systemMenuParam) {
|
||||
iSystemMenuService.edit(systemMenuParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "菜单删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemMenuParam.delete.class) @RequestBody SystemMenuParam systemMenuParam) {
|
||||
iSystemMenuService.del(systemMenuParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.hxkj.admin.controller.system;
|
||||
|
||||
import com.hxkj.admin.config.aop.Log;
|
||||
import com.hxkj.admin.service.ISystemRoleService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemRoleParam;
|
||||
import com.hxkj.admin.vo.system.SystemRoleVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 系统角色管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/system/role")
|
||||
public class SystemRoleController {
|
||||
|
||||
@Resource
|
||||
ISystemRoleService iSystemRoleService;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色列表")
|
||||
@GetMapping("/lists")
|
||||
public Object lists(@Validated PageParam pageParam) {
|
||||
PageResult<SystemRoleVo> lists = iSystemRoleService.lists(pageParam);
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色详情")
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemRoleVo vo = iSystemRoleService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 角色参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemRoleParam.create.class) @RequestBody SystemRoleParam systemRoleParam) {
|
||||
iSystemRoleService.add(systemRoleParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 角色参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemRoleParam.create.class) @RequestBody SystemRoleParam systemRoleParam) {
|
||||
iSystemRoleService.edit(systemRoleParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 角色参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemRoleParam.delete.class) @RequestBody SystemRoleParam systemRoleParam) {
|
||||
iSystemRoleService.del(systemRoleParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.hxkj.admin.validate.AlbumParam;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.album.AlbumVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 相册服务接口类
|
||||
*/
|
||||
public interface IAlbumService {
|
||||
|
||||
/**
|
||||
* 文件列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 其他搜索参数
|
||||
* @return PageResult<AlbumVo>
|
||||
*/
|
||||
PageResult<AlbumVo> albumList(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 文件重命名
|
||||
*
|
||||
* @param id 文件ID
|
||||
* @param name 文件名称
|
||||
*/
|
||||
void albumRename(Integer id, String name);
|
||||
|
||||
/**
|
||||
* 文件移动
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param cid 类目ID
|
||||
*/
|
||||
void albumMove(Integer id, Integer cid);
|
||||
|
||||
/**
|
||||
* 文件新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 文件信息参数
|
||||
*/
|
||||
Integer albumAdd(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 文件删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
*/
|
||||
void albumDel(Integer id);
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 搜索参数
|
||||
* @return JSONArray
|
||||
*/
|
||||
JSONArray cateList(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*/
|
||||
void cateAdd(AlbumParam albumParam);
|
||||
|
||||
/**
|
||||
* 分类编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
* @param name 分类名称
|
||||
*/
|
||||
void cateRename(Integer id, String name);
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
void cateDel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.article.CategoryParam;
|
||||
import com.hxkj.admin.validate.article.ArticleParam;
|
||||
import com.hxkj.admin.vo.article.ArticleDetailVo;
|
||||
import com.hxkj.admin.vo.article.ArticleListVo;
|
||||
import com.hxkj.admin.vo.article.CategoryVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文章服务接口类
|
||||
*/
|
||||
public interface IArticleService {
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
PageResult<ArticleListVo> articleList(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键ID
|
||||
*/
|
||||
ArticleDetailVo articleDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 文章新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
*/
|
||||
void articleAdd(ArticleParam articleParam);
|
||||
|
||||
/**
|
||||
* 文章编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
*/
|
||||
void articleEdit(ArticleParam articleParam);
|
||||
|
||||
/**
|
||||
* 文章删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文章主键
|
||||
*/
|
||||
void articleDel(Integer id);
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<CategoryVo>
|
||||
*/
|
||||
PageResult<CategoryVo> cateList(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 分类详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
CategoryVo cateDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleCateParam 分类参数
|
||||
*/
|
||||
void cateAdd(CategoryParam articleCateParam);
|
||||
|
||||
/**
|
||||
* 分类编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleCateParam 分类参数
|
||||
*/
|
||||
void cateEdit(CategoryParam articleCateParam);
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
void cateDel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基础配置服务接口类
|
||||
*/
|
||||
public interface IBasicsService {
|
||||
|
||||
/**
|
||||
* 获取网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
Map<String, String> getWebsite();
|
||||
|
||||
/**
|
||||
* 获取版权信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
Map<String, String> getCopyright();
|
||||
|
||||
/**
|
||||
* 设置网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void setWebsite(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 设置版权信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void setCopyright(Map<String, String> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主页服务接口类
|
||||
*/
|
||||
public interface IIndexService {
|
||||
|
||||
/**
|
||||
* 控制台数据
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> console();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemAdminParam;
|
||||
import com.hxkj.admin.vo.system.SystemAdminVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.system.SystemAdmin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统管理员服务接口类
|
||||
*/
|
||||
public interface ISystemAdminService {
|
||||
|
||||
/**
|
||||
* 根据账号查找管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param username 主键ID
|
||||
* @return SysAdmin
|
||||
*/
|
||||
SystemAdmin findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return PageResult<SysAdminListVo>
|
||||
*/
|
||||
PageResult<SystemAdminVo> lists(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 管理员详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysAdmin
|
||||
*/
|
||||
SystemAdminVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAdminParam 参数
|
||||
*/
|
||||
void add(SystemAdminParam systemAdminParam);
|
||||
|
||||
/**
|
||||
* 编辑管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAdminParam 参数
|
||||
*/
|
||||
void edit(SystemAdminParam systemAdminParam);
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
/**
|
||||
* 缓存管理员
|
||||
*/
|
||||
void cacheAdminUserByUid(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.system.LogLoginVo;
|
||||
import com.hxkj.admin.vo.system.LogOperateVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统日志服务类接口类
|
||||
*/
|
||||
public interface ISystemLogServer {
|
||||
|
||||
/**
|
||||
* 系统操作日志
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<LogOperateVo>
|
||||
*/
|
||||
PageResult<LogOperateVo> operate(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 系统登录日志
|
||||
*
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<LogLoginVo>
|
||||
*/
|
||||
PageResult<LogLoginVo> login(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.system.SystemLoginParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统登录服务接口类
|
||||
*/
|
||||
public interface ISystemLoginService {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemLoginParam 登录参数
|
||||
* @return token
|
||||
*/
|
||||
Map<String, Object> login(SystemLoginParam systemLoginParam);
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*
|
||||
* @author fzr
|
||||
* @param token 令牌
|
||||
*/
|
||||
void logout(String token);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.hxkj.admin.validate.system.SystemMenuParam;
|
||||
import com.hxkj.admin.vo.system.SystemMenuVo;
|
||||
|
||||
/**
|
||||
* 系统菜单服务接口类
|
||||
*/
|
||||
public interface ISystemMenuService {
|
||||
|
||||
/**
|
||||
* 根据角色获取菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return JSONArray
|
||||
*/
|
||||
JSONArray selectMenuByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return JSONArray
|
||||
*/
|
||||
JSONArray lists();
|
||||
|
||||
/**
|
||||
* 菜单详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SysMenu
|
||||
*/
|
||||
SystemMenuVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemMenuParam 参数
|
||||
*/
|
||||
void add(SystemMenuParam systemMenuParam);
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemMenuParam 参数
|
||||
*/
|
||||
void edit(SystemMenuParam systemMenuParam);
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色菜单服务接口类
|
||||
*/
|
||||
public interface ISystemRoleMenuService {
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单ID
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return List<Integer>
|
||||
*/
|
||||
List<Integer> selectMenuIdsByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 批量写入角色菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
* @param menuIds 菜单ID组
|
||||
*/
|
||||
void batchSaveByMenuIds(Integer roleId, String menuIds);
|
||||
|
||||
/**
|
||||
* 根据角色ID批量删除角色菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
void batchDeleteByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 根据菜单ID批量删除角色菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
void batchDeleteByMenuId(Integer menuId);
|
||||
|
||||
/**
|
||||
* 缓存角色菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
void cacheRoleMenusByRoleId(Integer roleId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemRoleParam;
|
||||
import com.hxkj.admin.vo.system.SystemRoleVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 系统角色服务接口类
|
||||
*/
|
||||
public interface ISystemRoleService {
|
||||
|
||||
/**
|
||||
* 根据id获取角色名称
|
||||
* @param id 角色ID
|
||||
* @return String
|
||||
*/
|
||||
String getRoleNameById(Integer id);
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 参数
|
||||
* @return PageResult<SysRoleListVo>
|
||||
*/
|
||||
PageResult<SystemRoleVo> lists(@Validated PageParam pageParam);
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysRole
|
||||
*/
|
||||
SystemRoleVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 参数
|
||||
*/
|
||||
void add(SystemRoleParam systemRoleParam);
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 参数
|
||||
*/
|
||||
void edit(SystemRoleParam systemRoleParam);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.hxkj.admin.service.IAlbumService;
|
||||
import com.hxkj.admin.validate.AlbumParam;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.album.AlbumCateVo;
|
||||
import com.hxkj.admin.vo.album.AlbumVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.Album;
|
||||
import com.hxkj.common.entity.AlbumCate;
|
||||
import com.hxkj.common.mapper.AlbumCateMapper;
|
||||
import com.hxkj.common.mapper.AlbumMapper;
|
||||
import com.hxkj.common.utils.ArrayUtil;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import com.hxkj.common.utils.ToolsUtil;
|
||||
import com.hxkj.common.utils.UrlUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 相册服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class AlbumServiceImpl implements IAlbumService {
|
||||
|
||||
@Resource
|
||||
AlbumMapper albumMapper;
|
||||
|
||||
@Resource
|
||||
AlbumCateMapper albumCateMapper;
|
||||
|
||||
/**
|
||||
* 文件列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return PageResult<AlbumVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<AlbumVo> albumList(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<Album> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select(Album.class, info->
|
||||
!info.getColumn().equals("type") &&
|
||||
!info.getColumn().equals("aid") &&
|
||||
!info.getColumn().equals("uid") &&
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc("id");
|
||||
|
||||
albumMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:keyword:str",
|
||||
"=:type:int"
|
||||
});
|
||||
|
||||
IPage<Album> iPage = albumMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<AlbumVo> albumVoArrayList = new ArrayList<>();
|
||||
for (Album album : iPage.getRecords()) {
|
||||
AlbumVo vo = new AlbumVo();
|
||||
BeanUtils.copyProperties(album, vo);
|
||||
|
||||
vo.setUri(UrlUtil.toAbsoluteUrl(album.getUri()));
|
||||
vo.setSize(ToolsUtil.toStorageUnit(album.getSize()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(album.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(album.getUpdateTime()));
|
||||
albumVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), albumVoArrayList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件重命名
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param name 文件名称
|
||||
*/
|
||||
@Override
|
||||
public void albumRename(Integer id, String name) {
|
||||
Album album = albumMapper.selectOne(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(album, "文件丢失!");
|
||||
|
||||
album.setName(name);
|
||||
album.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件移动
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param cid 类目ID
|
||||
*/
|
||||
@Override
|
||||
public void albumMove(Integer id, Integer cid) {
|
||||
Album album = albumMapper.selectOne(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(album, "文件丢失!");
|
||||
|
||||
Assert.notNull( albumCateMapper.selectOne(
|
||||
new QueryWrapper<AlbumCate>()
|
||||
.eq("id", cid)
|
||||
.eq("is_delete", 0)
|
||||
), "类目已不存在!");
|
||||
|
||||
album.setCid(cid);
|
||||
album.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 文件信息参数
|
||||
*/
|
||||
@Override
|
||||
public Integer albumAdd(Map<String, String> params) {
|
||||
Album album = new Album();
|
||||
album.setCid(Integer.parseInt(params.get("cid") == null ? "0" : params.get("cid")));
|
||||
album.setAid(Integer.parseInt(params.get("aid") == null ? "0" : params.get("aid")));
|
||||
album.setUid(Integer.parseInt(params.get("uid") == null ? "0" : params.get("uid")));
|
||||
album.setType(Integer.parseInt(params.get("type")));
|
||||
album.setName(params.get("name"));
|
||||
album.setExt(params.get("ext"));
|
||||
album.setUri(params.get("url"));
|
||||
album.setSize(Long.parseLong(params.get("size")));
|
||||
album.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
album.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.insert(album);
|
||||
return album.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
*/
|
||||
@Override
|
||||
public void albumDel(Integer id) {
|
||||
Album album = albumMapper.selectOne(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(album, "文件丢失!");
|
||||
|
||||
album.setIsDelete(1);
|
||||
album.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @param params 搜索参数
|
||||
* @return JSONArray
|
||||
*/
|
||||
@Override
|
||||
public JSONArray cateList(Map<String, String> params) {
|
||||
QueryWrapper<AlbumCate> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select(AlbumCate.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc("id");
|
||||
|
||||
long type = Integer.parseInt(params.getOrDefault("type", "0"));
|
||||
String keyword = params.getOrDefault("keyword", "");
|
||||
if (type > 0) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
|
||||
if (!keyword.equals("")) {
|
||||
queryWrapper.like("name", keyword);
|
||||
}
|
||||
|
||||
List<AlbumCate> albumCateList = albumCateMapper.selectList(queryWrapper);
|
||||
|
||||
List<AlbumCateVo> lists = new LinkedList<>();
|
||||
for (AlbumCate albumCate : albumCateList) {
|
||||
AlbumCateVo vo = new AlbumCateVo();
|
||||
BeanUtils.copyProperties(albumCate, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(albumCate.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(albumCate.getUpdateTime()));
|
||||
lists.add(vo);
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(lists));
|
||||
return ArrayUtil.listToTree(jsonArray, "id", "pid", "children");
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param albumParam 分类参数
|
||||
*/
|
||||
@Override
|
||||
public void cateAdd(AlbumParam albumParam) {
|
||||
AlbumCate albumCate = new AlbumCate();
|
||||
albumCate.setType(albumParam.getType());
|
||||
albumCate.setPid(albumParam.getPid());
|
||||
albumCate.setName(albumParam.getName());
|
||||
albumCate.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
albumCate.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumCateMapper.insert(albumCate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类重命名
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
* @param name 分类名称
|
||||
*/
|
||||
@Override
|
||||
public void cateRename(Integer id, String name) {
|
||||
AlbumCate albumCate = albumCateMapper.selectOne(
|
||||
new QueryWrapper<AlbumCate>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(albumCate, "分类已不存在!");
|
||||
|
||||
albumCate.setName(name);
|
||||
albumCate.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumCateMapper.updateById(albumCate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
@Override
|
||||
public void cateDel(Integer id) {
|
||||
AlbumCate albumCate = albumCateMapper.selectOne(
|
||||
new QueryWrapper<AlbumCate>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(albumCate, "分类已不存在!");
|
||||
|
||||
Assert.isNull(albumMapper.selectOne(new QueryWrapper<Album>()
|
||||
.select("id", "cid", "name")
|
||||
.eq("cid", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")
|
||||
), "当前分类正被使用中,不能删除!");
|
||||
|
||||
albumCate.setIsDelete(1);
|
||||
albumCate.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
albumCateMapper.updateById(albumCate);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.hxkj.admin.service.IArticleService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.article.CategoryParam;
|
||||
import com.hxkj.admin.validate.article.ArticleParam;
|
||||
import com.hxkj.admin.vo.article.ArticleDetailVo;
|
||||
import com.hxkj.admin.vo.article.ArticleListVo;
|
||||
import com.hxkj.admin.vo.article.CategoryVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.Article;
|
||||
import com.hxkj.common.entity.ArticleCategory;
|
||||
import com.hxkj.common.mapper.ArticleCategoryMapper;
|
||||
import com.hxkj.common.mapper.ArticleMapper;
|
||||
import com.hxkj.common.utils.StringUtil;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import com.hxkj.common.utils.UrlUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 文章服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ArticleServiceImpl implements IArticleService {
|
||||
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Resource
|
||||
ArticleCategoryMapper articleCategoryMapper;
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ArticleListVo> articleList(PageParam pageParam, Map<String, String> params) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
|
||||
MPJQueryWrapper<Article> mpjQueryWrapper = new MPJQueryWrapper<Article>()
|
||||
.selectAll(Article.class)
|
||||
.select("ac.name as category")
|
||||
.innerJoin("ls_article_category ac ON ac.id=t.cid")
|
||||
.eq("t.is_delete", 0)
|
||||
.orderByDesc(Arrays.asList("t.sort", "t.id"));
|
||||
|
||||
IPage<ArticleListVo> iPage = articleMapper.selectJoinPage(
|
||||
new Page<>(pageNo, pageSize),
|
||||
ArticleListVo.class,
|
||||
mpjQueryWrapper);
|
||||
|
||||
for (ArticleListVo vo : iPage.getRecords()) {
|
||||
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(vo.getUpdateTime()));
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), iPage.getRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
public ArticleDetailVo articleDetail(Integer id) {
|
||||
Article model = articleMapper.selectOne(
|
||||
new QueryWrapper<Article>()
|
||||
.select(Article.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(model, "文章不存在");
|
||||
|
||||
ArticleDetailVo vo = new ArticleDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
vo.setContent(StringUtil.isNull(model.getContent()) ? "" : model.getContent());
|
||||
vo.setImage(UrlUtil.toAbsoluteUrl(model.getImage()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(model.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(model.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
*/
|
||||
@Override
|
||||
public void articleAdd(ArticleParam articleParam) {
|
||||
Article model = new Article();
|
||||
model.setCid(articleParam.getCid());
|
||||
model.setTitle(articleParam.getTitle());
|
||||
model.setImage(UrlUtil.toRelativeUrl(articleParam.getImage()));
|
||||
model.setIntro(articleParam.getIntro());
|
||||
model.setContent(articleParam.getContent());
|
||||
model.setSort(articleParam.getSort());
|
||||
model.setIsShow(articleParam.getIsShow());
|
||||
model.setVisit(0);
|
||||
model.setCreateTime(TimeUtil.timestamp());
|
||||
model.setUpdateTime(TimeUtil.timestamp());
|
||||
articleMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
*/
|
||||
@Override
|
||||
public void articleEdit(ArticleParam articleParam) {
|
||||
Article model = articleMapper.selectOne(
|
||||
new QueryWrapper<Article>()
|
||||
.eq("id", articleParam.getId())
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(model, "文章不存在!");
|
||||
|
||||
Assert.notNull(articleCategoryMapper.selectOne(
|
||||
new QueryWrapper<ArticleCategory>()
|
||||
.eq("id", articleParam.getCid())
|
||||
.eq("is_delete", 0)), "分类不存在");
|
||||
|
||||
model.setCid(articleParam.getCid());
|
||||
model.setTitle(articleParam.getTitle());
|
||||
model.setImage(UrlUtil.toRelativeUrl(articleParam.getImage()));
|
||||
model.setIntro(articleParam.getIntro());
|
||||
model.setContent(articleParam.getContent());
|
||||
model.setIsShow(articleParam.getIsShow());
|
||||
model.setSort(articleParam.getSort());
|
||||
model.setUpdateTime(TimeUtil.timestamp());
|
||||
articleMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文章ID
|
||||
*/
|
||||
@Override
|
||||
public void articleDel(Integer id) {
|
||||
Article article = articleMapper.selectOne(
|
||||
new QueryWrapper<Article>()
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(article, "文章不存在!");
|
||||
|
||||
article.setIsDelete(1);
|
||||
article.setDeleteTime(TimeUtil.timestamp());
|
||||
articleMapper.updateById(article);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<CategoryVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<CategoryVo> cateList(PageParam pageParam, Map<String, String> params) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<ArticleCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id", "name", "sort", "is_show", "create_time", "update_time")
|
||||
.eq("is_delete", 0);
|
||||
|
||||
IPage<ArticleCategory> iPage = articleCategoryMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<CategoryVo> list = new ArrayList<>();
|
||||
for (ArticleCategory category : iPage.getRecords()) {
|
||||
CategoryVo vo = new CategoryVo();
|
||||
BeanUtils.copyProperties(category, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(vo.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
* @return CategoryVo
|
||||
*/
|
||||
@Override
|
||||
public CategoryVo cateDetail(Integer id) {
|
||||
ArticleCategory model = articleCategoryMapper.selectOne(
|
||||
new QueryWrapper<ArticleCategory>()
|
||||
.select(ArticleCategory.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(model, "分类不存在");
|
||||
|
||||
CategoryVo vo = new CategoryVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(model.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(model.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类参数
|
||||
*/
|
||||
@Override
|
||||
public void cateAdd(CategoryParam categoryParam) {
|
||||
ArticleCategory model = new ArticleCategory();
|
||||
model.setId(categoryParam.getId());
|
||||
model.setName(categoryParam.getName());
|
||||
model.setSort(categoryParam.getSort());
|
||||
model.setCreateTime(TimeUtil.timestamp());
|
||||
model.setUpdateTime(TimeUtil.timestamp());
|
||||
articleCategoryMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类参数
|
||||
*/
|
||||
@Override
|
||||
public void cateEdit(CategoryParam categoryParam) {
|
||||
ArticleCategory model = articleCategoryMapper.selectOne(
|
||||
new QueryWrapper<ArticleCategory>()
|
||||
.select(ArticleCategory.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", categoryParam.getId())
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(model, "分类不存在");
|
||||
|
||||
model.setName(categoryParam.getName());
|
||||
model.setSort(categoryParam.getSort());
|
||||
model.setUpdateTime(TimeUtil.timestamp());
|
||||
articleCategoryMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类参数
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
@Override
|
||||
public void cateDel(Integer id) {
|
||||
ArticleCategory model = articleCategoryMapper.selectOne(
|
||||
new QueryWrapper<ArticleCategory>()
|
||||
.select(ArticleCategory.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(model, "分类不存在");
|
||||
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(TimeUtil.timestamp());
|
||||
articleCategoryMapper.updateById(model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.hxkj.admin.service.IBasicsService;
|
||||
import com.hxkj.common.utils.ConfigUtil;
|
||||
import com.hxkj.common.utils.UrlUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基础配置服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class BasicsServiceImpl implements IBasicsService {
|
||||
|
||||
/**
|
||||
* 获取网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getWebsite() {
|
||||
Map<String, String> config = ConfigUtil.get("website");
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("name", config.getOrDefault("name", ""));
|
||||
map.put("logo", UrlUtil.toAbsoluteUrl(config.getOrDefault("logo", "")));
|
||||
map.put("backdrop", UrlUtil.toAbsoluteUrl(config.getOrDefault("backdrop", "")));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版权信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getCopyright() {
|
||||
Map<String, String> config = ConfigUtil.get("copyright");
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("privilege", config.getOrDefault("privilege", ""));
|
||||
map.put("icp_number", UrlUtil.toAbsoluteUrl(config.getOrDefault("icp_number", "")));
|
||||
map.put("icp_link", UrlUtil.toAbsoluteUrl(config.getOrDefault("icp_link", "")));
|
||||
map.put("ga_number", UrlUtil.toAbsoluteUrl(config.getOrDefault("ga_number", "")));
|
||||
map.put("ga_link", UrlUtil.toAbsoluteUrl(config.getOrDefault("ga_link", "")));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void setWebsite(Map<String, String> params) {
|
||||
ConfigUtil.set("website", "name", params.getOrDefault("name", ""));
|
||||
ConfigUtil.set("website", "logo", UrlUtil.toRelativeUrl(params.getOrDefault("logo", "")));
|
||||
ConfigUtil.set("website", "backdrop", UrlUtil.toRelativeUrl(params.getOrDefault("backdrop", "")));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置版权信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void setCopyright(Map<String, String> params) {
|
||||
ConfigUtil.set("copyright", "privilege", params.getOrDefault("privilege", ""));
|
||||
ConfigUtil.set("copyright", "icp_number", params.getOrDefault("icp_number", ""));
|
||||
ConfigUtil.set("copyright", "icp_link", params.getOrDefault("icp_link", ""));
|
||||
ConfigUtil.set("copyright", "ga_number", params.getOrDefault("ga_number", ""));
|
||||
ConfigUtil.set("copyright", "ga_link", params.getOrDefault("ga_link", ""));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.hxkj.admin.service.IIndexService;
|
||||
import com.hxkj.common.entity.Article;
|
||||
import com.hxkj.common.mapper.ArticleMapper;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 主页服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class IndexServiceImpl implements IIndexService {
|
||||
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
/**
|
||||
* 控制台数据
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> console() {
|
||||
Map<String, Object> console = new LinkedHashMap<>();
|
||||
|
||||
// 账号信息
|
||||
Map<String, Object> version = new LinkedHashMap<>();
|
||||
version.put("version", "1.0.0");
|
||||
version.put("website", "www.likeshop.cn");
|
||||
console.put("version", version);
|
||||
|
||||
// 今日数据
|
||||
Map<String, Object> today = new LinkedHashMap<>();
|
||||
today.put("todayVisits", 10);
|
||||
today.put("totalVisits", 100);
|
||||
today.put("todaySales", 30);
|
||||
today.put("totalSales", 65);
|
||||
today.put("todayUsers", 120);
|
||||
today.put("totalUsers", 360);
|
||||
console.put("today", today);
|
||||
|
||||
// 访客图表
|
||||
Map<String, Object> visitor = new LinkedHashMap<>();
|
||||
visitor.put("date", TimeUtil.daysAgoDate(8));
|
||||
visitor.put("list", new ArrayList<>());
|
||||
console.put("visitor", visitor);
|
||||
|
||||
// 文章排名
|
||||
List<Map<String, Object>> articles = articleMapper.selectMaps(new QueryWrapper<Article>()
|
||||
.select("id", "title", "visit")
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc(Arrays.asList("visit", "id"))
|
||||
.last("limit 10"));
|
||||
console.put("article", articles);
|
||||
|
||||
return console;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.hxkj.admin.LikeAdminThreadLocal;
|
||||
import com.hxkj.admin.config.AdminConfig;
|
||||
import com.hxkj.admin.service.ISystemAdminService;
|
||||
import com.hxkj.admin.service.ISystemRoleService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemAdminParam;
|
||||
import com.hxkj.admin.vo.system.SystemAdminVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.system.SystemAdmin;
|
||||
import com.hxkj.common.mapper.system.SystemAdminMapper;
|
||||
import com.hxkj.common.utils.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 系统管理员实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAdminServiceImpl implements ISystemAdminService {
|
||||
|
||||
@Resource
|
||||
SystemAdminMapper systemAdminMapper;
|
||||
|
||||
@Resource
|
||||
ISystemRoleService iSystemRoleService;
|
||||
|
||||
/**
|
||||
* 根据账号查找管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param username 主键ID
|
||||
* @return SysAdmin
|
||||
*/
|
||||
@Override
|
||||
public SystemAdmin findByUsername(String username) {
|
||||
return systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.eq("username", username)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取管理员列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return PageResult<SysAdminListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SystemAdminVo> lists(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SystemAdmin> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select(SystemAdmin.class, info->
|
||||
!info.getColumn().equals("salt") &&
|
||||
!info.getColumn().equals("password") &&
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc("sort");
|
||||
|
||||
systemAdminMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:username:str",
|
||||
"like:nickname:str",
|
||||
"=:role:int"
|
||||
});
|
||||
|
||||
IPage<SystemAdmin> iPage = systemAdminMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SystemAdminVo> adminVoArrayList = new ArrayList<>();
|
||||
for (SystemAdmin sysAdmin : iPage.getRecords()) {
|
||||
SystemAdminVo vo = new SystemAdminVo();
|
||||
BeanUtils.copyProperties(sysAdmin, vo);
|
||||
|
||||
if (sysAdmin.getId() == 1) {
|
||||
vo.setRole("超级管理员");
|
||||
} else {
|
||||
vo.setRole(iSystemRoleService.getRoleNameById(sysAdmin.getRole()));
|
||||
}
|
||||
|
||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(sysAdmin.getAvatar()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
vo.setLastLoginTime(TimeUtil.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), adminVoArrayList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取管理员详细
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SysAdmin
|
||||
*/
|
||||
@Override
|
||||
public SystemAdminVo detail(Integer id) {
|
||||
SystemAdmin sysAdmin = systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(SystemAdmin.class, info->
|
||||
!info.getColumn().equals("salt") &&
|
||||
!info.getColumn().equals("password") &&
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(sysAdmin, "账号已不存在!");
|
||||
|
||||
SystemAdminVo vo = new SystemAdminVo();
|
||||
BeanUtils.copyProperties(sysAdmin, vo);
|
||||
|
||||
vo.setRole(String.valueOf(sysAdmin.getRole()));
|
||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(sysAdmin.getAvatar()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
vo.setLastLoginTime(TimeUtil.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAdminParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemAdminParam systemAdminParam) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.isNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("username", systemAdminParam.getUsername())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", systemAdminParam.getNickname())
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
|
||||
Assert.notNull(iSystemRoleService.detail(systemAdminParam.getRole()), "角色不存在!");
|
||||
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5(systemAdminParam.getPassword().trim() + salt);
|
||||
String avatar = UrlUtil.toRelativeUrl(systemAdminParam.getAvatar());
|
||||
|
||||
SystemAdmin model = new SystemAdmin();
|
||||
model.setUsername(systemAdminParam.getUsername());
|
||||
model.setNickname(systemAdminParam.getNickname());
|
||||
model.setRole(systemAdminParam.getRole());
|
||||
model.setAvatar(avatar);
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
model.setSort(systemAdminParam.getSort());
|
||||
model.setIsDisable(systemAdminParam.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAdminMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAdminParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemAdminParam systemAdminParam) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(field)
|
||||
.eq("id", systemAdminParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "账号不存在了!");
|
||||
|
||||
Assert.isNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("username", systemAdminParam.getUsername())
|
||||
.ne("id", systemAdminParam.getId())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", systemAdminParam.getNickname())
|
||||
.ne("id", systemAdminParam.getId())
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
|
||||
Assert.notNull(iSystemRoleService.detail(systemAdminParam.getRole()), "角色不存在!");
|
||||
|
||||
SystemAdmin model = new SystemAdmin();
|
||||
model.setId(systemAdminParam.getId());
|
||||
model.setNickname(systemAdminParam.getNickname());
|
||||
model.setUsername(systemAdminParam.getUsername());
|
||||
model.setAvatar( UrlUtil.toRelativeUrl(systemAdminParam.getAvatar()));
|
||||
model.setRole(systemAdminParam.getId() == 1 ? 0 : systemAdminParam.getRole());
|
||||
model.setSort(systemAdminParam.getSort());
|
||||
model.setIsDisable(systemAdminParam.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (systemAdminParam.getPassword() != null) {
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5( systemAdminParam.getPassword().trim() + salt);
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
}
|
||||
|
||||
systemAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(systemAdminParam.getId());
|
||||
|
||||
if (systemAdminParam.getPassword() != null) {
|
||||
RedisUtil.del(Objects.requireNonNull(HttpUtil.obj()).getHeader("token"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select(field)
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "账号已不存在!");
|
||||
|
||||
Assert.isFalse(id == 1, "系统管理员不允许删除");
|
||||
|
||||
int adminId = Integer.parseInt(LikeAdminThreadLocal.getAdminId().toString());
|
||||
Assert.isFalse(id == adminId, "不能删除自己");
|
||||
|
||||
SystemAdmin model = new SystemAdmin();
|
||||
model.setId(id);
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
systemAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存管理员
|
||||
*/
|
||||
@Override
|
||||
public void cacheAdminUserByUid(Integer id) {
|
||||
SystemAdmin sysAdmin = systemAdminMapper.selectById(id);
|
||||
|
||||
Map<String, Object> user = new LinkedHashMap<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
user.put("id", sysAdmin.getId());
|
||||
user.put("role", sysAdmin.getRole());
|
||||
user.put("username", sysAdmin.getUsername());
|
||||
user.put("nickname", sysAdmin.getNickname());
|
||||
user.put("avatar", sysAdmin.getAvatar());
|
||||
user.put("isDisable", sysAdmin.getIsDisable());
|
||||
user.put("isDelete", sysAdmin.getIsDelete());
|
||||
user.put("lastLoginIp", sysAdmin.getLastLoginIp());
|
||||
user.put("lastLoginTime", TimeUtil.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
user.put("createTime", TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
||||
user.put("updateTime", TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
map.put(String.valueOf(sysAdmin.getId()), JSON.toJSONString(user));
|
||||
RedisUtil.hmSet(AdminConfig.backstageManageKey, map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.hxkj.admin.service.ISystemLogServer;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.vo.system.LogLoginVo;
|
||||
import com.hxkj.admin.vo.system.LogOperateVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.system.SystemLogLogin;
|
||||
import com.hxkj.common.entity.system.SystemLogOperate;
|
||||
import com.hxkj.common.mapper.system.SystemLogLoginMapper;
|
||||
import com.hxkj.common.mapper.system.SystemLogOperateMapper;
|
||||
import com.hxkj.common.utils.StringUtil;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统日志服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemLogServerImpl implements ISystemLogServer {
|
||||
|
||||
@Resource
|
||||
SystemLogOperateMapper logOperateMapper;
|
||||
|
||||
@Resource
|
||||
SystemLogLoginMapper logLoginMapper;
|
||||
|
||||
/**
|
||||
* 系统操作日志
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<LogOperateVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<LogOperateVo> operate(PageParam pageParam, Map<String, String> params) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
|
||||
MPJQueryWrapper<SystemLogOperate> mpjQueryWrapper = new MPJQueryWrapper<SystemLogOperate>()
|
||||
.selectAll(SystemLogOperate.class)
|
||||
.select("sa.username,sa.nickname")
|
||||
.leftJoin("ls_system_admin sa ON sa.id=t.admin_id")
|
||||
.orderByDesc("id");
|
||||
|
||||
IPage<LogOperateVo> iPage = logOperateMapper.selectJoinPage(
|
||||
new Page<>(pageNo, pageSize),
|
||||
LogOperateVo.class,
|
||||
mpjQueryWrapper);
|
||||
|
||||
logOperateMapper.setSearch(mpjQueryWrapper, params, new String[]{
|
||||
"like:title:str",
|
||||
"like:username:str",
|
||||
"=:type:int",
|
||||
"=:status:int",
|
||||
"datetime:startTime-endTime@create_time:str"
|
||||
});
|
||||
|
||||
for (LogOperateVo vo : iPage.getRecords()) {
|
||||
vo.setTaskTime(vo.getTaskTime());
|
||||
vo.setStartTime(TimeUtil.timestampToDate(vo.getStartTime()));
|
||||
vo.setEndTime(TimeUtil.timestampToDate(vo.getEndTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
||||
vo.setError(StringUtil.isNull(vo.getError()) ? "" : vo.getError());
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), iPage.getRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统登录日志
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<LogLoginVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<LogLoginVo> login(PageParam pageParam, Map<String, String> params) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SystemLogLogin> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
logLoginMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:username:str",
|
||||
"=:status:int",
|
||||
"datetime:startTime-endTime@create_time:str"
|
||||
});
|
||||
|
||||
IPage<SystemLogLogin> iPage = logLoginMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<LogLoginVo> voList = new LinkedList<>();
|
||||
for (SystemLogLogin item : iPage.getRecords()) {
|
||||
LogLoginVo vo = new LogLoginVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
||||
voList.add(vo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), voList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.hxkj.admin.config.AdminConfig;
|
||||
import com.hxkj.admin.service.ISystemAdminService;
|
||||
import com.hxkj.admin.service.ISystemLoginService;
|
||||
import com.hxkj.admin.validate.system.SystemLoginParam;
|
||||
import com.hxkj.common.entity.system.SystemAdmin;
|
||||
import com.hxkj.common.entity.system.SystemLogLogin;
|
||||
import com.hxkj.common.enums.HttpEnum;
|
||||
import com.hxkj.common.exception.LoginException;
|
||||
import com.hxkj.common.exception.OperateException;
|
||||
import com.hxkj.common.mapper.system.SystemAdminMapper;
|
||||
import com.hxkj.common.mapper.system.SystemLogLoginMapper;
|
||||
import com.hxkj.common.utils.*;
|
||||
import nl.bitwalker.useragentutils.UserAgent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 系统登录服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemLoginServiceImpl implements ISystemLoginService {
|
||||
|
||||
@Resource
|
||||
SystemLogLoginMapper systemLogLoginMapper;
|
||||
|
||||
@Resource
|
||||
SystemAdminMapper systemAdminMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAdminService iSystemAdminService;
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SystemLoginServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemLoginParam 登录参数
|
||||
* @return token
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> login(SystemLoginParam systemLoginParam) {
|
||||
String username = systemLoginParam.getUsername();
|
||||
String password = systemLoginParam.getPassword();
|
||||
|
||||
SystemAdmin sysAdmin = iSystemAdminService.findByUsername(username);
|
||||
if (sysAdmin == null || sysAdmin.getIsDelete() == 1) {
|
||||
this.recordLoginLog(0, systemLoginParam.getUsername(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_ACCOUNT_ERROR.getCode(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
}
|
||||
|
||||
if (sysAdmin.getIsDisable() == 1) {
|
||||
this.recordLoginLog(sysAdmin.getId(), systemLoginParam.getUsername(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_DISABLE_ERROR.getCode(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
}
|
||||
|
||||
String newPWd = password + sysAdmin.getSalt();
|
||||
String md5Pwd = ToolsUtil.makeMd5(newPWd);
|
||||
System.out.println(md5Pwd);
|
||||
if (!md5Pwd.equals(sysAdmin.getPassword())) {
|
||||
this.recordLoginLog(sysAdmin.getId(), systemLoginParam.getUsername(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_ACCOUNT_ERROR.getCode(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
}
|
||||
|
||||
try {
|
||||
sysAdmin.setLastLoginIp(HttpUtil.ip());
|
||||
sysAdmin.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||
systemAdminMapper.updateById(sysAdmin);
|
||||
|
||||
String token = ToolsUtil.makeToken();
|
||||
RedisUtil.set(AdminConfig.backstageTokenKey+token, sysAdmin.getId(), 7200);
|
||||
iSystemAdminService.cacheAdminUserByUid(sysAdmin.getId());
|
||||
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("token", token);
|
||||
|
||||
this.recordLoginLog(sysAdmin.getId(), systemLoginParam.getUsername(), "");
|
||||
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
Integer adminId = StringUtil.isNotNull(sysAdmin.getId()) ? sysAdmin.getId() : 0;
|
||||
String error = StringUtil.isEmpty(e.getMessage()) ? "未知错误" : e.getMessage();
|
||||
this.recordLoginLog(adminId, systemLoginParam.getUsername(), error);
|
||||
throw new OperateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*
|
||||
* @author fzr
|
||||
* @param token 令牌
|
||||
*/
|
||||
@Override
|
||||
public void logout(String token) {
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey + token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录日志
|
||||
*/
|
||||
private void recordLoginLog(Integer adminId, String username, String error) {
|
||||
try {
|
||||
HttpServletRequest request = Objects.requireNonNull(HttpUtil.obj());
|
||||
final UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
|
||||
|
||||
SystemLogLogin model = new SystemLogLogin();
|
||||
model.setAdminId(adminId);
|
||||
model.setUsername(username);
|
||||
model.setIp(HttpUtil.ip());
|
||||
model.setAddress(IpUtil.getRealAddressByIP(HttpUtil.ip()));
|
||||
model.setOs(userAgent.getOperatingSystem().getName());
|
||||
model.setBrowser(userAgent.getBrowser().getName());
|
||||
model.setStatus(StringUtil.isEmpty(error) ? 1 : 0);
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
systemLogLoginMapper.insert(model);
|
||||
} catch (Exception e) {
|
||||
log.error("记录登录日志异常 {}" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.hxkj.admin.LikeAdminThreadLocal;
|
||||
import com.hxkj.admin.config.AdminConfig;
|
||||
import com.hxkj.admin.service.ISystemMenuService;
|
||||
import com.hxkj.admin.service.ISystemRoleMenuService;
|
||||
import com.hxkj.admin.validate.system.SystemMenuParam;
|
||||
import com.hxkj.admin.vo.system.SystemMenuVo;
|
||||
import com.hxkj.common.entity.system.SystemMenu;
|
||||
import com.hxkj.common.mapper.system.SystemMenuMapper;
|
||||
import com.hxkj.common.utils.ArrayUtil;
|
||||
import com.hxkj.common.utils.RedisUtil;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SystemMenuServiceImpl implements ISystemMenuService {
|
||||
|
||||
@Resource
|
||||
SystemMenuMapper systemMenuMapper;
|
||||
|
||||
@Resource
|
||||
ISystemRoleMenuService iSystemRoleMenuService;
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
* @return JSONArray
|
||||
*/
|
||||
@Override
|
||||
public JSONArray selectMenuByRoleId(Integer roleId) {
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
List<Integer> menuIds = iSystemRoleMenuService.selectMenuIdsByRoleId(roleId);
|
||||
|
||||
QueryWrapper<SystemMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("menu_type", Arrays.asList("M", "C"));
|
||||
queryWrapper.orderByDesc(Arrays.asList("menu_sort", "id"));
|
||||
if (adminId != 1 && menuIds.size() > 0) {
|
||||
queryWrapper.in("id", menuIds);
|
||||
}
|
||||
|
||||
List<SystemMenu> systemMenus = systemMenuMapper.selectList(queryWrapper);
|
||||
List<SystemMenuVo> lists = new ArrayList<>();
|
||||
for (SystemMenu systemMenu : systemMenus) {
|
||||
SystemMenuVo vo = new SystemMenuVo();
|
||||
BeanUtils.copyProperties(systemMenu, vo);
|
||||
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemMenu.getUpdateTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemMenu.getCreateTime()));
|
||||
lists.add(vo);
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(lists));
|
||||
return ArrayUtil.listToTree(jsonArray, "id", "pid", "children");
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return JSONArray
|
||||
*/
|
||||
@Override
|
||||
public JSONArray lists() {
|
||||
QueryWrapper<SystemMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc(Arrays.asList("menu_sort", "id"));
|
||||
|
||||
List<SystemMenu> systemMenus = systemMenuMapper.selectList(queryWrapper);
|
||||
|
||||
List<SystemMenuVo> lists = new ArrayList<>();
|
||||
for (SystemMenu systemMenu : systemMenus) {
|
||||
SystemMenuVo vo = new SystemMenuVo();
|
||||
BeanUtils.copyProperties(systemMenu, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemMenu.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemMenu.getUpdateTime()));
|
||||
lists.add(vo);
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(lists));
|
||||
return ArrayUtil.listToTree(jsonArray, "id", "pid", "children");
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysMenu
|
||||
*/
|
||||
@Override
|
||||
public SystemMenuVo detail(Integer id) {
|
||||
SystemMenu systemMenu = systemMenuMapper.selectOne(new QueryWrapper<SystemMenu>().eq("id", id));
|
||||
Assert.notNull(systemMenu, "菜单已不存在!");
|
||||
|
||||
SystemMenuVo vo = new SystemMenuVo();
|
||||
BeanUtils.copyProperties(systemMenu, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemMenu.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemMenu.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemMenuParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemMenuParam systemMenuParam) {
|
||||
SystemMenu model = new SystemMenu();
|
||||
model.setPid(systemMenuParam.getPid());
|
||||
model.setMenuType(systemMenuParam.getMenuType());
|
||||
model.setMenuName(systemMenuParam.getMenuName());
|
||||
model.setMenuIcon(systemMenuParam.getMenuIcon());
|
||||
model.setMenuSort(systemMenuParam.getMenuSort());
|
||||
model.setPerms(systemMenuParam.getPerms());
|
||||
model.setIsDisable(systemMenuParam.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemMenuMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemMenuParam 菜单
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemMenuParam systemMenuParam) {
|
||||
SystemMenu model = systemMenuMapper.selectOne(new QueryWrapper<SystemMenu>().eq("id", systemMenuParam.getId()));
|
||||
Assert.notNull(model, "菜单已不存在!");
|
||||
|
||||
model.setMenuType(systemMenuParam.getMenuType());
|
||||
model.setMenuName(systemMenuParam.getMenuName());
|
||||
model.setMenuIcon(systemMenuParam.getMenuIcon());
|
||||
model.setMenuSort(systemMenuParam.getMenuSort());
|
||||
model.setPerms(systemMenuParam.getPerms());
|
||||
model.setPid(systemMenuParam.getPid());
|
||||
model.setIsDisable(systemMenuParam.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemMenuMapper.updateById(model);
|
||||
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
SystemMenu model = systemMenuMapper.selectOne(new QueryWrapper<SystemMenu>().eq("id", id));
|
||||
Assert.notNull(model, "菜单已不存在!");
|
||||
|
||||
systemMenuMapper.deleteById(id);
|
||||
|
||||
iSystemRoleMenuService.batchDeleteByMenuId(id);
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.hxkj.admin.config.AdminConfig;
|
||||
import com.hxkj.admin.service.ISystemRoleMenuService;
|
||||
import com.hxkj.common.entity.system.SystemMenu;
|
||||
import com.hxkj.common.entity.system.SystemRoleMenu;
|
||||
import com.hxkj.common.mapper.system.SystemMenuMapper;
|
||||
import com.hxkj.common.mapper.system.SystemRoleMenuMapper;
|
||||
import com.hxkj.common.utils.ArrayUtil;
|
||||
import com.hxkj.common.utils.RedisUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统菜单服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemRoleMenuServiceImpl implements ISystemRoleMenuService {
|
||||
|
||||
@Resource
|
||||
SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
|
||||
@Resource
|
||||
SystemMenuMapper systemMenuMapper;
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单ID
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return List<Integer>
|
||||
*/
|
||||
@Override
|
||||
public List<Integer> selectMenuIdsByRoleId(Integer roleId) {
|
||||
List<Integer> menus = new LinkedList<>();
|
||||
List<SystemRoleMenu> systemRoleMenus = systemRoleMenuMapper.selectList(
|
||||
new QueryWrapper<SystemRoleMenu>().eq("role_id", roleId));
|
||||
for (SystemRoleMenu systemRoleMenu : systemRoleMenus) {
|
||||
menus.add(systemRoleMenu.getMenuId());
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量写入角色菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
* @param menuIds 菜单ID组
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchSaveByMenuIds(Integer roleId, String menuIds) {
|
||||
if (menuIds != null && !menuIds.equals("")) {
|
||||
for (String menuId : menuIds.split(",")) {
|
||||
SystemRoleMenu model = new SystemRoleMenu();
|
||||
model.setRoleId(roleId);
|
||||
model.setMenuId(Integer.parseInt(menuId));
|
||||
systemRoleMenuMapper.insert(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单(根据角色ID)
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@Override
|
||||
public void batchDeleteByRoleId(Integer roleId) {
|
||||
systemRoleMenuMapper.delete(new QueryWrapper<SystemRoleMenu>().eq("role_id", roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单(根据菜单ID)
|
||||
*
|
||||
* @author fzr
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
@Override
|
||||
public void batchDeleteByMenuId(Integer menuId) {
|
||||
systemRoleMenuMapper.delete(new QueryWrapper<SystemRoleMenu>().eq("menu_id", menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存角色菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@Override
|
||||
public void cacheRoleMenusByRoleId(Integer roleId) {
|
||||
List<Integer> menuIds = new LinkedList<>();
|
||||
List<String> menuArray = new LinkedList<>();
|
||||
|
||||
List<SystemRoleMenu> systemRoleMenus = systemRoleMenuMapper.selectList(
|
||||
new QueryWrapper<SystemRoleMenu>().eq("role_id", roleId));
|
||||
for (SystemRoleMenu systemRoleMenu : systemRoleMenus) {
|
||||
menuIds.add(systemRoleMenu.getMenuId());
|
||||
}
|
||||
|
||||
if (menuIds.size() > 0) {
|
||||
List<SystemMenu> systemMenus = systemMenuMapper.selectList(new QueryWrapper<SystemMenu>()
|
||||
.select("id,perms")
|
||||
.in("id", menuIds)
|
||||
.eq("is_disable", 0));
|
||||
|
||||
for (SystemMenu systemMenu : systemMenus) {
|
||||
menuArray.add(systemMenu.getPerms().trim());
|
||||
}
|
||||
}
|
||||
|
||||
RedisUtil.hSet(AdminConfig.backstageRolesKey, String.valueOf(roleId), ArrayUtil.listStrToString(menuArray, ","));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.hxkj.admin.config.AdminConfig;
|
||||
import com.hxkj.admin.service.ISystemRoleMenuService;
|
||||
import com.hxkj.admin.service.ISystemRoleService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemRoleParam;
|
||||
import com.hxkj.admin.vo.system.SystemRoleVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.system.SystemAdmin;
|
||||
import com.hxkj.common.entity.system.SystemRole;
|
||||
import com.hxkj.common.mapper.system.SystemAdminMapper;
|
||||
import com.hxkj.common.mapper.system.SystemRoleMapper;
|
||||
import com.hxkj.common.utils.RedisUtil;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemRoleServiceImpl implements ISystemRoleService {
|
||||
|
||||
@Resource
|
||||
SystemAdminMapper systemAdminMapper;
|
||||
|
||||
@Resource
|
||||
SystemRoleMapper systemRoleMapper;
|
||||
|
||||
@Resource
|
||||
ISystemRoleMenuService iSystemRoleMenuService;
|
||||
|
||||
/**
|
||||
* 根据ID获取角色名称
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 角色ID
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getRoleNameById(Integer id) {
|
||||
QueryWrapper<SystemRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id", "name")
|
||||
.eq("id", id)
|
||||
.last("limit 1");
|
||||
|
||||
SystemRole systemRole = systemRoleMapper.selectOne(queryWrapper);
|
||||
if (systemRole == null) {
|
||||
return "";
|
||||
}
|
||||
return systemRole.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 参数
|
||||
* @return PageResult<SysRoleListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SystemRoleVo> lists(@Validated PageParam pageParam) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SystemRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||
|
||||
IPage<SystemRole> iPage = systemRoleMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SystemRoleVo> roleVoArrayList = new ArrayList<>();
|
||||
for (SystemRole systemRole : iPage.getRecords()) {
|
||||
SystemRoleVo vo = new SystemRoleVo();
|
||||
BeanUtils.copyProperties(systemRole, vo);
|
||||
|
||||
vo.setMenus(new ArrayList<>());
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemRole.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemRole.getUpdateTime()));
|
||||
roleVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), roleVoArrayList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysRole
|
||||
*/
|
||||
@Override
|
||||
public SystemRoleVo detail(Integer id) {
|
||||
SystemRole systemRole = systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemRole, "角色已不存在!");
|
||||
|
||||
SystemRoleVo vo = new SystemRoleVo();
|
||||
BeanUtils.copyProperties(systemRole, vo);
|
||||
|
||||
vo.setMenus(iSystemRoleMenuService.selectMenuIdsByRoleId(systemRole.getId()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemRole.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemRole.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(SystemRoleParam systemRoleParam) {
|
||||
Assert.isNull(systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.eq("name", systemRoleParam.getName().trim())
|
||||
.last("limit 1")), "角色名称已存在!");
|
||||
|
||||
SystemRole model = new SystemRole();
|
||||
model.setName(systemRoleParam.getName().trim());
|
||||
model.setRemark(systemRoleParam.getRemark());
|
||||
model.setIsDisable(systemRoleParam.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemRoleMapper.insert(model);
|
||||
|
||||
iSystemRoleMenuService.batchSaveByMenuIds(model.getId(), systemRoleParam.getMenuIds());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemRoleParam 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void edit(SystemRoleParam systemRoleParam) {
|
||||
Assert.notNull(systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.eq("id", systemRoleParam.getId())
|
||||
.last("limit 1")), "角色已不存在!");
|
||||
|
||||
Assert.isNull(systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.ne("id", systemRoleParam.getId())
|
||||
.eq("name", systemRoleParam.getName().trim())
|
||||
.last("limit 1")), "角色名称已存在!");
|
||||
|
||||
SystemRole model = new SystemRole();
|
||||
model.setId(systemRoleParam.getId());
|
||||
model.setName(systemRoleParam.getName().trim());
|
||||
model.setRemark(systemRoleParam.getRemark());
|
||||
model.setIsDisable(systemRoleParam.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemRoleMapper.updateById(model);
|
||||
|
||||
iSystemRoleMenuService.batchDeleteByRoleId(systemRoleParam.getId());
|
||||
iSystemRoleMenuService.batchSaveByMenuIds(systemRoleParam.getId(), systemRoleParam.getMenuIds());
|
||||
iSystemRoleMenuService.cacheRoleMenusByRoleId(systemRoleParam.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void del(Integer id) {
|
||||
Assert.notNull(
|
||||
systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.last("limit 1")),
|
||||
"角色已不存在!");
|
||||
|
||||
Assert.isNull(systemAdminMapper.selectOne(new QueryWrapper<SystemAdmin>()
|
||||
.select("id", "role", "nickname")
|
||||
.eq("role", id)
|
||||
.eq("is_delete", 0)),
|
||||
"角色已被管理员使用,请先移除");
|
||||
|
||||
systemRoleMapper.deleteById(id);
|
||||
iSystemRoleMenuService.batchDeleteByRoleId(id);
|
||||
RedisUtil.hDel(AdminConfig.backstageRolesKey, String.valueOf(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.hxkj.admin.validate;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import com.hxkj.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class AlbumParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface delete{}
|
||||
public interface rename{}
|
||||
public interface cateAdd{}
|
||||
public interface albumMove{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {rename.class, albumMove.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {albumMove.class})
|
||||
private Integer cid;
|
||||
|
||||
@NotNull(message = "缺少pid参数", groups = {cateAdd.class})
|
||||
@Min(value = 0, message = "pid参数必须为数字", groups = {cateAdd.class})
|
||||
private Integer pid;
|
||||
|
||||
@NotNull(message = "缺少type参数", groups = {cateAdd.class})
|
||||
@IntegerContains(values = {10, 20, 30}, message = "type不在合法值内", groups = {cateAdd.class})
|
||||
private Integer type;
|
||||
|
||||
@NotEmpty(message = "名称不能为空", groups = {rename.class})
|
||||
@Length(min = 1, max = 30, message = "名称不能大于30个字符", groups = {rename.class})
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.hxkj.admin.validate;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.DecimalMax;
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 分页参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class PageParam implements Serializable {
|
||||
|
||||
// 当前分页
|
||||
@DecimalMin(value = "1", message = "pageNo参数必须大于0的数字")
|
||||
public Integer pageNo = 1;
|
||||
|
||||
// 每页条数
|
||||
@DecimalMin(value = "1", message = "pageSize参数必须是大于0的数字")
|
||||
@DecimalMax(value = "60", message = "pageSize参数必须是小于60的数字")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.hxkj.admin.validate.article;
|
||||
|
||||
import com.hxkj.admin.validate.system.SystemAdminParam;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import com.hxkj.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class ArticleParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {create.class, update.class})
|
||||
private Integer cid;
|
||||
|
||||
@NotEmpty(message = "文章标题不能为空", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 200, message = "文章标题不能大于200个字符", groups = {create.class, update.class})
|
||||
private String title;
|
||||
|
||||
@Length(max = 200, message = "简介不能超出200个字符", groups = {create.class, update.class})
|
||||
private String intro = "";
|
||||
|
||||
@Length(max = 200, message = "图片链接过长不能超200个字符", groups = {create.class, update.class})
|
||||
private String image = "";
|
||||
|
||||
private String content = "";
|
||||
|
||||
@NotNull(message = "排序号不能为空", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer sort;
|
||||
|
||||
@NotNull(message = "缺少isShow参数", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, message = "isShow不是合法值", groups = {create.class, update.class})
|
||||
private Integer isShow;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.hxkj.admin.validate.article;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import com.hxkj.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章分类参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class CategoryParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {ArticleParam.create.class, ArticleParam.delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotEmpty(message = "分类名称不能为空", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 60, message = "分类名称不能大于60个字符", groups = {create.class, update.class})
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "排序号不能为空", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer sort;
|
||||
|
||||
@NotNull(message = "缺少isShow参数", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, message = "isShow不是合法值", groups = {create.class, update.class})
|
||||
private Integer isShow;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.hxkj.admin.validate.system;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统管理员参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemAdminParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "请选择角色", groups = {create.class, update.class})
|
||||
@Min(value = 1, message = "role参数异常", groups = {create.class, update.class})
|
||||
private Integer role;
|
||||
|
||||
@NotEmpty(message = "账号不能为空", groups = {create.class, update.class})
|
||||
@Length(min = 2, max = 20, message = "账号必须在2~20个字符内", groups = {create.class, update.class})
|
||||
private String username;
|
||||
|
||||
@NotEmpty(message = "昵称不能为空", groups = {create.class, update.class})
|
||||
@Length(min = 2, max = 30, message = "昵称必须在2~30个字符内", groups = {create.class, update.class})
|
||||
private String nickname;
|
||||
|
||||
@NotEmpty(message = "密码不能为空", groups = {create.class})
|
||||
@Length(min = 6, max = 18, message = "密码必须在6~18个字符内", groups = {create.class, update.class})
|
||||
private String password;
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
private Integer isDisable;
|
||||
|
||||
@NotNull(message = "排序号不能为空", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer sort;
|
||||
|
||||
private String avatar = "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.hxkj.admin.validate.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统登录参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemLoginParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotEmpty(message = "账号不能为空")
|
||||
@Length(min = 2, max = 20, message = "账号或密码错误")
|
||||
private String username;
|
||||
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 6, max = 18, message = "账号或密码错误")
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.hxkj.admin.validate.system;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import com.hxkj.common.validator.annotation.StringContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统菜单参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemMenuParam implements Serializable {
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "上级菜单不能为空", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "上级菜单值不能少于0", groups = {create.class, update.class})
|
||||
private Integer pid;
|
||||
|
||||
@NotNull(message = "缺少参数menuType", groups = {create.class, update.class})
|
||||
@StringContains(values = {"M", "C", "A"}, message = "菜单类型不是合法值(M,C,A)", groups = {create.class, update.class})
|
||||
private String menuType;
|
||||
|
||||
@NotNull(message = "缺少参数menuName", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 30, message = "菜单名称必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String menuName;
|
||||
|
||||
@Length(max = 100, message = "图标名称不能超过100个字符", groups = {create.class, update.class})
|
||||
private String menuIcon;
|
||||
|
||||
@NotNull(message = "排序号不能为空", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer menuSort;
|
||||
|
||||
@Length(max = 100, message = "权限字符不能超过100个字符", groups = {create.class, update.class})
|
||||
private String perms;
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
private Integer isDisable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.hxkj.admin.validate.system;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemRoleParam implements Serializable {
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "缺少参数name", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 30, message = "角色名称必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String name;
|
||||
|
||||
@Max(value = 200, message = "备注信息不能超过200个字符")
|
||||
private String remark = "";
|
||||
|
||||
@NotNull(message = "排序号不能为空", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer sort;
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
private Integer isDisable;
|
||||
|
||||
private String menuIds = "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.hxkj.admin.vo.album;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 相册分类Vo
|
||||
*/
|
||||
@Data
|
||||
public class AlbumCateVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer pid;
|
||||
private String name;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.hxkj.admin.vo.album;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 相册Vo
|
||||
*/
|
||||
@Data
|
||||
public class AlbumVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer cid;
|
||||
private String name;
|
||||
private String uri;
|
||||
private String ext;
|
||||
private String size;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.hxkj.admin.vo.article;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章详情Vo
|
||||
*/
|
||||
@Data
|
||||
public class ArticleDetailVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer cid;
|
||||
private String title;
|
||||
private String image;
|
||||
private String intro;
|
||||
private String content;
|
||||
private Integer visit;
|
||||
private Integer sort;
|
||||
private Integer isShow;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.hxkj.admin.vo.article;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ArticleListVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String category;
|
||||
private String title;
|
||||
private String image;
|
||||
private Integer visit;
|
||||
private Integer sort;
|
||||
private Integer isShow;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hxkj.admin.vo.article;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章分类Vo
|
||||
*/
|
||||
@Data
|
||||
public class CategoryVo implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer sort;
|
||||
private Integer isShow;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.hxkj.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 登录日志Vo
|
||||
*/
|
||||
@Data
|
||||
public class LogLoginVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String username;
|
||||
private String ip;
|
||||
private String os;
|
||||
private String browser;
|
||||
private String address;
|
||||
private Integer status;
|
||||
private String createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.hxkj.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 操作日志Vo
|
||||
*/
|
||||
@Data
|
||||
public class LogOperateVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String username;
|
||||
private String nickname;
|
||||
private String type;
|
||||
private String title;
|
||||
private String method;
|
||||
private String ip;
|
||||
private String url;
|
||||
private String args;
|
||||
private String error;
|
||||
private String address;
|
||||
private Integer status;
|
||||
private String taskTime;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.hxkj.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 管理员Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAdminVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String username;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private String role;
|
||||
private Integer isDisable;
|
||||
private String lastLoginIp;
|
||||
private String lastLoginTime;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.hxkj.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统菜单Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemMenuVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer pid;
|
||||
private String menuType;
|
||||
private String menuName;
|
||||
private String menuIcon;
|
||||
private Integer menuSort;
|
||||
private String perms;
|
||||
private Integer isDisable;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.hxkj.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统角色Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemRoleVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String remark;
|
||||
private Object menus;
|
||||
private Integer sort;
|
||||
private Integer isDisable;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "like.upload-directory",
|
||||
"type": "java.lang.String",
|
||||
"description": "Description for like.upload-directory."
|
||||
}
|
||||
]
|
||||
}
|
||||
10
like-framework/like-admin/src/main/resources/banner.txt
Normal file
10
like-framework/like-admin/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
///////////////////////////////////////////////////////
|
||||
// _ _ _ _ _ _ //
|
||||
// | | (_) | __ / \ __| |_ __ ___ (_)_ __ //
|
||||
// | | | | |/ / / _ \ / _` | '_ ` _ \| | '_ \ //
|
||||
// | |___| | < / ___ \ (_| | | | | | | | | | | //
|
||||
// |_____|_|_|\_\/_/ \_\__,_|_| |_| |_|_|_| |_| //
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||
// 佛祖保佑 永不宕机 永无BUG //
|
||||
//////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- 日志级别排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
|
||||
<configuration monitorInterval="5">
|
||||
|
||||
<!-- 变量配置 -->
|
||||
<Properties>
|
||||
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
|
||||
<property name="FILE_PATH" value="/www/wwwroot/logs/like-admin" />
|
||||
<property name="FILE_NAME" value="admin-log4j2" />
|
||||
</Properties>
|
||||
|
||||
<appenders>
|
||||
<!-- 控制台输出 -->
|
||||
<console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</console>
|
||||
|
||||
<!-- 临时测试日志 -->
|
||||
<File name="Filelog" fileName="${FILE_PATH}/test.log" append="false">
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
</File>
|
||||
|
||||
<!-- Info日志分割压缩 -->
|
||||
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
<!-- warn日志分割压缩 -->
|
||||
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
<!-- error日志分割压缩 -->
|
||||
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
</appenders>
|
||||
|
||||
<loggers>
|
||||
<!-- 过滤指定DEBUG信息 -->
|
||||
<logger name="org.mybatis" level="info" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
</logger>
|
||||
|
||||
<!-- 监控系统信息 -->
|
||||
<Logger name="org.springframework" level="info" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Logger>
|
||||
|
||||
<!-- 初始化日志 -->
|
||||
<root level="info">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="Filelog"/>
|
||||
<appender-ref ref="RollingFileInfo"/>
|
||||
<appender-ref ref="RollingFileWarn"/>
|
||||
<appender-ref ref="RollingFileError"/>
|
||||
</root>
|
||||
</loggers>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user