mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-09-07 07:07:57 +08:00
修改项目包名称为mdd
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.mdd.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.mdd"})
|
||||
@MapperScan(basePackages = {"com.mdd.*.mapper"})
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication(exclude = {RedisRepositoriesAutoConfiguration.class})
|
||||
public class LikeAdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LikeAdminApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.mdd.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.system.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.enums.HttpEnum;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.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
|
||||
ISystemAuthAdminService iSystemAuthAdminService;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
// 路由转权限
|
||||
String prefix = "/api/";
|
||||
String route = request.getRequestURI().replaceFirst(prefix, "");
|
||||
String auths = route.replace("/", ":");
|
||||
|
||||
// 免登录接口
|
||||
List<String> notLoginUri = Arrays.asList(AdminConfig.notLoginUri);
|
||||
if (notLoginUri.contains(auths)) {
|
||||
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)) {
|
||||
iSystemAuthAdminService.cacheAdminUserByUid(Integer.parseInt(uid));
|
||||
}
|
||||
|
||||
// 校验用户被删除
|
||||
Map<String, String> map = ToolsUtil.jsonToMap(RedisUtil.hGet(AdminConfig.backstageManageKey, uid).toString());
|
||||
if (map == null || map.get("isDelete").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").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"));
|
||||
LikeAdminThreadLocal.put("username", map.get("username"));
|
||||
LikeAdminThreadLocal.put("nickname", map.get("nickname"));
|
||||
|
||||
// 免权限验证接口
|
||||
List<String> notAuthUri = Arrays.asList(AdminConfig.notAuthUri);
|
||||
if (notAuthUri.contains(auths) || Integer.parseInt(uid) == 1) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 校验角色权限是否存在
|
||||
String roleId = map.get("role");
|
||||
if (!RedisUtil.hExists(AdminConfig.backstageRolesKey, roleId)) {
|
||||
iSystemAuthPermService.cacheRoleMenusByRoleId(Integer.parseInt(roleId));
|
||||
}
|
||||
|
||||
// 验证是否有权限操作
|
||||
String menus = RedisUtil.hGet(AdminConfig.backstageRolesKey, roleId).toString();
|
||||
if (menus.equals("") || !Arrays.asList(menus.split(",")).contains(auths)) {
|
||||
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.mdd.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,37 @@
|
||||
package com.mdd.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[]{
|
||||
"system:login", // 登录接口
|
||||
"common:index:config" // 配置接口
|
||||
};
|
||||
|
||||
// 免权限验证
|
||||
public static String[] notAuthUri = new String[]{
|
||||
"system:logout", // 退出登录
|
||||
"system:menu:menus", // 系统菜单
|
||||
"system:menu:route", // 菜单路由
|
||||
"system:admin:upInfo", // 管理员更新
|
||||
"system:admin:self", // 管理员信息
|
||||
"system:role:all", // 所有角色
|
||||
"system:post:all", // 所有岗位
|
||||
"system:dept:list", // 所有部门
|
||||
"setting:dict:type:all", // 所有字典类型
|
||||
"setting:dict:data:all", // 所有字典数据
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mdd.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.mdd.admin.config;
|
||||
|
||||
import com.mdd.admin.LikeAdminInterceptor;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.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.mdd.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,137 @@
|
||||
package com.mdd.admin.config.aop;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.common.entity.system.SystemLogOperate;
|
||||
import com.mdd.common.mapper.system.SystemLogOperateMapper;
|
||||
import com.mdd.common.utils.IpUtil;
|
||||
import com.mdd.common.utils.RequestUtil;
|
||||
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.mdd.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());
|
||||
model.setType(request.getMethod());
|
||||
model.setMethod(className + "." + methodName + "()");
|
||||
model.setUrl(RequestUtil.route());
|
||||
model.setArgs(params);
|
||||
model.setError(error);
|
||||
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,102 @@
|
||||
package com.mdd.admin.controller.article;
|
||||
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.article.IArticleArchivesService;
|
||||
import com.mdd.admin.validate.article.ArticleParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.article.ArticleDetailVo;
|
||||
import com.mdd.admin.vo.article.ArticleListVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.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("articleController")
|
||||
@RequestMapping("api/article")
|
||||
public class ArticleController {
|
||||
|
||||
@Resource
|
||||
IArticleArchivesService iArticleArchivesService;
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object articleList(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<ArticleListVo> vos = iArticleArchivesService.list(pageParam, params);
|
||||
return AjaxResult.success(vos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文章ID
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
ArticleDetailVo vo = iArticleArchivesService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(
|
||||
@Validated(value = ArticleParam.create.class)
|
||||
@RequestBody ArticleParam articleParam) {
|
||||
iArticleArchivesService.add(articleParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = ArticleParam.update.class)
|
||||
@RequestBody ArticleParam articleParam) {
|
||||
iArticleArchivesService.edit(articleParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = ArticleParam.delete.class)
|
||||
@RequestBody ArticleParam articleParam) {
|
||||
iArticleArchivesService.del(articleParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.mdd.admin.controller.article;
|
||||
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.article.IArticleCategoryService;
|
||||
import com.mdd.admin.validate.article.CategoryParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.article.ArticleCateVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文章分类管理
|
||||
*/
|
||||
@RestController("articleCategoryController")
|
||||
@RequestMapping("api/article/cate")
|
||||
public class CategoryController {
|
||||
|
||||
@Resource
|
||||
IArticleCategoryService iArticleCategoryService;
|
||||
|
||||
/**
|
||||
* 分类所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<ArticleCateVo> list = iArticleCategoryService.all();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<ArticleCateVo> list = iArticleCategoryService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
ArticleCateVo vo = iArticleCategoryService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章分类新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = CategoryParam.create.class)
|
||||
@RequestBody CategoryParam categoryParam) {
|
||||
iArticleCategoryService.add(categoryParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类编辑
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章分类编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = CategoryParam.update.class)
|
||||
@RequestBody CategoryParam categoryParam) {
|
||||
iArticleCategoryService.edit(categoryParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类删除
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "文章分类删除")
|
||||
@PostMapping("/cateDel")
|
||||
public Object del(@Validated(value = CategoryParam.delete.class)
|
||||
@RequestBody CategoryParam categoryParam) {
|
||||
iArticleCategoryService.del(categoryParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.mdd.admin.controller.common;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.common.IAlbumService;
|
||||
import com.mdd.admin.validate.common.AlbumParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.album.AlbumVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 相册管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/common/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(@RequestBody Map<String, Object> params) {
|
||||
if (params.get("ids") == null) {
|
||||
return AjaxResult.failed("缺少ids参数");
|
||||
}
|
||||
|
||||
if (params.get("cid") == null) {
|
||||
return AjaxResult.failed("缺少cid参数");
|
||||
}
|
||||
|
||||
List<Integer> ids = ArrayUtil.objectToListAsInt(params.get("ids"));
|
||||
if (ids.size() <= 0) {
|
||||
return AjaxResult.failed("请至少选择一个文件");
|
||||
}
|
||||
|
||||
iAlbumService.albumMove(ids, Integer.parseInt(params.get("cid").toString()));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册文件删除
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "相册文件删除")
|
||||
@PostMapping("/albumDel")
|
||||
public Object albumDel(@RequestBody Map<String, List<Integer>> params) {
|
||||
if (params.get("ids") == null) {
|
||||
return AjaxResult.failed("缺少ids参数");
|
||||
}
|
||||
|
||||
iAlbumService.albumDel(params.get("ids"));
|
||||
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,48 @@
|
||||
package com.mdd.admin.controller.common;
|
||||
|
||||
import com.mdd.admin.service.common.IIndexService;
|
||||
import com.mdd.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/common/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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共配置
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
public Object config() {
|
||||
Map<String, Object> map = iIndexService.config();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.mdd.admin.controller.common;
|
||||
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.common.IAlbumService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.enums.AlbumEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.plugin.storage.StorageDriver;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
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/common/upload")
|
||||
public class UploadController {
|
||||
|
||||
@Resource
|
||||
IAlbumService iAlbumService;
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求对象
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "上传图片")
|
||||
@PostMapping("/image")
|
||||
public Object image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed("请正确选择上传图片");
|
||||
}
|
||||
|
||||
if (multipartFile == null) {
|
||||
return AjaxResult.failed("请选择上传图片");
|
||||
}
|
||||
|
||||
try {
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
Map<String, Object> map = storageDriver.upload(multipartFile, "image", AlbumEnum.IMAGE.getCode());
|
||||
String cid = StringUtil.isNotEmpty(request.getParameter("cid")) ? request.getParameter("cid") : "0";
|
||||
|
||||
Map<String, String> album = new LinkedHashMap<>();
|
||||
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
||||
album.put("cid", 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());
|
||||
album.put("name", map.get("name").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;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed("请正确选择上传视频");
|
||||
}
|
||||
|
||||
if (multipartFile == null) {
|
||||
return AjaxResult.failed("请选择上传视频");
|
||||
}
|
||||
|
||||
try {
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
Map<String, Object> map = storageDriver.upload(multipartFile, "video", AlbumEnum.Video.getCode());
|
||||
String cid = StringUtil.isNotEmpty(request.getParameter("cid")) ? request.getParameter("cid") : "0";
|
||||
|
||||
Map<String, String> album = new LinkedHashMap<>();
|
||||
album.put("cid", 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.mdd.admin.controller.monitor;
|
||||
|
||||
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.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(value = "monitorCacheController")
|
||||
@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,30 @@
|
||||
package com.mdd.admin.controller.monitor;
|
||||
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.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(value = "monitorServerController")
|
||||
@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,45 @@
|
||||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import com.mdd.admin.service.setting.ISettingCopyrightService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 网站版权配置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/setting/copyright")
|
||||
public class CopyrightController {
|
||||
|
||||
@Resource
|
||||
ISettingCopyrightService iSettingCopyrightService;
|
||||
|
||||
/**
|
||||
* 获取网站版权信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail() {
|
||||
List<Map<String, String>> list = iSettingCopyrightService.detail();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存网站版本信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody List<Map<String, String>> params) {
|
||||
iSettingCopyrightService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.service.setting.ISettingDictDataService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.setting.DictDataParam;
|
||||
import com.mdd.admin.vo.setting.DictDataVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典数据配置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/setting/dict/data")
|
||||
public class DictDataController {
|
||||
|
||||
@Resource
|
||||
ISettingDictDataService iSettingDictDataService;
|
||||
|
||||
/**
|
||||
* 字典数据所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all(@RequestParam Map<String, String> params) {
|
||||
Assert.isFalse(StringUtil.isEmpty(params.get("dictType")), "dictType缺失");
|
||||
List<DictDataVo> list = iSettingDictDataService.all(params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
Assert.isFalse(StringUtil.isEmpty(params.get("dictType")), "dictType缺失");
|
||||
PageResult<DictDataVo> list = iSettingDictDataService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
DictDataVo vo = iSettingDictDataService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = DictDataParam.create.class) @RequestBody DictDataParam dictDataParam) {
|
||||
iSettingDictDataService.add(dictDataParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = DictDataParam.update.class) @RequestBody DictDataParam dictDataParam) {
|
||||
iSettingDictDataService.edit(dictDataParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = DictDataParam.delete.class) @RequestBody DictDataParam dictDataParam) {
|
||||
iSettingDictDataService.del(dictDataParam.getIds());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import com.mdd.admin.service.setting.ISettingDictTypeService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.setting.DictTypeParam;
|
||||
import com.mdd.admin.vo.setting.DictTypeVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典类型配置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/setting/dict/type")
|
||||
public class DictTypeController {
|
||||
|
||||
@Resource
|
||||
ISettingDictTypeService iSettingDictTypeService;
|
||||
|
||||
/**
|
||||
* 字典类型所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<DictTypeVo> list = iSettingDictTypeService.all();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<DictTypeVo> list = iSettingDictTypeService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
DictTypeVo vo = iSettingDictTypeService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = DictTypeParam.create.class) @RequestBody DictTypeParam dictTypeParam) {
|
||||
iSettingDictTypeService.add(dictTypeParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = DictTypeParam.update.class) @RequestBody DictTypeParam dictTypeParam) {
|
||||
iSettingDictTypeService.edit(dictTypeParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = DictTypeParam.delete.class) @RequestBody DictTypeParam dictTypeParam) {
|
||||
iSettingDictTypeService.del(dictTypeParam.getIds());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import com.mdd.admin.service.setting.ISettingProtocolService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 政策协议配置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/setting/protocol")
|
||||
public class ProtocolController {
|
||||
|
||||
@Resource
|
||||
ISettingProtocolService iSettingProtocolService;
|
||||
|
||||
/**
|
||||
* 获取网站版权信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail() {
|
||||
Map<String, Map<String, String>> detail = iSettingProtocolService.detail();
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存网站版本信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody Map<String, Object> params) {
|
||||
iSettingProtocolService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.service.setting.ISettingStorageService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 存储方式配置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/setting/storage")
|
||||
public class StorageController {
|
||||
|
||||
@Resource
|
||||
ISettingStorageService iSettingStorageService;
|
||||
|
||||
/**
|
||||
* 存储列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list() {
|
||||
List<Map<String, Object>> list = iSettingStorageService.list();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储详情
|
||||
*
|
||||
* @param alias 引擎别名
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(String alias) {
|
||||
Map<String, Object> map = iSettingStorageService.detail(alias);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@RequestBody Map<String, String> params) {
|
||||
iSettingStorageService.edit(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储切换
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/change")
|
||||
public Object change(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("alias"), "alias参数缺失");
|
||||
Assert.notNull(params.get("status"), "status参数缺失");
|
||||
String alias = params.get("alias");
|
||||
Integer status = Integer.parseInt(params.get("status"));
|
||||
iSettingStorageService.change(alias, status);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import com.mdd.admin.service.setting.ISettingWebsiteService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 网站信息配置管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/setting/website")
|
||||
public class WebsiteController {
|
||||
|
||||
@Resource
|
||||
ISettingWebsiteService iSettingWebsiteService;
|
||||
|
||||
/**
|
||||
* 获取网站配置信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail() {
|
||||
Map<String, String> detail = iSettingWebsiteService.detail();
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存网站配置信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody Map<String, String> params) {
|
||||
iSettingWebsiteService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.system.ISystemAuthAdminService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthAdminParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthAdminVo;
|
||||
import com.mdd.admin.vo.system.SystemAuthSelfVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.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 AuthAdminController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthAdminService iSystemAuthAdminService;
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<SystemAuthAdminVo> list = iSystemAuthAdminService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/self")
|
||||
public Object self() {
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
SystemAuthSelfVo vo = iSystemAuthAdminService.self(adminId);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键ID
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemAuthAdminVo vo = iSystemAuthAdminService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemAuthAdminParam.create.class) @RequestBody SystemAuthAdminParam systemAuthAdminParam) {
|
||||
iSystemAuthAdminService.add(systemAuthAdminParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemAuthAdminParam.update.class) @RequestBody SystemAuthAdminParam systemAuthAdminParam) {
|
||||
iSystemAuthAdminService.edit(systemAuthAdminParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前管理员更新
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员更新")
|
||||
@PostMapping("/upInfo")
|
||||
public Object upInfo(@Validated(value = SystemAuthAdminParam.upInfo.class) @RequestBody SystemAuthAdminParam systemAuthAdminParam) {
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
iSystemAuthAdminService.upInfo(systemAuthAdminParam, adminId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员删除
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemAuthAdminParam.delete.class) @RequestBody SystemAuthAdminParam systemAuthAdminParam) {
|
||||
iSystemAuthAdminService.del(systemAuthAdminParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员状态切换
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "管理员状态切换")
|
||||
@PostMapping("/disable")
|
||||
public Object disable(@Validated(value = SystemAuthAdminParam.delete.class) @RequestBody SystemAuthAdminParam systemAuthAdminParam) {
|
||||
iSystemAuthAdminService.disable(systemAuthAdminParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mdd.admin.service.system.ISystemAuthDeptService;
|
||||
import com.mdd.admin.validate.system.SystemAuthDeptParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthDeptVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统部门管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/system/dept")
|
||||
public class AuthDeptController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthDeptService iSystemAuthDeptService;
|
||||
|
||||
/**
|
||||
* 部门所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<SystemAuthDeptVo> vos = iSystemAuthDeptService.all();
|
||||
return AjaxResult.success(vos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@RequestParam Map<String, String> params) {
|
||||
JSONArray list = iSystemAuthDeptService.list(params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemAuthDeptVo vo = iSystemAuthDeptService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemAuthDeptParam.create.class) @RequestBody SystemAuthDeptParam systemAuthDeptParam) {
|
||||
iSystemAuthDeptService.add(systemAuthDeptParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemAuthDeptParam.update.class) @RequestBody SystemAuthDeptParam systemAuthDeptParam) {
|
||||
iSystemAuthDeptService.edit(systemAuthDeptParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemAuthDeptParam.delete.class) @RequestBody SystemAuthDeptParam systemAuthDeptParam) {
|
||||
iSystemAuthDeptService.del(systemAuthDeptParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.system.ISystemAuthMenuService;
|
||||
import com.mdd.admin.validate.system.SystemAuthMenuParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthMenuVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.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 AuthMenuController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthMenuService iSystemAuthMenuService;
|
||||
|
||||
/**
|
||||
* 获取菜单路由
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/route")
|
||||
public Object route() {
|
||||
Integer roleId = LikeAdminThreadLocal.getRoleId();
|
||||
JSONArray lists = iSystemAuthMenuService.selectMenuByRoleId(roleId);
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list() {
|
||||
JSONArray lists = iSystemAuthMenuService.list();
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemAuthMenuVo vo = iSystemAuthMenuService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "菜单新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemAuthMenuParam.create.class) @RequestBody SystemAuthMenuParam systemAuthMenuParam) {
|
||||
iSystemAuthMenuService.add(systemAuthMenuParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "菜单编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemAuthMenuParam.update.class) @RequestBody SystemAuthMenuParam systemAuthMenuParam) {
|
||||
iSystemAuthMenuService.edit(systemAuthMenuParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "菜单删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemAuthMenuParam.delete.class) @RequestBody SystemAuthMenuParam systemAuthMenuParam) {
|
||||
iSystemAuthMenuService.del(systemAuthMenuParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.service.system.ISystemAuthPostService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthPostParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthPostVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统岗位管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/system/post")
|
||||
public class AuthPostController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthPostService iSystemAuthPostService;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<SystemAuthPostVo> vos = iSystemAuthPostService.all();
|
||||
return AjaxResult.success(vos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<SystemAuthPostVo> list = iSystemAuthPostService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemAuthPostVo vo = iSystemAuthPostService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemAuthPostParam.create.class) @RequestBody SystemAuthPostParam systemAuthPostParam) {
|
||||
iSystemAuthPostService.add(systemAuthPostParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemAuthPostParam.update.class) @RequestBody SystemAuthPostParam systemAuthPostParam) {
|
||||
iSystemAuthPostService.edit(systemAuthPostParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemAuthPostParam.delete.class) @RequestBody SystemAuthPostParam systemAuthPostParam) {
|
||||
iSystemAuthPostService.del(systemAuthPostParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.system.ISystemAuthRoleService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthRoleParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthRoleVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统角色管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/system/role")
|
||||
public class AuthRoleController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthRoleService iSystemAuthRoleService;
|
||||
|
||||
/**
|
||||
* 角色所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<Map<String, Object>> list = iSystemAuthRoleService.all();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色列表")
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam) {
|
||||
PageResult<SystemAuthRoleVo> lists = iSystemAuthRoleService.list(pageParam);
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色详情")
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemAuthRoleVo vo = iSystemAuthRoleService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 角色参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemAuthRoleParam.create.class) @RequestBody SystemAuthRoleParam systemAuthRoleParam) {
|
||||
iSystemAuthRoleService.add(systemAuthRoleParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 角色参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemAuthRoleParam.create.class) @RequestBody SystemAuthRoleParam systemAuthRoleParam) {
|
||||
iSystemAuthRoleService.edit(systemAuthRoleParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 角色参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "角色删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemAuthRoleParam.delete.class) @RequestBody SystemAuthRoleParam systemAuthRoleParam) {
|
||||
iSystemAuthRoleService.del(systemAuthRoleParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.service.system.ISystemLoginService;
|
||||
import com.mdd.admin.validate.system.SystemLoginParam;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.exception.LoginException;
|
||||
import com.mdd.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("systemLoginController")
|
||||
@RequestMapping("api/system")
|
||||
public class LoginController {
|
||||
|
||||
@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,54 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.service.system.ISystemLogsServer;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.system.LogLoginVo;
|
||||
import com.mdd.admin.vo.system.LogOperateVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.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("systemLogController")
|
||||
@RequestMapping("api/system/log")
|
||||
public class LogsController {
|
||||
|
||||
@Resource
|
||||
ISystemLogsServer iSystemLogsServer;
|
||||
|
||||
/**
|
||||
* 系统操作日志
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/operate")
|
||||
public Object operate(@Validated PageParam pageParam, @RequestParam Map<String, String> params) {
|
||||
PageResult<LogOperateVo> list = iSystemLogsServer.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 = iSystemLogsServer.login(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.mdd.admin.service.article;
|
||||
|
||||
import com.mdd.admin.validate.article.ArticleParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.article.ArticleDetailVo;
|
||||
import com.mdd.admin.vo.article.ArticleListVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文章服务接口类
|
||||
*/
|
||||
public interface IArticleArchivesService {
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
PageResult<ArticleListVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键ID
|
||||
*/
|
||||
ArticleDetailVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 文章新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
*/
|
||||
void add(ArticleParam articleParam);
|
||||
|
||||
/**
|
||||
* 文章编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param articleParam 文章参数
|
||||
*/
|
||||
void edit(ArticleParam articleParam);
|
||||
|
||||
/**
|
||||
* 文章删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文章主键
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mdd.admin.service.article;
|
||||
|
||||
import com.mdd.admin.validate.article.CategoryParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.article.ArticleCateVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文章分类服接口务类
|
||||
*/
|
||||
public interface IArticleCategoryService {
|
||||
|
||||
/**
|
||||
* 分类所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<CategoryVo>
|
||||
*/
|
||||
List<ArticleCateVo> all();
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<CategoryVo>
|
||||
*/
|
||||
PageResult<ArticleCateVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 分类详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
ArticleCateVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 分类新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类参数
|
||||
*/
|
||||
void add(CategoryParam categoryParam);
|
||||
|
||||
/**
|
||||
* 分类编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param categoryParam 分类参数
|
||||
*/
|
||||
void edit(CategoryParam categoryParam);
|
||||
|
||||
/**
|
||||
* 分类删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 分类ID
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.mdd.admin.service.article.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.mdd.admin.service.article.IArticleArchivesService;
|
||||
import com.mdd.admin.validate.article.ArticleParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.article.ArticleDetailVo;
|
||||
import com.mdd.admin.vo.article.ArticleListVo;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.article.Article;
|
||||
import com.mdd.common.entity.article.ArticleCategory;
|
||||
import com.mdd.common.mapper.article.ArticleCategoryMapper;
|
||||
import com.mdd.common.mapper.article.ArticleMapper;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.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.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文章服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ArticleArchivesServiceImpl implements IArticleArchivesService {
|
||||
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Resource
|
||||
ArticleCategoryMapper articleCategoryMapper;
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ArticleListVo> list(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("?_article_category ac ON ac.id=t.cid".replace("?_", GlobalConfig.tablePrefix))
|
||||
.eq("t.is_delete", 0)
|
||||
.orderByDesc(Arrays.asList("t.sort", "t.id"));
|
||||
|
||||
articleMapper.setSearch(mpjQueryWrapper, params, new String[]{
|
||||
"like:title@t.title:str",
|
||||
"=:cid@t.cid:int",
|
||||
"=:isShow@t.is_show:int",
|
||||
"datetime:startTime-endTime@t.create_time:str"
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
public ArticleDetailVo detail(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 add(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 edit(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 del(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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.mdd.admin.service.article.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.mdd.admin.service.article.IArticleCategoryService;
|
||||
import com.mdd.admin.validate.article.CategoryParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.article.ArticleCateVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.article.ArticleCategory;
|
||||
import com.mdd.common.mapper.article.ArticleCategoryMapper;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文章分类服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ArticleCategoryServiceImpl implements IArticleCategoryService {
|
||||
|
||||
@Resource
|
||||
ArticleCategoryMapper articleCategoryMapper;
|
||||
|
||||
/**
|
||||
* 分类所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<CategoryVo>
|
||||
*/
|
||||
@Override
|
||||
public List<ArticleCateVo> all() {
|
||||
QueryWrapper<ArticleCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id", "name", "sort", "is_show", "create_time", "update_time")
|
||||
.eq("is_delete", 0);
|
||||
|
||||
List<ArticleCategory> lists = articleCategoryMapper.selectList(queryWrapper);
|
||||
|
||||
List<ArticleCateVo> vos = new ArrayList<>();
|
||||
for (ArticleCategory category : lists) {
|
||||
ArticleCateVo vo = new ArticleCateVo();
|
||||
BeanUtils.copyProperties(category, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(vo.getUpdateTime()));
|
||||
vos.add(vo);
|
||||
}
|
||||
|
||||
return vos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<CategoryVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ArticleCateVo> list(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);
|
||||
|
||||
articleCategoryMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:name:str",
|
||||
"=:isShow@is_show:int"
|
||||
});
|
||||
|
||||
IPage<ArticleCategory> iPage = articleCategoryMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<ArticleCateVo> list = new ArrayList<>();
|
||||
for (ArticleCategory category : iPage.getRecords()) {
|
||||
ArticleCateVo vo = new ArticleCateVo();
|
||||
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 ArticleCateVo detail(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, "分类不存在");
|
||||
|
||||
ArticleCateVo vo = new ArticleCateVo();
|
||||
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 add(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 edit(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 del(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,91 @@
|
||||
package com.mdd.admin.service.common;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mdd.admin.validate.common.AlbumParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.album.AlbumVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
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 ids 文件ID
|
||||
* @param cid 类目ID
|
||||
*/
|
||||
void albumMove(List<Integer> ids, Integer cid);
|
||||
|
||||
/**
|
||||
* 文件新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 文件信息参数
|
||||
*/
|
||||
Integer albumAdd(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 文件删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param ids 文件ID
|
||||
*/
|
||||
void albumDel(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
*
|
||||
* @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,23 @@
|
||||
package com.mdd.admin.service.common;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主页服务接口类
|
||||
*/
|
||||
public interface IIndexService {
|
||||
|
||||
/**
|
||||
* 控制台数据
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> console();
|
||||
|
||||
/**
|
||||
* 公共配置
|
||||
*/
|
||||
Map<String, Object> config();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
package com.mdd.admin.service.common.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.mdd.admin.service.common.IAlbumService;
|
||||
import com.mdd.admin.validate.common.AlbumParam;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.album.AlbumCateVo;
|
||||
import com.mdd.admin.vo.album.AlbumVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.album.Album;
|
||||
import com.mdd.common.entity.album.AlbumCate;
|
||||
import com.mdd.common.mapper.album.AlbumCateMapper;
|
||||
import com.mdd.common.mapper.album.AlbumMapper;
|
||||
import com.mdd.common.utils.*;
|
||||
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");
|
||||
|
||||
if (StringUtil.isNotEmpty(params.get("cid"))) {
|
||||
queryWrapper.eq("cid", Integer.parseInt(params.get("cid")));
|
||||
}
|
||||
|
||||
albumMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"=:type:int",
|
||||
"like:keyword@name:str"
|
||||
});
|
||||
|
||||
IPage<Album> iPage = albumMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<AlbumVo> list = new ArrayList<>();
|
||||
for (Album album : iPage.getRecords()) {
|
||||
AlbumVo vo = new AlbumVo();
|
||||
BeanUtils.copyProperties(album, vo);
|
||||
|
||||
vo.setUri(UrlUtil.toAbsoluteUrl(album.getUri()));
|
||||
vo.setSize(ToolsUtil.storageUnit(album.getSize()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(album.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(album.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 相册文件重命名
|
||||
*
|
||||
* @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 ids 文件ID
|
||||
* @param cid 类目ID
|
||||
*/
|
||||
@Override
|
||||
public void albumMove(List<Integer> ids, Integer cid) {
|
||||
List<Album> albums = albumMapper.selectList(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.in("id", ids)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(albums, "文件丢失!");
|
||||
|
||||
Assert.notNull(albumCateMapper.selectOne(
|
||||
new QueryWrapper<AlbumCate>()
|
||||
.eq("id", cid)
|
||||
.eq("is_delete", 0)
|
||||
), "类目已不存在!");
|
||||
|
||||
for (Album album : albums) {
|
||||
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 ids 文件ID
|
||||
*/
|
||||
@Override
|
||||
public void albumDel(List<Integer> ids) {
|
||||
List<Album> albums = albumMapper.selectList(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.in("id", ids)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(albums, "文件丢失!");
|
||||
|
||||
for (Album album : albums) {
|
||||
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,92 @@
|
||||
package com.mdd.admin.service.common.impl;
|
||||
|
||||
import com.mdd.admin.service.common.IIndexService;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.mapper.article.ArticleMapper;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.common.utils.UrlUtil;
|
||||
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("name", ConfigUtil.get("website", "name", "LikeAdmin-Java"));
|
||||
version.put("version", GlobalConfig.version);
|
||||
version.put("website", "www.likeadmin.cn");
|
||||
version.put("based", "Vue3.x、ElementUI、MySQL");
|
||||
Map<String, String> channel = new LinkedHashMap<>();
|
||||
channel.put("gitee", "https://gitee.com/likeadmin/likeadmin_java");
|
||||
channel.put("website", "https://www.likeadmin.cn");
|
||||
version.put("channel", channel);
|
||||
console.put("version", version);
|
||||
|
||||
// 今日数据
|
||||
Map<String, Object> today = new LinkedHashMap<>();
|
||||
today.put("time", "2022-08-11 15:08:29");
|
||||
today.put("todayVisits", 10); // 访问量(人)
|
||||
today.put("totalVisits", 100); // 总访问量
|
||||
today.put("todaySales", 30); // 销售额(元)
|
||||
today.put("totalSales", 65); // 总销售额
|
||||
today.put("todayOrder", 12); // 订单量(笔)
|
||||
today.put("totalOrder", 255); // 总订单量
|
||||
today.put("todayUsers", 120); // 新增用户
|
||||
today.put("totalUsers", 360); // 总访用户
|
||||
console.put("today", today);
|
||||
|
||||
// 访客图表
|
||||
Map<String, Object> visitor = new LinkedHashMap<>();
|
||||
visitor.put("date", TimeUtil.daysAgoDate(15));
|
||||
visitor.put("list", Arrays.asList(12,13,11,5,8,22,14,9,456,62,78,12,18,22,46));
|
||||
console.put("visitor", visitor);
|
||||
|
||||
return console;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共配置
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> config() {
|
||||
Map<String, String> website = ConfigUtil.get("website");
|
||||
String copyright = ConfigUtil.get("website", "copyright", "");
|
||||
|
||||
System.out.println(UrlUtil.toRelativeUrl("http://127.0.0.1:8082/uploads/image/20220426/8984bec1-57d6-4635-a110-fb4b26335879.png"));
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("webName", website.getOrDefault("name", ""));
|
||||
map.put("webLogo", UrlUtil.toAbsoluteUrl(website.getOrDefault("logo", "")));
|
||||
map.put("webFavicon", UrlUtil.toAbsoluteUrl(website.getOrDefault("favicon", "")));
|
||||
map.put("webBackdrop", UrlUtil.toAbsoluteUrl(website.getOrDefault("backdrop", "")));
|
||||
map.put("ossDomain", UrlUtil.domain());
|
||||
map.put("copyright", ArrayUtil.stringToListAsMapStr(copyright));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mdd.admin.service.setting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 网站备案服务接口类
|
||||
*/
|
||||
public interface ISettingCopyrightService {
|
||||
|
||||
/**
|
||||
* 获取网站备案信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
List<Map<String, String>> detail();
|
||||
|
||||
/**
|
||||
* 保存网站备案信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void save(List<Map<String, String>> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mdd.admin.service.setting;
|
||||
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.setting.DictDataParam;
|
||||
import com.mdd.admin.vo.setting.DictDataVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典数据服务接口类
|
||||
*/
|
||||
public interface ISettingDictDataService {
|
||||
|
||||
/**
|
||||
* 字典数据所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<DictDataVo>
|
||||
*/
|
||||
List<DictDataVo> all(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 字典数据列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<DictDataVo>
|
||||
*/
|
||||
PageResult<DictDataVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 字典数据详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return DictDataVo
|
||||
*/
|
||||
DictDataVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 字典数据新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
*/
|
||||
void add(DictDataParam dictDataParam);
|
||||
|
||||
/**
|
||||
* 字典数据编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
*/
|
||||
void edit(DictDataParam dictDataParam);
|
||||
|
||||
/**
|
||||
* 字典数据删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param ids 主键
|
||||
*/
|
||||
void del(List<Integer> ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mdd.admin.service.setting;
|
||||
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.setting.DictTypeParam;
|
||||
import com.mdd.admin.vo.setting.DictTypeVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典类型服务接口类
|
||||
*/
|
||||
public interface ISettingDictTypeService {
|
||||
|
||||
/**
|
||||
* 字典类型所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<DictTypeVo>
|
||||
*/
|
||||
List<DictTypeVo> all();
|
||||
|
||||
/**
|
||||
* 字典类型列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<DictDataVo>
|
||||
*/
|
||||
PageResult<DictTypeVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 字典类型详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return DictDataVo
|
||||
*/
|
||||
DictTypeVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 字典类型新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
*/
|
||||
void add(DictTypeParam dictTypeParam);
|
||||
|
||||
/**
|
||||
* 字典类型编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
*/
|
||||
void edit(DictTypeParam dictTypeParam);
|
||||
|
||||
/**
|
||||
* 字典类型删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param ids 主键
|
||||
*/
|
||||
void del(List<Integer> ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mdd.admin.service.setting;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 政策协议服务接口类
|
||||
*/
|
||||
public interface ISettingProtocolService {
|
||||
|
||||
/**
|
||||
* 获取政策协议信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
Map<String, Map<String, String>> detail();
|
||||
|
||||
/**
|
||||
* 保存政策协议信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void save(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mdd.admin.service.setting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 存储配置服务接口类
|
||||
*/
|
||||
public interface ISettingStorageService {
|
||||
|
||||
/**
|
||||
* 存储列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<Map<String, Object>>
|
||||
*/
|
||||
List<Map<String, Object>> list();
|
||||
|
||||
/**
|
||||
* 存储详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param alias 引擎别名
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> detail(String alias);
|
||||
|
||||
/**
|
||||
* 存储编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void edit(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 存储切换
|
||||
*
|
||||
* @author fzr
|
||||
* @param alias 引擎别名
|
||||
* @param status 状态
|
||||
*/
|
||||
void change(String alias, Integer status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mdd.admin.service.setting;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 网站信息服务接口类
|
||||
*/
|
||||
public interface ISettingWebsiteService {
|
||||
|
||||
/**
|
||||
* 获取网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
Map<String, String> detail();
|
||||
|
||||
/**
|
||||
* 保存网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void save(Map<String, String> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mdd.admin.service.setting.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mdd.admin.service.setting.ISettingCopyrightService;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 网站备案服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SettingCopyrightServiceImpl implements ISettingCopyrightService {
|
||||
|
||||
/**
|
||||
* 获取网站备案信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<Map<String, String>>
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, String>> detail() {
|
||||
String config = ConfigUtil.get("website", "copyright", "[]");
|
||||
return ArrayUtil.stringToListAsMapStr(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存网站备案信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void save(List<Map<String, String>> params) {
|
||||
List<Map<String, String>> list = new LinkedList<>();
|
||||
for (Map<String, String> item : params) {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
if (StringUtil.isNotEmpty(item.get("name")) || StringUtil.isNotEmpty(item.get("link"))) {
|
||||
map.put("name", item.get("name"));
|
||||
map.put("link", item.get("link"));
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
ConfigUtil.set("website", "copyright", JSON.toJSONString(list));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.mdd.admin.service.setting.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.mdd.admin.service.setting.ISettingDictDataService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.setting.DictDataParam;
|
||||
import com.mdd.admin.vo.setting.DictDataVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.setting.DictData;
|
||||
import com.mdd.common.entity.setting.DictType;
|
||||
import com.mdd.common.mapper.setting.DictDataMapper;
|
||||
import com.mdd.common.mapper.setting.DictTypeMapper;
|
||||
import com.mdd.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 SettingDictDataServiceImpl implements ISettingDictDataService {
|
||||
|
||||
@Resource
|
||||
DictDataMapper dictDataMapper;
|
||||
|
||||
@Resource
|
||||
DictTypeMapper dictTypeMapper;
|
||||
|
||||
/**
|
||||
* 字典数据所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<DictDataVo>
|
||||
*/
|
||||
@Override
|
||||
public List<DictDataVo> all(Map<String, String> params) {
|
||||
DictType dictType = dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.eq("dict_type", params.get("dictType"))
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(dictType, "该字典类型不存在!");
|
||||
|
||||
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,type_id,name,value,remark,sort,status,create_time,update_time");
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.eq("type_id", dictType.getId());
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
dictDataMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:name:str",
|
||||
"like:value:str",
|
||||
"=:status:int",
|
||||
});
|
||||
|
||||
List<DictData> dictDataList = dictDataMapper.selectList(queryWrapper);
|
||||
|
||||
List<DictDataVo> list = new LinkedList<>();
|
||||
for (DictData dictData : dictDataList) {
|
||||
DictDataVo vo = new DictDataVo();
|
||||
BeanUtils.copyProperties(dictData, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(dictData.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(dictData.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<DictDataVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<DictDataVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
DictType dictType = dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.eq("is_delete", 0)
|
||||
.eq("dict_type", params.get("dictType"))
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(dictType, "该字典类型不存在!");
|
||||
|
||||
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,type_id,name,value,remark,sort,status,create_time,update_time");
|
||||
queryWrapper.eq("type_id", dictType.getId());
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
dictDataMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:name:str",
|
||||
"like:value:str",
|
||||
"=:status:int",
|
||||
});
|
||||
|
||||
IPage<DictData> iPage = dictDataMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<DictDataVo> list = new LinkedList<>();
|
||||
for (DictData dictData : iPage.getRecords()) {
|
||||
DictDataVo vo = new DictDataVo();
|
||||
BeanUtils.copyProperties(dictData, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(dictData.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(dictData.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return DictDataVo
|
||||
*/
|
||||
@Override
|
||||
public DictDataVo detail(Integer id) {
|
||||
DictData dictData = dictDataMapper.selectOne(new QueryWrapper<DictData>()
|
||||
.select("id,type_id,name,value,remark,sort,status,create_time,update_time")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(dictData, "字典数据不存在!");
|
||||
|
||||
DictDataVo vo = new DictDataVo();
|
||||
BeanUtils.copyProperties(dictData, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(dictData.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(dictData.getUpdateTime()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(DictDataParam dictDataParam) {
|
||||
Assert.isNull(dictDataMapper.selectOne(new QueryWrapper<DictData>()
|
||||
.select("id")
|
||||
.eq("name", dictDataParam.getName())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "字典数据已存在!");
|
||||
|
||||
DictData model = new DictData();
|
||||
model.setTypeId(dictDataParam.getTypeId());
|
||||
model.setName(dictDataParam.getName());
|
||||
model.setValue(dictDataParam.getValue());
|
||||
model.setRemark(dictDataParam.getRemark());
|
||||
model.setSort(dictDataParam.getSort());
|
||||
model.setStatus(dictDataParam.getStatus());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
dictDataMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictDataParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(DictDataParam dictDataParam) {
|
||||
DictData model = dictDataMapper.selectOne(new QueryWrapper<DictData>()
|
||||
.eq("id", dictDataParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "字典数据不存在!");
|
||||
|
||||
Assert.isNull(dictDataMapper.selectOne(new QueryWrapper<DictData>()
|
||||
.select("id")
|
||||
.ne("id", dictDataParam.getId())
|
||||
.eq("name", dictDataParam.getName())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "字典数据已存在!");
|
||||
|
||||
model.setName(dictDataParam.getName());
|
||||
model.setValue(dictDataParam.getValue());
|
||||
model.setRemark(dictDataParam.getRemark());
|
||||
model.setSort(dictDataParam.getSort());
|
||||
model.setStatus(dictDataParam.getStatus());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
dictDataMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param ids 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
DictData model = new DictData();
|
||||
model.setId(id);
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
dictDataMapper.updateById(model);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.mdd.admin.service.setting.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.mdd.admin.service.setting.ISettingDictTypeService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.setting.DictTypeParam;
|
||||
import com.mdd.admin.vo.setting.DictTypeVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.setting.DictType;
|
||||
import com.mdd.common.mapper.setting.DictTypeMapper;
|
||||
import com.mdd.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 SettingDictTypeServiceImpl implements ISettingDictTypeService {
|
||||
|
||||
@Resource
|
||||
DictTypeMapper dictTypeMapper;
|
||||
|
||||
/**
|
||||
* 字典类型所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<DictTypeVo>
|
||||
*/
|
||||
@Override
|
||||
public List<DictTypeVo> all() {
|
||||
QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,dict_name,dict_type,dict_remark,dict_status,create_time,update_time");
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
List<DictType> dictTypeList = dictTypeMapper.selectList(queryWrapper);
|
||||
|
||||
List<DictTypeVo> list = new LinkedList<>();
|
||||
for (DictType dictType : dictTypeList) {
|
||||
DictTypeVo vo = new DictTypeVo();
|
||||
BeanUtils.copyProperties(dictType, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(dictType.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(dictType.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<DictDataVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<DictTypeVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,dict_name,dict_type,dict_remark,dict_status,create_time,update_time");
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
dictTypeMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:dictName@dict_name:str",
|
||||
"like:dictType@dict_type:str",
|
||||
"=:dictStatus@dict_status:int",
|
||||
});
|
||||
|
||||
IPage<DictType> iPage = dictTypeMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<DictTypeVo> list = new LinkedList<>();
|
||||
for (DictType dictType : iPage.getRecords()) {
|
||||
DictTypeVo vo = new DictTypeVo();
|
||||
BeanUtils.copyProperties(dictType, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(dictType.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(dictType.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return DictDataVo
|
||||
*/
|
||||
@Override
|
||||
public DictTypeVo detail(Integer id) {
|
||||
DictType dictType = dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.select("id,dict_name,dict_type,dict_remark,dict_status,create_time,update_time")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(dictType, "字典类型不存在!");
|
||||
|
||||
DictTypeVo vo = new DictTypeVo();
|
||||
BeanUtils.copyProperties(dictType, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(dictType.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(dictType.getUpdateTime()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(DictTypeParam dictTypeParam) {
|
||||
Assert.isNull(dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.select("id")
|
||||
.eq("dict_name", dictTypeParam.getDictName())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "字典名称已存在!");
|
||||
|
||||
Assert.isNull(dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.select("id")
|
||||
.eq("dict_type", dictTypeParam.getDictType())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "字典类型已存在!");
|
||||
|
||||
DictType model = new DictType();
|
||||
model.setDictName(dictTypeParam.getDictName());
|
||||
model.setDictType(dictTypeParam.getDictType());
|
||||
model.setDictRemark(dictTypeParam.getDictRemark());
|
||||
model.setDictStatus(dictTypeParam.getDictStatus());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
dictTypeMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param dictTypeParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(DictTypeParam dictTypeParam) {
|
||||
DictType model = dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.eq("id", dictTypeParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "字典类型不存在!");
|
||||
|
||||
Assert.isNull(dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.ne("id", dictTypeParam.getId())
|
||||
.eq("dict_name", dictTypeParam.getDictName())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "字典类型已存在!");
|
||||
|
||||
Assert.isNull(dictTypeMapper.selectOne(new QueryWrapper<DictType>()
|
||||
.ne("id", dictTypeParam.getId())
|
||||
.eq("dict_type", dictTypeParam.getDictType())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "字典类型已存在!");
|
||||
|
||||
model.setDictName(dictTypeParam.getDictName());
|
||||
model.setDictType(dictTypeParam.getDictType());
|
||||
model.setDictRemark(dictTypeParam.getDictRemark());
|
||||
model.setDictStatus(dictTypeParam.getDictStatus());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
dictTypeMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param ids 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(List<Integer> ids) {
|
||||
for(Integer id : ids) {
|
||||
DictType model = new DictType();
|
||||
model.setId(id);
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
dictTypeMapper.updateById(model);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mdd.admin.service.setting.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mdd.admin.service.setting.ISettingProtocolService;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 政策接口服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SettingProtocolServiceImpl implements ISettingProtocolService {
|
||||
|
||||
/**
|
||||
* 获取政策协议信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Map<String, String>>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Map<String, String>> detail() {
|
||||
String service = ConfigUtil.get("protocol", "service", "{\"name\":\"\",\"content\":\"\"}");
|
||||
String privacy = ConfigUtil.get("protocol", "privacy", "{\"name\":\"\",\"content\":\"\"}");
|
||||
|
||||
Map<String, Map<String, String>> map = new LinkedHashMap<>();
|
||||
map.put("service", ToolsUtil.jsonToMap(service));
|
||||
map.put("privacy", ToolsUtil.jsonToMap(privacy));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存政策协议信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void save(Map<String, Object> params) {
|
||||
ConfigUtil.set("protocol","service", JSON.toJSONString(params.get("service")));
|
||||
ConfigUtil.set("protocol","privacy", JSON.toJSONString(params.get("privacy")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.mdd.admin.service.setting.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.service.setting.ISettingStorageService;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 存储配置服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SettingStorageServiceImpl implements ISettingStorageService {
|
||||
|
||||
/**
|
||||
* 存储列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<Map<String, Object>>
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> list() {
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
List<Map<String, Object>> list = new LinkedList<>();
|
||||
|
||||
Map<String, Object> local = new LinkedHashMap<>();
|
||||
local.put("name", "本地存储");
|
||||
local.put("alias", "local");
|
||||
local.put("describe", "存储在本地服务器");
|
||||
local.put("status", engine.equals("local") ? 1 : 0);
|
||||
list.add(local);
|
||||
|
||||
Map<String, Object> qiniu = new LinkedHashMap<>();
|
||||
qiniu.put("name", "七牛云存储");
|
||||
qiniu.put("alias", "qiniu");
|
||||
qiniu.put("describe", "存储在七牛云,请前往七牛云开通存储服务");
|
||||
qiniu.put("status", engine.equals("qiniu") ? 1 : 0);
|
||||
list.add(qiniu);
|
||||
|
||||
Map<String, Object> aliyun = new LinkedHashMap<>();
|
||||
aliyun.put("name", "阿里云才能出");
|
||||
aliyun.put("alias", "aliyun");
|
||||
aliyun.put("describe", "存储在阿里云,请前往阿里云开通存储服务");
|
||||
aliyun.put("status", engine.equals("aliyun") ? 1 : 0);
|
||||
list.add(aliyun);
|
||||
|
||||
Map<String, Object> qcloud = new LinkedHashMap<>();
|
||||
qcloud.put("name", "腾讯云存储");
|
||||
qcloud.put("alias", "qcloud");
|
||||
qcloud.put("describe", "存储在腾讯云,请前往腾讯云开通存储服务");
|
||||
qcloud.put("status", engine.equals("qcloud") ? 1 : 0);
|
||||
list.add(qcloud);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param alias 存储别名
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> detail(String alias) {
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
Map<String, String> config = ConfigUtil.getMap("storage", alias);
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("name", config.getOrDefault("name", ""));
|
||||
map.put("alias", alias);
|
||||
map.put("status", engine.equals(alias) ? 1 : 0);
|
||||
if (!alias.equals("local")) {
|
||||
map.put("bucket", config.getOrDefault("bucket", ""));
|
||||
map.put("secretKey", config.getOrDefault("secretKey", ""));
|
||||
map.put("accessKey", config.getOrDefault("accessKey", ""));
|
||||
map.put("domain", config.getOrDefault("domain", ""));
|
||||
if (alias.equals("qcloud")) {
|
||||
map.put("region", config.getOrDefault("region", ""));
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(Map<String, String> params) {
|
||||
Assert.notNull(params.get("alias"), "alias参数缺失");
|
||||
Assert.notNull(params.get("status"), "status参数缺失");
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
System.out.println("斤斤计较");
|
||||
System.out.println(params);
|
||||
map.put("name", "本地存储");
|
||||
if (!params.get("alias").equals("local")) {
|
||||
map.put("bucket", params.getOrDefault("bucket", ""));
|
||||
map.put("secretKey", params.getOrDefault("secretKey", ""));
|
||||
map.put("accessKey", params.getOrDefault("accessKey", ""));
|
||||
map.put("domain", params.getOrDefault("domain", ""));
|
||||
switch (params.get("alias")) {
|
||||
case "qcloud":
|
||||
map.put("name", "腾讯云存储");
|
||||
map.put("region", params.getOrDefault("region", ""));
|
||||
break;
|
||||
case "qiniu":
|
||||
map.put("name", "七牛云存储");
|
||||
break;
|
||||
case "aliyun":
|
||||
map.put("name", "阿里云存储");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigUtil.set("storage", params.get("alias"), JSON.toJSONString(map));
|
||||
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
if (Integer.parseInt(params.get("status")) == 1) {
|
||||
ConfigUtil.set("storage", "default", params.get("alias"));
|
||||
} else if (engine.equals(params.get("alias")) && Integer.parseInt(params.get("status")) == 0) {
|
||||
ConfigUtil.set("storage", "default", params.get(""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 引擎切换
|
||||
*
|
||||
* @author fzr
|
||||
* @param alias 引擎别名
|
||||
* @param status 状态
|
||||
*/
|
||||
@Override
|
||||
public void change(String alias, Integer status) {
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
if (engine.equals(alias) && status == 0) {
|
||||
ConfigUtil.set("storage", "default", "");
|
||||
} else {
|
||||
ConfigUtil.set("storage", "default", alias);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mdd.admin.service.setting.impl;
|
||||
|
||||
import com.mdd.admin.service.setting.ISettingWebsiteService;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.UrlUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 网站信息配置服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SettingWebsiteServiceImpl implements ISettingWebsiteService {
|
||||
|
||||
/**
|
||||
* 获取网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> detail() {
|
||||
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("favicon", UrlUtil.toAbsoluteUrl(config.getOrDefault("favicon", "")));
|
||||
map.put("backdrop", UrlUtil.toAbsoluteUrl(config.getOrDefault("backdrop", "")));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存网站信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void save(Map<String, String> params) {
|
||||
ConfigUtil.set("website", "name", params.getOrDefault("name", ""));
|
||||
ConfigUtil.set("website", "logo", UrlUtil.toRelativeUrl(params.getOrDefault("logo", "")));
|
||||
ConfigUtil.set("website", "favicon", UrlUtil.toRelativeUrl(params.getOrDefault("favicon", "")));
|
||||
ConfigUtil.set("website", "backdrop", UrlUtil.toRelativeUrl(params.getOrDefault("backdrop", "")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthAdminParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthAdminVo;
|
||||
import com.mdd.admin.vo.system.SystemAuthSelfVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统管理员服务接口类
|
||||
*/
|
||||
public interface ISystemAuthAdminService {
|
||||
|
||||
/**
|
||||
* 根据账号查找管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param username 主键ID
|
||||
* @return SysAdmin
|
||||
*/
|
||||
SystemAuthAdmin findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return PageResult<SysAdminListVo>
|
||||
*/
|
||||
PageResult<SystemAuthAdminVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 当前管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @return SystemSelfVo
|
||||
*/
|
||||
SystemAuthSelfVo self(Integer adminId);
|
||||
|
||||
/**
|
||||
* 管理员详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysAdmin
|
||||
*/
|
||||
SystemAuthAdminVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 管理员新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
*/
|
||||
void add(SystemAuthAdminParam systemAuthAdminParam);
|
||||
|
||||
/**
|
||||
* 管理员编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
*/
|
||||
void edit(SystemAuthAdminParam systemAuthAdminParam);
|
||||
|
||||
/**
|
||||
* 当前管理员更新
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
*/
|
||||
void upInfo(SystemAuthAdminParam systemAuthAdminParam, Integer adminId);
|
||||
|
||||
/**
|
||||
* 管理员删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
/**
|
||||
* 管理员状态切换
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
void disable(Integer id);
|
||||
|
||||
/**
|
||||
* 缓存管理员
|
||||
*/
|
||||
void cacheAdminUserByUid(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mdd.admin.validate.system.SystemAuthDeptParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthDeptVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统部门服务接口类
|
||||
*/
|
||||
public interface ISystemAuthDeptService {
|
||||
|
||||
/**
|
||||
* 部门所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemDeptVo>
|
||||
*/
|
||||
List<SystemAuthDeptVo> all();
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 搜索参数
|
||||
* @return JSONArray
|
||||
*/
|
||||
JSONArray list(Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 部门详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SysMenu
|
||||
*/
|
||||
SystemAuthDeptVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 部门新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
*/
|
||||
void add(SystemAuthDeptParam systemAuthDeptParam);
|
||||
|
||||
/**
|
||||
* 部门编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
*/
|
||||
void edit(SystemAuthDeptParam systemAuthDeptParam);
|
||||
|
||||
/**
|
||||
* 部门删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mdd.admin.validate.system.SystemAuthMenuParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthMenuVo;
|
||||
|
||||
/**
|
||||
* 系统菜单服务接口类
|
||||
*/
|
||||
public interface ISystemAuthMenuService {
|
||||
|
||||
/**
|
||||
* 根据角色获取菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @return JSONArray
|
||||
*/
|
||||
JSONArray selectMenuByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return JSONArray
|
||||
*/
|
||||
JSONArray list();
|
||||
|
||||
/**
|
||||
* 菜单详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SysMenu
|
||||
*/
|
||||
SystemAuthMenuVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 菜单新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthMenuParam 参数
|
||||
*/
|
||||
void add(SystemAuthMenuParam systemAuthMenuParam);
|
||||
|
||||
/**
|
||||
* 菜单编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthMenuParam 参数
|
||||
*/
|
||||
void edit(SystemAuthMenuParam systemAuthMenuParam);
|
||||
|
||||
/**
|
||||
* 菜单删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色菜单服务接口类
|
||||
*/
|
||||
public interface ISystemAuthPermService {
|
||||
|
||||
/**
|
||||
* 根据角色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,67 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthPostParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthPostVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统岗位服务接口类
|
||||
*/
|
||||
public interface ISystemAuthPostService {
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemPostVo>
|
||||
*/
|
||||
List<SystemAuthPostVo> all();
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<SystemPostVo>
|
||||
*/
|
||||
PageResult<SystemAuthPostVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SystemPostVo
|
||||
*/
|
||||
SystemAuthPostVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 岗位新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
*/
|
||||
void add(SystemAuthPostParam systemAuthPostParam);
|
||||
|
||||
/**
|
||||
* 岗位编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
*/
|
||||
void edit(SystemAuthPostParam systemAuthPostParam);
|
||||
|
||||
/**
|
||||
* 岗位删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthRoleParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthRoleVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统角色服务接口类
|
||||
*/
|
||||
public interface ISystemAuthRoleService {
|
||||
|
||||
/**
|
||||
* 角色所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemAuthRoleVo>
|
||||
*/
|
||||
List<Map<String, Object>> all();
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 参数
|
||||
* @return PageResult<SysRoleListVo>
|
||||
*/
|
||||
PageResult<SystemAuthRoleVo> list(@Validated PageParam pageParam);
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysRole
|
||||
*/
|
||||
SystemAuthRoleVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 角色新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 参数
|
||||
*/
|
||||
void add(SystemAuthRoleParam systemAuthRoleParam);
|
||||
|
||||
/**
|
||||
* 角色更新
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 参数
|
||||
*/
|
||||
void edit(SystemAuthRoleParam systemAuthRoleParam);
|
||||
|
||||
/**
|
||||
* 角色删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.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,34 @@
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.system.LogLoginVo;
|
||||
import com.mdd.admin.vo.system.LogOperateVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统日志服务类接口类
|
||||
*/
|
||||
public interface ISystemLogsServer {
|
||||
|
||||
/**
|
||||
* 系统操作日志
|
||||
*
|
||||
* @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,433 @@
|
||||
package com.mdd.admin.service.system.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.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.system.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.system.ISystemAuthRoleService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthAdminParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthAdminVo;
|
||||
import com.mdd.admin.vo.system.SystemAuthRoleVo;
|
||||
import com.mdd.admin.vo.system.SystemAuthSelfVo;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemAuthMenu;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
||||
import com.mdd.common.utils.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 系统管理员服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthMenuMapper systemAuthMenuMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAuthRoleService iSystemAuthRoleService;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
/**
|
||||
* 根据账号查找管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param username 主键ID
|
||||
* @return SysAdmin
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthAdmin findByUsername(String username) {
|
||||
return systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.eq("username", username)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return PageResult<SysAdminListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SystemAuthAdminVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
MPJQueryWrapper<SystemAuthAdmin> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||
mpjQueryWrapper.select("t.id,t.dept_id,t.post_id,t.username,t.nickname,t.avatar," +
|
||||
"sd.name as dept,sr.name as role,t.is_multipoint,t.is_disable," +
|
||||
"t.last_login_ip,t.last_login_time,t.create_time,t.update_time")
|
||||
.eq("t.is_delete", 0)
|
||||
.leftJoin("?_system_auth_role sr ON sr.id=t.role".replace("?_", GlobalConfig.tablePrefix))
|
||||
.leftJoin("?_system_auth_dept sd ON sd.id=t.dept_id".replace("?_", GlobalConfig.tablePrefix))
|
||||
.orderByDesc(Arrays.asList("t.id", "t.sort"));
|
||||
|
||||
systemAuthAdminMapper.setSearch(mpjQueryWrapper, params, new String[]{
|
||||
"like:username:str",
|
||||
"like:nickname:str",
|
||||
"=:role:int"
|
||||
});
|
||||
|
||||
IPage<SystemAuthAdminVo> iPage = systemAuthAdminMapper.selectJoinPage(
|
||||
new Page<>(page, limit),
|
||||
SystemAuthAdminVo.class,
|
||||
mpjQueryWrapper);
|
||||
|
||||
for (SystemAuthAdminVo vo : iPage.getRecords()) {
|
||||
if (vo.getId() == 1) {
|
||||
vo.setRole("系统管理员");
|
||||
}
|
||||
|
||||
if (vo.getDept() == null) {
|
||||
vo.setDept("");
|
||||
}
|
||||
|
||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(vo.getUpdateTime()));
|
||||
vo.setLastLoginTime(TimeUtil.timestampToDate(vo.getLastLoginTime()));
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @return SystemSelfVo
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthSelfVo self(Integer adminId) {
|
||||
// 管理员信息
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(SystemAuthAdmin.class, info->
|
||||
!info.getColumn().equals("salt") &&
|
||||
!info.getColumn().equals("password") &&
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("is_delete", 0)
|
||||
.eq("id", adminId)
|
||||
.last("limit 1"));
|
||||
|
||||
SystemAuthAdminVo systemAuthAdminVo = new SystemAuthAdminVo();
|
||||
BeanUtils.copyProperties(sysAdmin, systemAuthAdminVo);
|
||||
systemAuthAdminVo.setDept(String.valueOf(sysAdmin.getDeptId()));
|
||||
systemAuthAdminVo.setRole(String.valueOf(sysAdmin.getRole()));
|
||||
systemAuthAdminVo.setAvatar(UrlUtil.toAbsoluteUrl(sysAdmin.getAvatar()));
|
||||
systemAuthAdminVo.setUpdateTime(TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
systemAuthAdminVo.setCreateTime(TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
||||
systemAuthAdminVo.setLastLoginTime(TimeUtil.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
|
||||
// 角色权限
|
||||
List<String> auths = new LinkedList<>();
|
||||
if (adminId > 1) {
|
||||
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(sysAdmin.getRole());
|
||||
if (menuIds.size() > 0) {
|
||||
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(new QueryWrapper<SystemAuthMenu>()
|
||||
.eq("is_disable", 0)
|
||||
.in("id", menuIds)
|
||||
.in("menu_type", Arrays.asList("C", "A"))
|
||||
.orderByAsc(Arrays.asList("menu_sort", "id")));
|
||||
|
||||
// 处理权限
|
||||
for (SystemAuthMenu item : systemAuthMenus) {
|
||||
if (StringUtil.isNotNull(item.getPerms()) && StringUtil.isNotEmpty(item.getPerms())) {
|
||||
auths.add(item.getPerms().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 没有权限
|
||||
if (auths.size() <= 0) {
|
||||
auths.add("");
|
||||
}
|
||||
} else {
|
||||
// 所有权限
|
||||
auths.add("*");
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
SystemAuthSelfVo vo = new SystemAuthSelfVo();
|
||||
vo.setUser(systemAuthAdminVo);
|
||||
vo.setPermissions(auths);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员详细
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SysAdmin
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthAdminVo detail(Integer id) {
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(SystemAuthAdmin.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, "账号已不存在!");
|
||||
|
||||
SystemAuthAdminVo vo = new SystemAuthAdminVo();
|
||||
BeanUtils.copyProperties(sysAdmin, vo);
|
||||
|
||||
vo.setDept(String.valueOf(vo.getDeptId()));
|
||||
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 systemAuthAdminParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemAuthAdminParam systemAuthAdminParam) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("username", systemAuthAdminParam.getUsername())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", systemAuthAdminParam.getNickname())
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
|
||||
SystemAuthRoleVo roleVo = iSystemAuthRoleService.detail(systemAuthAdminParam.getRole());
|
||||
Assert.notNull(roleVo, "角色不存在!");
|
||||
Assert.isTrue(roleVo.getIsDisable() <= 0, "当前角色已被禁用!");
|
||||
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5(systemAuthAdminParam.getPassword().trim() + salt);
|
||||
String avatar = UrlUtil.toRelativeUrl(systemAuthAdminParam.getAvatar());
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
model.setDeptId(systemAuthAdminParam.getDeptId());
|
||||
model.setPostId(systemAuthAdminParam.getPostId());
|
||||
model.setUsername(systemAuthAdminParam.getUsername());
|
||||
model.setNickname(systemAuthAdminParam.getNickname());
|
||||
model.setRole(systemAuthAdminParam.getRole());
|
||||
model.setAvatar(avatar);
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
model.setSort(systemAuthAdminParam.getSort());
|
||||
model.setIsMultipoint(systemAuthAdminParam.getIsMultipoint());
|
||||
model.setIsDisable(systemAuthAdminParam.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthAdminMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员更新
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemAuthAdminParam systemAuthAdminParam) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("id", systemAuthAdminParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "账号不存在了!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("username", systemAuthAdminParam.getUsername())
|
||||
.ne("id", systemAuthAdminParam.getId())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", systemAuthAdminParam.getNickname())
|
||||
.ne("id", systemAuthAdminParam.getId())
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
|
||||
if (systemAuthAdminParam.getRole() > 0 && systemAuthAdminParam.getId() != 1) {
|
||||
Assert.notNull(iSystemAuthRoleService.detail(systemAuthAdminParam.getRole()), "角色不存在!");
|
||||
}
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
model.setId(systemAuthAdminParam.getId());
|
||||
model.setDeptId(systemAuthAdminParam.getDeptId());
|
||||
model.setPostId(systemAuthAdminParam.getPostId());
|
||||
model.setNickname(systemAuthAdminParam.getNickname());
|
||||
model.setUsername(systemAuthAdminParam.getUsername());
|
||||
model.setAvatar(UrlUtil.toRelativeUrl(systemAuthAdminParam.getAvatar()));
|
||||
model.setRole(systemAuthAdminParam.getId() == 1 ? 0 : systemAuthAdminParam.getRole());
|
||||
model.setSort(systemAuthAdminParam.getSort());
|
||||
model.setIsMultipoint(systemAuthAdminParam.getIsMultipoint());
|
||||
model.setIsDisable(systemAuthAdminParam.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (systemAuthAdminParam.getPassword() != null && !systemAuthAdminParam.getPassword().equals("")) {
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5( systemAuthAdminParam.getPassword().trim() + salt);
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
}
|
||||
|
||||
systemAuthAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(systemAuthAdminParam.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前管理员更新
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthAdminParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void upInfo(SystemAuthAdminParam systemAuthAdminParam, Integer adminId) {
|
||||
String[] field = {"id", "username", "nickname", "password", "salt"};
|
||||
SystemAuthAdmin model = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("id", adminId)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "账号不存在了!");
|
||||
|
||||
model.setNickname(systemAuthAdminParam.getNickname());
|
||||
model.setAvatar( UrlUtil.toRelativeUrl(systemAuthAdminParam.getAvatar()));
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (systemAuthAdminParam.getPassword() != null && !systemAuthAdminParam.getPassword().equals("")) {
|
||||
String currPassword = ToolsUtil.makeMd5(systemAuthAdminParam.getCurrPassword() + model.getSalt());
|
||||
if (!currPassword.equals(model.getPassword())) {
|
||||
throw new OperateException("当前密码不正确!");
|
||||
}
|
||||
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5( systemAuthAdminParam.getPassword().trim() + salt);
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
}
|
||||
|
||||
systemAuthAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(adminId);
|
||||
|
||||
if (systemAuthAdminParam.getPassword() != null) {
|
||||
String token = Objects.requireNonNull(RequestUtil.handler()).getHeader("token");
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey + token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.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, "不能删除自己");
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
model.setId(id);
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员状态切换
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
@Override
|
||||
public void disable(Integer id) {
|
||||
String[] field = {"id", "username", "nickname", "is_disable"};
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemAuthAdmin, "账号已不存在!");
|
||||
|
||||
Integer disable = systemAuthAdmin.getIsDisable() == 1 ? 0 : 1;
|
||||
systemAuthAdmin.setIsDisable(disable);
|
||||
systemAuthAdmin.setUpdateTime(TimeUtil.timestamp());
|
||||
systemAuthAdminMapper.updateById(systemAuthAdmin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存管理员
|
||||
*/
|
||||
@Override
|
||||
public void cacheAdminUserByUid(Integer id) {
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.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("isMultipoint", sysAdmin.getIsDisable());
|
||||
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,221 @@
|
||||
package com.mdd.admin.service.system.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.service.system.ISystemAuthDeptService;
|
||||
import com.mdd.admin.validate.system.SystemAuthDeptParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthDeptVo;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemAuthDept;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthDeptMapper;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import com.mdd.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;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统部门服务实现类
|
||||
*/
|
||||
@Service
|
||||
class SystemAuthDeptServiceImpl implements ISystemAuthDeptService {
|
||||
|
||||
@Resource
|
||||
SystemAuthDeptMapper systemAuthDeptMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemPostVo>
|
||||
*/
|
||||
@Override
|
||||
public List<SystemAuthDeptVo> all() {
|
||||
List<SystemAuthDept> systemAuthDeptList = systemAuthDeptMapper.selectList(new QueryWrapper<SystemAuthDept>()
|
||||
.gt("pid", 0)
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc((Arrays.asList("id", "sort"))));
|
||||
|
||||
List<SystemAuthDeptVo> adminVoArrayList = new ArrayList<>();
|
||||
for (SystemAuthDept systemAuthDept : systemAuthDeptList) {
|
||||
SystemAuthDeptVo vo = new SystemAuthDeptVo();
|
||||
BeanUtils.copyProperties(systemAuthDept, vo);
|
||||
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthDept.getUpdateTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthDept.getCreateTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return adminVoArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 搜索参数
|
||||
* @return JSONArray
|
||||
*/
|
||||
@Override
|
||||
public JSONArray list(Map<String, String> params) {
|
||||
QueryWrapper<SystemAuthDept> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByAsc(Arrays.asList("sort", "id"));
|
||||
queryWrapper.select(SystemAuthDept.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"));
|
||||
|
||||
systemAuthDeptMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:name:str",
|
||||
"=:isStop@is_stop:int"
|
||||
});
|
||||
|
||||
List<SystemAuthDept> systemAuthDeptList = systemAuthDeptMapper.selectList(queryWrapper);
|
||||
|
||||
List<SystemAuthDeptVo> lists = new ArrayList<>();
|
||||
for (SystemAuthDept systemAuthDept : systemAuthDeptList) {
|
||||
SystemAuthDeptVo vo = new SystemAuthDeptVo();
|
||||
BeanUtils.copyProperties(systemAuthDept, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthDept.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthDept.getUpdateTime()));
|
||||
lists.add(vo);
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(lists));
|
||||
return ArrayUtil.listToTree(jsonArray, "id", "pid", "children");
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SystemDeptVo
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthDeptVo detail(Integer id) {
|
||||
SystemAuthDept systemAuthDept = systemAuthDeptMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthDept>()
|
||||
.select(SystemAuthDept.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemAuthDept, "部门已不存在!");
|
||||
|
||||
SystemAuthDeptVo vo = new SystemAuthDeptVo();
|
||||
BeanUtils.copyProperties(systemAuthDept, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthDept.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthDept.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemAuthDeptParam systemAuthDeptParam) {
|
||||
if (systemAuthDeptParam.getPid() == 0) {
|
||||
SystemAuthDept systemAuthDept = systemAuthDeptMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthDept>()
|
||||
.select("id,pid,name")
|
||||
.eq("pid", 0)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.isNull(systemAuthDept, "顶级部门只允许有一个");
|
||||
}
|
||||
|
||||
SystemAuthDept model = new SystemAuthDept();
|
||||
model.setPid(systemAuthDeptParam.getPid());
|
||||
model.setName(systemAuthDeptParam.getName());
|
||||
model.setDuty(systemAuthDeptParam.getDuty());
|
||||
model.setMobile(systemAuthDeptParam.getMobile());
|
||||
model.setSort(systemAuthDeptParam.getSort());
|
||||
model.setIsStop(systemAuthDeptParam.getIsStop());
|
||||
model.setIsDelete(0);
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthDeptMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthDeptParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemAuthDeptParam systemAuthDeptParam) {
|
||||
SystemAuthDept model = systemAuthDeptMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthDept>()
|
||||
.select(SystemAuthDept.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", systemAuthDeptParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "部门不存在");
|
||||
Assert.isFalse((model.getPid() == 0 && systemAuthDeptParam.getPid() > 0), "顶级部门不能修改上级");
|
||||
Assert.isFalse(systemAuthDeptParam.getId().equals(systemAuthDeptParam.getPid()), "上级部门不能是自己");
|
||||
|
||||
model.setPid(systemAuthDeptParam.getPid());
|
||||
model.setName(systemAuthDeptParam.getName());
|
||||
model.setDuty(systemAuthDeptParam.getDuty());
|
||||
model.setMobile(systemAuthDeptParam.getMobile());
|
||||
model.setSort(systemAuthDeptParam.getSort());
|
||||
model.setIsStop(systemAuthDeptParam.getIsStop());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthDeptMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
SystemAuthDept model = systemAuthDeptMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthDept>()
|
||||
.select("id,pid,name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "部门不存在");
|
||||
Assert.isFalse((model.getPid() == 0), "顶级部门不能删除");
|
||||
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select("id,nickname")
|
||||
.eq("dept_id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.isNull(systemAuthAdmin, "该部门已被管理员使用,请先移除");
|
||||
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthDeptMapper.updateById(model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.mdd.admin.service.system.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.system.ISystemAuthMenuService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.admin.validate.system.SystemAuthMenuParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthMenuVo;
|
||||
import com.mdd.common.entity.system.SystemAuthMenu;
|
||||
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.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 SystemAuthMenuServiceImpl implements ISystemAuthMenuService {
|
||||
|
||||
@Resource
|
||||
SystemAuthMenuMapper systemAuthMenuMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
* @return JSONArray
|
||||
*/
|
||||
@Override
|
||||
public JSONArray selectMenuByRoleId(Integer roleId) {
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(roleId);
|
||||
|
||||
QueryWrapper<SystemAuthMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("menu_type", Arrays.asList("M", "C"));
|
||||
queryWrapper.eq("is_disable", 0);
|
||||
queryWrapper.orderByAsc(Arrays.asList("menu_sort", "id"));
|
||||
if (adminId != 1 && menuIds.size() > 0) {
|
||||
queryWrapper.in("id", menuIds);
|
||||
}
|
||||
|
||||
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(queryWrapper);
|
||||
|
||||
List<SystemAuthMenuVo> lists = new ArrayList<>();
|
||||
for (SystemAuthMenu systemAuthMenu : systemAuthMenus) {
|
||||
SystemAuthMenuVo vo = new SystemAuthMenuVo();
|
||||
BeanUtils.copyProperties(systemAuthMenu, vo);
|
||||
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthMenu.getUpdateTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthMenu.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 list() {
|
||||
QueryWrapper<SystemAuthMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc(Arrays.asList("menu_sort", "id"));
|
||||
|
||||
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(queryWrapper);
|
||||
|
||||
List<SystemAuthMenuVo> lists = new ArrayList<>();
|
||||
for (SystemAuthMenu systemAuthMenu : systemAuthMenus) {
|
||||
SystemAuthMenuVo vo = new SystemAuthMenuVo();
|
||||
BeanUtils.copyProperties(systemAuthMenu, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthMenu.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthMenu.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 SystemAuthMenuVo detail(Integer id) {
|
||||
SystemAuthMenu systemAuthMenu = systemAuthMenuMapper.selectOne(new QueryWrapper<SystemAuthMenu>().eq("id", id));
|
||||
Assert.notNull(systemAuthMenu, "菜单已不存在!");
|
||||
|
||||
SystemAuthMenuVo vo = new SystemAuthMenuVo();
|
||||
BeanUtils.copyProperties(systemAuthMenu, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthMenu.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthMenu.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthMenuParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemAuthMenuParam systemAuthMenuParam) {
|
||||
SystemAuthMenu model = new SystemAuthMenu();
|
||||
model.setPid(systemAuthMenuParam.getPid());
|
||||
model.setMenuType(systemAuthMenuParam.getMenuType());
|
||||
model.setMenuName(systemAuthMenuParam.getMenuName());
|
||||
model.setMenuIcon(systemAuthMenuParam.getMenuIcon());
|
||||
model.setMenuSort(systemAuthMenuParam.getMenuSort());
|
||||
model.setPerms(systemAuthMenuParam.getPerms());
|
||||
model.setPaths(systemAuthMenuParam.getPaths());
|
||||
model.setComponent(systemAuthMenuParam.getComponent());
|
||||
model.setSelected(systemAuthMenuParam.getSelected());
|
||||
model.setParams(systemAuthMenuParam.getParams());
|
||||
model.setIsCache(systemAuthMenuParam.getIsCache());
|
||||
model.setIsShow(systemAuthMenuParam.getIsShow());
|
||||
model.setIsDisable(systemAuthMenuParam.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthMenuMapper.insert(model);
|
||||
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthMenuParam 菜单
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemAuthMenuParam systemAuthMenuParam) {
|
||||
SystemAuthMenu model = systemAuthMenuMapper.selectOne(new QueryWrapper<SystemAuthMenu>().eq("id", systemAuthMenuParam.getId()));
|
||||
Assert.notNull(model, "菜单已不存在!");
|
||||
|
||||
model.setMenuType(systemAuthMenuParam.getMenuType());
|
||||
model.setMenuName(systemAuthMenuParam.getMenuName());
|
||||
model.setMenuIcon(systemAuthMenuParam.getMenuIcon());
|
||||
model.setMenuSort(systemAuthMenuParam.getMenuSort());
|
||||
model.setPaths(systemAuthMenuParam.getPaths());
|
||||
model.setPerms(systemAuthMenuParam.getPerms());
|
||||
model.setComponent(systemAuthMenuParam.getComponent());
|
||||
model.setPid(systemAuthMenuParam.getPid());
|
||||
model.setSelected(systemAuthMenuParam.getSelected());
|
||||
model.setParams(systemAuthMenuParam.getParams());
|
||||
model.setIsCache(systemAuthMenuParam.getIsCache());
|
||||
model.setIsShow(systemAuthMenuParam.getIsShow());
|
||||
model.setIsDisable(systemAuthMenuParam.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthMenuMapper.updateById(model);
|
||||
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
SystemAuthMenu model = systemAuthMenuMapper.selectOne(new QueryWrapper<SystemAuthMenu>().eq("id", id));
|
||||
Assert.notNull(model, "菜单已不存在!");
|
||||
|
||||
Assert.isNull(systemAuthMenuMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthMenu>().eq("pid", id)),
|
||||
"请先删除子菜单再操作!");
|
||||
|
||||
systemAuthMenuMapper.deleteById(id);
|
||||
iSystemAuthPermService.batchDeleteByMenuId(id);
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.mdd.admin.service.system.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.common.entity.system.SystemAuthMenu;
|
||||
import com.mdd.common.entity.system.SystemAuthPerm;
|
||||
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthPermMapper;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统权限服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
|
||||
|
||||
@Resource
|
||||
SystemAuthPermMapper systemAuthPermMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthMenuMapper systemAuthMenuMapper;
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单ID
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return List<Integer>
|
||||
*/
|
||||
@Override
|
||||
public List<Integer> selectMenuIdsByRoleId(Integer roleId) {
|
||||
List<Integer> menus = new LinkedList<>();
|
||||
List<SystemAuthPerm> systemAuthPerms = systemAuthPermMapper.selectList(
|
||||
new QueryWrapper<SystemAuthPerm>().eq("role_id", roleId));
|
||||
for (SystemAuthPerm systemAuthPerm : systemAuthPerms) {
|
||||
menus.add(systemAuthPerm.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(",")) {
|
||||
SystemAuthPerm model = new SystemAuthPerm();
|
||||
model.setRoleId(roleId);
|
||||
model.setMenuId(Integer.parseInt(menuId));
|
||||
systemAuthPermMapper.insert(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单(根据角色ID)
|
||||
*
|
||||
* @author fzr
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@Override
|
||||
public void batchDeleteByRoleId(Integer roleId) {
|
||||
systemAuthPermMapper.delete(new QueryWrapper<SystemAuthPerm>().eq("role_id", roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单(根据菜单ID)
|
||||
*
|
||||
* @author fzr
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
@Override
|
||||
public void batchDeleteByMenuId(Integer menuId) {
|
||||
systemAuthPermMapper.delete(new QueryWrapper<SystemAuthPerm>().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<SystemAuthPerm> systemAuthPerms = systemAuthPermMapper.selectList(
|
||||
new QueryWrapper<SystemAuthPerm>().eq("role_id", roleId));
|
||||
for (SystemAuthPerm systemAuthPerm : systemAuthPerms) {
|
||||
menuIds.add(systemAuthPerm.getMenuId());
|
||||
}
|
||||
|
||||
if (menuIds.size() > 0) {
|
||||
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(new QueryWrapper<SystemAuthMenu>()
|
||||
.select("id,perms")
|
||||
.eq("is_disable", 0)
|
||||
.in("id", menuIds)
|
||||
.in("menu_type", Arrays.asList("C", "A"))
|
||||
.orderByAsc(Arrays.asList("menu_sort", "id")));
|
||||
|
||||
for (SystemAuthMenu item : systemAuthMenus) {
|
||||
if (StringUtil.isNotNull(item.getPerms()) && StringUtil.isNotEmpty(item.getPerms())) {
|
||||
menuArray.add(item.getPerms().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RedisUtil.hSet(AdminConfig.backstageRolesKey, String.valueOf(roleId), ArrayUtil.listToStringByStr(menuArray, ","));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package com.mdd.admin.service.system.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.mdd.admin.service.system.ISystemAuthPostService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthPostParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthPostVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemAuthPost;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthPostMapper;
|
||||
import com.mdd.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;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统岗位服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAuthPostServiceImpl implements ISystemAuthPostService {
|
||||
|
||||
@Resource
|
||||
SystemAuthPostMapper systemAuthPostMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemPostVo>
|
||||
*/
|
||||
@Override
|
||||
public List<SystemAuthPostVo> all() {
|
||||
List<SystemAuthPost> systemAuthPostList = systemAuthPostMapper.selectList(new QueryWrapper<SystemAuthPost>()
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc((Arrays.asList("id", "sort"))));
|
||||
|
||||
List<SystemAuthPostVo> adminVoArrayList = new ArrayList<>();
|
||||
for (SystemAuthPost systemAuthPost : systemAuthPostList) {
|
||||
SystemAuthPostVo vo = new SystemAuthPostVo();
|
||||
BeanUtils.copyProperties(systemAuthPost, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthPost.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthPost.getUpdateTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return adminVoArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<SystemPostVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SystemAuthPostVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SystemAuthPost> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select(SystemAuthPost.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc(Arrays.asList("id", "sort"));
|
||||
|
||||
systemAuthPostMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:code:str",
|
||||
"like:name:str",
|
||||
"=:isStop@is_stop:int"
|
||||
});
|
||||
|
||||
IPage<SystemAuthPost> iPage = systemAuthPostMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SystemAuthPostVo> list = new ArrayList<>();
|
||||
for (SystemAuthPost systemAuthPost : iPage.getRecords()) {
|
||||
SystemAuthPostVo vo = new SystemAuthPostVo();
|
||||
BeanUtils.copyProperties(systemAuthPost, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthPost.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthPost.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SystemPostVo
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthPostVo detail(Integer id) {
|
||||
SystemAuthPost systemAuthPost = systemAuthPostMapper.selectOne(new QueryWrapper<SystemAuthPost>()
|
||||
.select(SystemAuthPost.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemAuthPost, "岗位不存在");
|
||||
|
||||
SystemAuthPostVo vo = new SystemAuthPostVo();
|
||||
BeanUtils.copyProperties(systemAuthPost, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthPost.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthPost.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemAuthPostParam systemAuthPostParam) {
|
||||
Assert.isNull(systemAuthPostMapper.selectOne(new QueryWrapper<SystemAuthPost>()
|
||||
.select("id,code,name")
|
||||
.nested(
|
||||
wq->wq.eq("code", systemAuthPostParam.getCode())
|
||||
.or()
|
||||
.eq("name", systemAuthPostParam.getName())
|
||||
)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "该岗位已存在");
|
||||
|
||||
SystemAuthPost model = new SystemAuthPost();
|
||||
model.setCode(systemAuthPostParam.getCode());
|
||||
model.setName(systemAuthPostParam.getName());
|
||||
model.setSort(systemAuthPostParam.getSort());
|
||||
model.setRemarks(systemAuthPostParam.getRemarks());
|
||||
model.setIsStop(systemAuthPostParam.getIsStop());
|
||||
model.setIsDelete(0);
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthPostMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthPostParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemAuthPostParam systemAuthPostParam) {
|
||||
SystemAuthPost model = systemAuthPostMapper.selectOne(new QueryWrapper<SystemAuthPost>()
|
||||
.select(SystemAuthPost.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", systemAuthPostParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "岗位不存在");
|
||||
|
||||
Assert.isNull(systemAuthPostMapper.selectOne(new QueryWrapper<SystemAuthPost>()
|
||||
.select("id,code,name")
|
||||
.ne("id", systemAuthPostParam.getId())
|
||||
.nested(
|
||||
wq->wq.eq("code", systemAuthPostParam.getCode())
|
||||
.or()
|
||||
.eq("name", systemAuthPostParam.getName())
|
||||
)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "该岗位已存在");
|
||||
|
||||
model.setCode(systemAuthPostParam.getCode());
|
||||
model.setName(systemAuthPostParam.getName());
|
||||
model.setSort(systemAuthPostParam.getSort());
|
||||
model.setRemarks(systemAuthPostParam.getRemarks());
|
||||
model.setIsStop(systemAuthPostParam.getIsStop());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthPostMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
SystemAuthPost model = systemAuthPostMapper.selectOne(new QueryWrapper<SystemAuthPost>()
|
||||
.select("id,code,name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "岗位不存在");
|
||||
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select("id,nickname")
|
||||
.eq("post_id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.isNull(systemAuthAdmin, "该岗位已被管理员使用,请先移除");
|
||||
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthPostMapper.updateById(model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.mdd.admin.service.system.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.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.system.ISystemAuthRoleService;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.validate.system.SystemAuthRoleParam;
|
||||
import com.mdd.admin.vo.system.SystemAuthRoleVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemAuthRole;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthRoleMapper;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.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.*;
|
||||
|
||||
/**
|
||||
* 系统角色服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthRoleMapper systemAuthRoleMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
/**
|
||||
* 角色所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemAuthRoleVo>
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> all() {
|
||||
QueryWrapper<SystemAuthRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,name,create_time,update_time");
|
||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||
List<SystemAuthRole> systemAuthRoles = systemAuthRoleMapper.selectList(queryWrapper);
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SystemAuthRole systemAuthRole : systemAuthRoles) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("id", systemAuthRole.getId());
|
||||
map.put("name", systemAuthRole.getName());
|
||||
map.put("createTime", TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
||||
map.put("updateTime", TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 参数
|
||||
* @return PageResult<SysRoleListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SystemAuthRoleVo> list(@Validated PageParam pageParam) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SystemAuthRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||
|
||||
IPage<SystemAuthRole> iPage = systemAuthRoleMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SystemAuthRoleVo> list = new ArrayList<>();
|
||||
for (SystemAuthRole systemAuthRole : iPage.getRecords()) {
|
||||
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
||||
BeanUtils.copyProperties(systemAuthRole, vo);
|
||||
|
||||
Integer member = systemAuthAdminMapper.selectCount(new QueryWrapper<SystemAuthAdmin>()
|
||||
.eq("is_delete", 0)
|
||||
.eq("role", systemAuthRole.getId()));
|
||||
|
||||
vo.setMenus(new ArrayList<>());
|
||||
vo.setMember(member);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @return SysRole
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthRoleVo detail(Integer id) {
|
||||
SystemAuthRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemAuthRole, "角色已不存在!");
|
||||
|
||||
Integer member = systemAuthAdminMapper.selectCount(new QueryWrapper<SystemAuthAdmin>()
|
||||
.eq("is_delete", 0)
|
||||
.eq("role", systemAuthRole.getId()));
|
||||
|
||||
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
||||
BeanUtils.copyProperties(systemAuthRole, vo);
|
||||
vo.setMember(member);
|
||||
vo.setMenus(iSystemAuthPermService.selectMenuIdsByRoleId(systemAuthRole.getId()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(SystemAuthRoleParam systemAuthRoleParam) {
|
||||
Assert.isNull(systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
.select("id,name")
|
||||
.eq("name", systemAuthRoleParam.getName().trim())
|
||||
.last("limit 1")), "角色名称已存在!");
|
||||
|
||||
SystemAuthRole model = new SystemAuthRole();
|
||||
model.setName(systemAuthRoleParam.getName().trim());
|
||||
model.setRemark(systemAuthRoleParam.getRemark());
|
||||
model.setIsDisable(systemAuthRoleParam.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthRoleMapper.insert(model);
|
||||
iSystemAuthPermService.batchSaveByMenuIds(model.getId(), systemAuthRoleParam.getMenuIds());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemAuthRoleParam 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void edit(SystemAuthRoleParam systemAuthRoleParam) {
|
||||
Assert.notNull(systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
.select("id,name")
|
||||
.eq("id", systemAuthRoleParam.getId())
|
||||
.last("limit 1")), "角色已不存在!");
|
||||
|
||||
Assert.isNull(systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
.select("id,name")
|
||||
.ne("id", systemAuthRoleParam.getId())
|
||||
.eq("name", systemAuthRoleParam.getName().trim())
|
||||
.last("limit 1")), "角色名称已存在!");
|
||||
|
||||
SystemAuthRole model = new SystemAuthRole();
|
||||
model.setId(systemAuthRoleParam.getId());
|
||||
model.setName(systemAuthRoleParam.getName().trim());
|
||||
model.setRemark(systemAuthRoleParam.getRemark());
|
||||
model.setSort(systemAuthRoleParam.getSort());
|
||||
model.setIsDisable(systemAuthRoleParam.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthRoleMapper.updateById(model);
|
||||
|
||||
iSystemAuthPermService.batchDeleteByRoleId(systemAuthRoleParam.getId());
|
||||
iSystemAuthPermService.batchSaveByMenuIds(systemAuthRoleParam.getId(), systemAuthRoleParam.getMenuIds());
|
||||
iSystemAuthPermService.cacheRoleMenusByRoleId(systemAuthRoleParam.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void del(Integer id) {
|
||||
Assert.notNull(
|
||||
systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.last("limit 1")),
|
||||
"角色已不存在!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select("id", "role", "nickname")
|
||||
.eq("role", id)
|
||||
.eq("is_delete", 0)),
|
||||
"角色已被管理员使用,请先移除");
|
||||
|
||||
systemAuthRoleMapper.deleteById(id);
|
||||
iSystemAuthPermService.batchDeleteByRoleId(id);
|
||||
RedisUtil.hDel(AdminConfig.backstageRolesKey, String.valueOf(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.mdd.admin.service.system.impl;
|
||||
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.system.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.system.ISystemLoginService;
|
||||
import com.mdd.admin.validate.system.SystemLoginParam;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemLogLogin;
|
||||
import com.mdd.common.enums.HttpEnum;
|
||||
import com.mdd.common.exception.LoginException;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemLogLoginMapper;
|
||||
import com.mdd.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
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAuthAdminService iSystemAuthAdminService;
|
||||
|
||||
|
||||
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();
|
||||
|
||||
SystemAuthAdmin sysAdmin = iSystemAuthAdminService.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);
|
||||
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(IpUtil.getIpAddress());
|
||||
sysAdmin.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthAdminMapper.updateById(sysAdmin);
|
||||
|
||||
// 缓存登录信息
|
||||
String token = ToolsUtil.makeToken();
|
||||
RedisUtil.set(AdminConfig.backstageTokenKey+token, sysAdmin.getId(), 7200);
|
||||
iSystemAuthAdminService.cacheAdminUserByUid(sysAdmin.getId());
|
||||
|
||||
// 返回登录信息
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("token", token);
|
||||
|
||||
// 更新登录信息
|
||||
sysAdmin.setLastLoginIp(IpUtil.getIpAddress());
|
||||
sysAdmin.setLastLoginTime(TimeUtil.timestamp());
|
||||
systemAuthAdminMapper.updateById(sysAdmin);
|
||||
|
||||
// 记录登录日志
|
||||
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(RequestUtil.handler());
|
||||
final UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
|
||||
|
||||
SystemLogLogin model = new SystemLogLogin();
|
||||
model.setAdminId(adminId);
|
||||
model.setUsername(username);
|
||||
model.setIp(IpUtil.getIpAddress());
|
||||
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,119 @@
|
||||
package com.mdd.admin.service.system.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.mdd.admin.service.system.ISystemLogsServer;
|
||||
import com.mdd.admin.validate.common.PageParam;
|
||||
import com.mdd.admin.vo.system.LogLoginVo;
|
||||
import com.mdd.admin.vo.system.LogOperateVo;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemLogLogin;
|
||||
import com.mdd.common.entity.system.SystemLogOperate;
|
||||
import com.mdd.common.mapper.system.SystemLogLoginMapper;
|
||||
import com.mdd.common.mapper.system.SystemLogOperateMapper;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.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 SystemLogsServerImpl implements ISystemLogsServer {
|
||||
|
||||
@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("?_system_auth_admin sa ON sa.id=t.admin_id".replace("?_", GlobalConfig.tablePrefix))
|
||||
.orderByDesc("id");
|
||||
|
||||
logOperateMapper.setSearch(mpjQueryWrapper, params, new String[]{
|
||||
"like:title:str",
|
||||
"like:username:str",
|
||||
"=:type:str",
|
||||
"=:status:int",
|
||||
"=:url:str",
|
||||
"=:ip:str",
|
||||
"datetime:startTime-endTime@t.create_time:str"
|
||||
});
|
||||
|
||||
IPage<LogOperateVo> iPage = logOperateMapper.selectJoinPage(
|
||||
new Page<>(pageNo, pageSize),
|
||||
LogOperateVo.class,
|
||||
mpjQueryWrapper);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统登录日志
|
||||
*
|
||||
* @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> list = new LinkedList<>();
|
||||
for (SystemLogLogin item : iPage.getRecords()) {
|
||||
LogLoginVo vo = new LogLoginVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mdd.admin.validate.article;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.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.mdd.admin.validate.article;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.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,48 @@
|
||||
package com.mdd.admin.validate.common;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.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.mdd.admin.validate.common;
|
||||
|
||||
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,55 @@
|
||||
package com.mdd.admin.validate.setting;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.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.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class DictDataParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "ids参数缺失", groups = {delete.class})
|
||||
private List<Integer> ids;
|
||||
|
||||
@IDMust(message = "typeId参数必传且需大于0", groups = {create.class, update.class})
|
||||
private Integer typeId;
|
||||
|
||||
@NotNull(message = "name参数缺失", groups = {create.class, update.class})
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "value参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 100, message = "键名不能超出100个字符", groups = {create.class, update.class})
|
||||
private String value;
|
||||
|
||||
@Length(max = 200, message = "数值不能超出200个字符", groups = {create.class, update.class})
|
||||
private String remark;
|
||||
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer sort;
|
||||
|
||||
@NotNull(message = "status参数缺失", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, message = "status参数不在合法值内", groups = {create.class, update.class})
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mdd.admin.validate.setting;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典类型参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class DictTypeParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "ids参数缺失", groups = {delete.class})
|
||||
private List<Integer> ids;
|
||||
|
||||
@NotNull(message = "dictName参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 200, message = "名称不能超出200个字符", groups = {create.class, update.class})
|
||||
private String dictName;
|
||||
|
||||
@NotNull(message = "dictType参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 200, message = "类型不能超出200个字符", groups = {create.class, update.class})
|
||||
private String dictType;
|
||||
|
||||
@Length(max = 200, message = "备注不能超出200个字符", groups = {create.class, update.class})
|
||||
private String dictRemark;
|
||||
|
||||
@NotNull(message = "dictStatus参数缺失")
|
||||
@IntegerContains(values = {0, 1}, message = "dictStatus参数不在合法值内", groups = {create.class, update.class})
|
||||
private Integer dictStatus;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mdd.admin.validate.system;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.common.validator.annotation.IntegerContains;
|
||||
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 SystemAuthAdminParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface upInfo{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "请选择角色", groups = {create.class, update.class})
|
||||
@Min(value = 0, 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, upInfo.class})
|
||||
@Length(min = 2, max = 30, message = "昵称必须在2~30个字符内", groups = {create.class, update.class, upInfo.class})
|
||||
private String nickname;
|
||||
|
||||
@NotEmpty(message = "密码不能为空", groups = {create.class})
|
||||
@Length(min = 6, max = 32, message = "密码必须在6~32个字符内", groups = {create.class})
|
||||
private String password;
|
||||
|
||||
@NotEmpty(message = "当前密码不能为空", groups = {upInfo.class})
|
||||
@Length(min = 6, max = 32, message = "当前密码错误", groups = {upInfo.class})
|
||||
private String currPassword;
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, message = "isDisable参数不在合法值内", groups = {create.class, update.class})
|
||||
private Integer isDisable;
|
||||
|
||||
@NotNull(message = "请选择是否支持多端登录", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, message = "isMultipoint参数不在合法值内", groups = {create.class, update.class})
|
||||
private Integer isMultipoint;
|
||||
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0", groups = {create.class, update.class})
|
||||
private Integer sort = 0;
|
||||
|
||||
private Integer deptId = 0;
|
||||
|
||||
private Integer postId = 0;
|
||||
|
||||
private String avatar = "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mdd.admin.validate.system;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.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.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 系统部门参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemAuthDeptParam {
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "pid参数缺失", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "上级值不能少于0", groups = {create.class, update.class})
|
||||
private Integer pid;
|
||||
|
||||
@NotNull(message = "name参数缺失", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 100, message = "部门名称必须在1~100个字符内", groups = {create.class, update.class})
|
||||
private String name;
|
||||
|
||||
@Length(min = 1, max = 30, message = "负责人名称必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String duty = "";
|
||||
|
||||
@Length(min = 11, max = 11, message = "手机号只能为11位", groups = {create.class, update.class})
|
||||
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误", groups = {create.class, update.class})
|
||||
private String mobile = "";
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isStop = 0;
|
||||
|
||||
private Integer sort = 0;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mdd.admin.validate.system;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.common.validator.annotation.IntegerContains;
|
||||
import com.mdd.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.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统菜单参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemAuthMenuParam 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;
|
||||
|
||||
@Length(max = 200, message = "路由地址不能超过200个字符", groups = {create.class, update.class})
|
||||
private String paths;
|
||||
|
||||
@Length(max = 200, message = "前端组件不能超过200个字符", groups = {create.class, update.class})
|
||||
private String component;
|
||||
|
||||
@Length(max = 200, message = "选中菜单路径不能超过200个字符", groups = {create.class, update.class})
|
||||
private String selected;
|
||||
|
||||
@Length(max = 200, message = "路由参数不能超过200个字符", groups = {create.class, update.class})
|
||||
private String params;
|
||||
|
||||
@NotNull(message = "请选择缓存状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isCache;
|
||||
|
||||
@NotNull(message = "请选择显示状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isShow;
|
||||
|
||||
@NotNull(message = "请选择菜单状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isDisable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mdd.admin.validate.system;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 系统岗位Vo
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemAuthPostParam {
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "code参数缺失", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 30, message = "岗位编码必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String code;
|
||||
|
||||
@NotNull(message = "name参数缺失", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 30, message = "岗位名称必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isStop = 0;
|
||||
|
||||
@Length( max = 250, message = "岗位备注不能大于250个字符内", groups = {create.class, update.class})
|
||||
private String remarks = "";
|
||||
|
||||
private Integer sort = 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mdd.admin.validate.system;
|
||||
|
||||
import com.mdd.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 SystemAuthRoleParam 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,29 @@
|
||||
package com.mdd.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,21 @@
|
||||
package com.mdd.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.mdd.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,22 @@
|
||||
package com.mdd.admin.vo.article;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章分类Vo
|
||||
*/
|
||||
@Data
|
||||
public class ArticleCateVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private String name; // 分类名称
|
||||
private Integer sort; // 排序编号
|
||||
private Integer isShow; // 是否显示
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mdd.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; // 是否显示: [0=否, 1=是]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mdd.admin.vo.article;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章列表Vo
|
||||
*/
|
||||
@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; // 是否显示: [0=否, 1=是]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mdd.admin.vo.setting;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 字典数据Vo
|
||||
*/
|
||||
@Data
|
||||
public class DictDataVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private Integer typeId; // 类型
|
||||
private String name; // 键
|
||||
private String value; // 值
|
||||
private String remark; // 备注
|
||||
private Integer sort; // 排序
|
||||
private Integer status; // 状态: [0=停用, 1=禁用]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mdd.admin.vo.setting;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 字典类型Vo
|
||||
*/
|
||||
@Data
|
||||
public class DictTypeVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private String dictName; // 字典名称
|
||||
private String dictType; // 字典类型
|
||||
private String dictRemark; // 字典备注
|
||||
private Integer dictStatus; // 字典状态
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mdd.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; // 来源IP
|
||||
private String os; // 操作系统
|
||||
private String browser; // 浏览器
|
||||
private Integer status; // 操作状态: [1=成功, 2=失败]
|
||||
private String createTime; // 创建时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mdd.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; // 请求类型: GET/POST/PUT
|
||||
private String title; // 操作标题
|
||||
private String method; // 请求方式
|
||||
private String ip; // 请求IP
|
||||
private String url; // 请求地址
|
||||
private String args; // 请求参数
|
||||
private String error; // 错误信息
|
||||
private Integer status; // 执行状态: [1=成功, 2=失败]
|
||||
private String taskTime; // 执行耗时
|
||||
private String startTime; // 开始时间
|
||||
private String endTime; // 结束时间
|
||||
private String createTime; // 创建时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 管理员Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAuthAdminVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private Integer deptId; // 部门ID
|
||||
private Integer postId; // 岗位ID
|
||||
private String username; // 账号
|
||||
private String nickname; // 昵称
|
||||
private String avatar; // 头像
|
||||
private String dept; // 部门
|
||||
private String role; // 角色
|
||||
private Integer isMultipoint; // 多端登录: [0=否, 1=是]
|
||||
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
||||
private String lastLoginIp; // 最后登录IP
|
||||
private String lastLoginTime; // 最后登录时间
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 部门Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAuthDeptVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private Integer pid; // 部门父级
|
||||
private String name; // 部门名称
|
||||
private String duty; // 负责人
|
||||
private String mobile; // 联系电话
|
||||
private Integer sort; // 排序编号
|
||||
private Integer isStop; // 是否停用: [0=否, 1=是]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统菜单Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAuthMenuVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private Integer pid; // 上级菜单
|
||||
private String menuType; // 权限类型: [M=目录, C=菜单, A=按钮]
|
||||
private String menuName; // 菜单名称
|
||||
private String menuIcon; // 菜单图标
|
||||
private Integer menuSort; // 菜单排序
|
||||
private String perms; // 权限标识
|
||||
private String paths; // 路由地址
|
||||
private String component; // 前端组件
|
||||
private String selected; // 选中路径
|
||||
private String params; // 路由参数
|
||||
private Integer isCache; // 是否缓存: [0=否, 1=是]
|
||||
private Integer isShow; // 是否显示: [0=否, 1=是]
|
||||
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统岗位Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAuthPostVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private String code; // 岗位编号
|
||||
private String name; // 岗位名称
|
||||
private String remarks; // 岗位备注
|
||||
private Integer sort; // 岗位排序
|
||||
private Integer isStop; // 是否停用: [0=否, 1=是]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统角色Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAuthRoleVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键
|
||||
private String name; // 角色名称
|
||||
private String remark; // 角色备注
|
||||
private Object menus; // 关联菜单
|
||||
private Integer member; // 成员数量
|
||||
private Integer sort; // 角色排序
|
||||
private Integer isDisable; // 是否禁用: [0=否, 1=是]
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 当前系统管理员Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemAuthSelfVo {
|
||||
|
||||
private Object user; // 用户信息
|
||||
private Object permissions; // 权限集合: [[*]=>所有权限, ['article:add']=>部分权限]
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user