refactor: 💥 适配 ContiNew Starter CRUD(扩展模块)
This commit is contained in:
parent
ce785ddce2
commit
ce5a2ec931
@ -16,6 +16,12 @@
|
|||||||
<description>公共模块(存放公共工具类,公共配置等)</description>
|
<description>公共模块(存放公共工具类,公共配置等)</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- ContiNew Starter 扩展模块 - CURD(增删改查) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>top.charles7c.continew</groupId>
|
||||||
|
<artifactId>continew-starter-extension-crud</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- ContiNew Starter 认证模块 - JustAuth -->
|
<!-- ContiNew Starter 认证模块 - JustAuth -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.charles7c.continew</groupId>
|
<groupId>top.charles7c.continew</groupId>
|
||||||
@ -81,11 +87,5 @@
|
|||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Hibernate Validator -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增删改查请求映射器注解
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/27 9:54
|
|
||||||
*/
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface CrudRequestMapping {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路径映射 URI(等同于:@RequestMapping("/foo1"))
|
|
||||||
*/
|
|
||||||
String value() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API 列表
|
|
||||||
*/
|
|
||||||
Api[] api() default {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API 枚举
|
|
||||||
*/
|
|
||||||
enum Api {
|
|
||||||
/**
|
|
||||||
* 所有 API
|
|
||||||
*/
|
|
||||||
ALL,
|
|
||||||
/**
|
|
||||||
* 分页
|
|
||||||
*/
|
|
||||||
PAGE,
|
|
||||||
/**
|
|
||||||
* 树列表
|
|
||||||
*/
|
|
||||||
TREE,
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
*/
|
|
||||||
LIST,
|
|
||||||
/**
|
|
||||||
* 详情
|
|
||||||
*/
|
|
||||||
GET,
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
*/
|
|
||||||
ADD,
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*/
|
|
||||||
UPDATE,
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
DELETE,
|
|
||||||
/**
|
|
||||||
* 导出
|
|
||||||
*/
|
|
||||||
EXPORT,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应拦截忽略注解
|
|
||||||
*
|
|
||||||
* @author BULL_BCLS
|
|
||||||
* @since 2023/10/8 20:44
|
|
||||||
*/
|
|
||||||
@Target({ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface NoResponseAdvice {}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询注解
|
|
||||||
*
|
|
||||||
* @author Zheng Jie(ELADMIN)
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/15 18:01
|
|
||||||
*/
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface Query {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 属性名(默认和使用该注解的属性的名称一致)
|
|
||||||
*/
|
|
||||||
String property() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询类型(等值查询、模糊查询、范围查询等)
|
|
||||||
*/
|
|
||||||
QueryTypeEnum type() default QueryTypeEnum.EQUAL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多属性模糊查询,仅支持 String 类型属性
|
|
||||||
* <p>
|
|
||||||
* 例如:@Query(blurry = {"username", "email"}) 表示根据用户名和邮箱模糊查询
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
String[] blurry() default {};
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树结构字段
|
|
||||||
*
|
|
||||||
* @see cn.hutool.core.lang.tree.TreeNodeConfig
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/2/26 23:50
|
|
||||||
*/
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface TreeField {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID 字段名
|
|
||||||
*
|
|
||||||
* @return ID 字段名
|
|
||||||
*/
|
|
||||||
String value() default "key";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父 ID 字段名
|
|
||||||
*
|
|
||||||
* @return 父 ID 字段名
|
|
||||||
*/
|
|
||||||
String parentIdKey() default "parentId";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称字段名
|
|
||||||
*
|
|
||||||
* @return 名称字段名
|
|
||||||
*/
|
|
||||||
String nameKey() default "title";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序字段名
|
|
||||||
*
|
|
||||||
* @return 排序字段名
|
|
||||||
*/
|
|
||||||
String weightKey() default "sort";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 子列表字段名
|
|
||||||
*
|
|
||||||
* @return 子列表字段名
|
|
||||||
*/
|
|
||||||
String childrenKey() default "children";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递归深度(< 0 不限制)
|
|
||||||
*
|
|
||||||
* @return 递归深度
|
|
||||||
*/
|
|
||||||
int deep() default -1;
|
|
||||||
}
|
|
@ -1,218 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
|
|
||||||
import top.charles7c.cnadmin.common.annotation.NoResponseAdvice;
|
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.R;
|
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 控制器基类
|
|
||||||
*
|
|
||||||
* @param <S>
|
|
||||||
* 业务接口
|
|
||||||
* @param <L>
|
|
||||||
* 列表信息
|
|
||||||
* @param <D>
|
|
||||||
* 详情信息
|
|
||||||
* @param <Q>
|
|
||||||
* 查询条件
|
|
||||||
* @param <C>
|
|
||||||
* 创建或修改信息
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/26 10:45
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q, C extends BaseReq> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected S baseService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param pageQuery
|
|
||||||
* 分页查询条件
|
|
||||||
* @return 分页信息
|
|
||||||
*/
|
|
||||||
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
|
||||||
@ResponseBody
|
|
||||||
@GetMapping
|
|
||||||
public PageDataResp<L> page(Q query, @Validated PageQuery pageQuery) {
|
|
||||||
this.checkPermission(Api.LIST);
|
|
||||||
return baseService.page(query, pageQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询树列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @return 树列表信息
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查询树列表", description = "查询树列表")
|
|
||||||
@ResponseBody
|
|
||||||
@GetMapping("/tree")
|
|
||||||
public List<Tree<Long>> tree(Q query, SortQuery sortQuery) {
|
|
||||||
this.checkPermission(Api.LIST);
|
|
||||||
return baseService.tree(query, sortQuery, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @return 列表信息
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查询列表", description = "查询列表")
|
|
||||||
@ResponseBody
|
|
||||||
@GetMapping("/list")
|
|
||||||
public List<L> list(Q query, SortQuery sortQuery) {
|
|
||||||
this.checkPermission(Api.LIST);
|
|
||||||
return baseService.list(query, sortQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看详情
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* ID
|
|
||||||
* @return 详情信息
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查看详情", description = "查看详情")
|
|
||||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
|
||||||
@ResponseBody
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public D get(@PathVariable Long id) {
|
|
||||||
this.checkPermission(Api.LIST);
|
|
||||||
return baseService.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* 创建信息
|
|
||||||
* @return 自增 ID
|
|
||||||
*/
|
|
||||||
@Operation(summary = "新增数据", description = "新增数据")
|
|
||||||
@ResponseBody
|
|
||||||
@PostMapping
|
|
||||||
public R<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody C req) {
|
|
||||||
this.checkPermission(Api.ADD);
|
|
||||||
Long id = baseService.add(req);
|
|
||||||
return R.ok("新增成功", id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* 修改信息
|
|
||||||
* @param id
|
|
||||||
* ID
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
@Operation(summary = "修改数据", description = "修改数据")
|
|
||||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
|
||||||
@ResponseBody
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public R update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody C req, @PathVariable Long id) {
|
|
||||||
this.checkPermission(Api.UPDATE);
|
|
||||||
baseService.update(req, id);
|
|
||||||
return R.ok("修改成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* ID 列表
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
@Operation(summary = "删除数据", description = "删除数据")
|
|
||||||
@Parameter(name = "ids", description = "ID 列表", example = "1,2", in = ParameterIn.PATH)
|
|
||||||
@ResponseBody
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public R delete(@PathVariable List<Long> ids) {
|
|
||||||
this.checkPermission(Api.DELETE);
|
|
||||||
baseService.delete(ids);
|
|
||||||
return R.ok("删除成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @param response
|
|
||||||
* 响应对象
|
|
||||||
*/
|
|
||||||
@Operation(summary = "导出数据", description = "导出数据")
|
|
||||||
@NoResponseAdvice
|
|
||||||
@GetMapping("/export")
|
|
||||||
public void export(Q query, SortQuery sortQuery, HttpServletResponse response) {
|
|
||||||
this.checkPermission(Api.EXPORT);
|
|
||||||
baseService.export(query, sortQuery, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 API 类型进行权限验证
|
|
||||||
*
|
|
||||||
* @param api
|
|
||||||
* API 类型
|
|
||||||
*/
|
|
||||||
private void checkPermission(Api api) {
|
|
||||||
CrudRequestMapping crudRequestMapping = this.getClass().getDeclaredAnnotation(CrudRequestMapping.class);
|
|
||||||
String path = crudRequestMapping.value();
|
|
||||||
String permissionPrefix = String.join(StringConstants.COLON, StrUtil.splitTrim(path, StringConstants.SLASH));
|
|
||||||
StpUtil.checkPermission(String.format("%s:%s", permissionPrefix, api.name().toLowerCase()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实体类基类
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2022/12/12 23:02
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BaseDO implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private Long createUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改人
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.UPDATE)
|
|
||||||
private Long updateUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 详情响应基类
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/26 10:40
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BaseDetailResp extends BaseResp {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改人
|
|
||||||
*/
|
|
||||||
@JsonIgnore
|
|
||||||
private Long updateUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改人
|
|
||||||
*/
|
|
||||||
@Schema(description = "修改人", example = "李四")
|
|
||||||
@ExcelProperty(value = "修改人", order = Integer.MAX_VALUE - 2)
|
|
||||||
private String updateUserString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改时间
|
|
||||||
*/
|
|
||||||
@Schema(description = "修改时间", example = "2023-08-08 08:08:08", type = "string")
|
|
||||||
@ExcelProperty(value = "修改时间", order = Integer.MAX_VALUE - 1)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.ChainWrappers;
|
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapper 基类
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* 实体类
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/2/19 20:47
|
|
||||||
*/
|
|
||||||
public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入记录
|
|
||||||
*
|
|
||||||
* @param entityList
|
|
||||||
* 实体列表
|
|
||||||
* @return 是否成功
|
|
||||||
*/
|
|
||||||
default boolean insertBatch(Collection<T> entityList) {
|
|
||||||
return Db.saveBatch(entityList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量更新记录
|
|
||||||
*
|
|
||||||
* @param entityList
|
|
||||||
* 实体列表
|
|
||||||
* @return 是否成功
|
|
||||||
*/
|
|
||||||
default boolean updateBatchById(Collection<T> entityList) {
|
|
||||||
return Db.updateBatchById(entityList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 链式查询
|
|
||||||
*
|
|
||||||
* @return QueryWrapper 的包装类
|
|
||||||
*/
|
|
||||||
default QueryChainWrapper<T> query() {
|
|
||||||
return ChainWrappers.queryChain(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 链式查询(lambda 式)
|
|
||||||
*
|
|
||||||
* @return LambdaQueryWrapper 的包装类
|
|
||||||
*/
|
|
||||||
default LambdaQueryChainWrapper<T> lambdaQuery() {
|
|
||||||
return ChainWrappers.lambdaQueryChain(this, this.currentEntityClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 链式查询(lambda 式)
|
|
||||||
*
|
|
||||||
* @param entity
|
|
||||||
* 实体对象
|
|
||||||
* @return LambdaQueryWrapper 的包装类
|
|
||||||
*/
|
|
||||||
default LambdaQueryChainWrapper<T> lambdaQuery(T entity) {
|
|
||||||
return ChainWrappers.lambdaQueryChain(this, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 链式更改
|
|
||||||
*
|
|
||||||
* @return UpdateWrapper 的包装类
|
|
||||||
*/
|
|
||||||
default UpdateChainWrapper<T> update() {
|
|
||||||
return ChainWrappers.updateChain(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 链式更改(lambda 式)
|
|
||||||
*
|
|
||||||
* @return LambdaUpdateWrapper 的包装类
|
|
||||||
*/
|
|
||||||
default LambdaUpdateChainWrapper<T> lambdaUpdate() {
|
|
||||||
return ChainWrappers.lambdaUpdateChain(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取实体类 Class 对象
|
|
||||||
*
|
|
||||||
* @return 实体类 Class 对象
|
|
||||||
*/
|
|
||||||
default Class<T> currentEntityClass() {
|
|
||||||
return (Class<T>)ClassUtil.getTypeArgument(this.getClass(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求基类
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/30 21:51
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BaseReq implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应基类
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/26 10:40
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BaseResp implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID
|
|
||||||
*/
|
|
||||||
@Schema(description = "ID", example = "1")
|
|
||||||
@ExcelProperty(value = "ID", order = 1)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
@JsonIgnore
|
|
||||||
private Long createUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
@Schema(description = "创建人", example = "超级管理员")
|
|
||||||
@ExcelProperty(value = "创建人", order = Integer.MAX_VALUE - 4)
|
|
||||||
private String createUserString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@Schema(description = "创建时间", example = "2023-08-08 08:08:08", type = "string")
|
|
||||||
@ExcelProperty(value = "创建时间", order = Integer.MAX_VALUE - 3)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否禁用修改
|
|
||||||
*/
|
|
||||||
@Schema(description = "是否禁用修改", example = "true")
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
private Boolean disabled;
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务接口基类
|
|
||||||
*
|
|
||||||
* @param <L>
|
|
||||||
* 列表信息
|
|
||||||
* @param <D>
|
|
||||||
* 详情信息
|
|
||||||
* @param <Q>
|
|
||||||
* 查询条件
|
|
||||||
* @param <C>
|
|
||||||
* 创建或修改信息
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/26 16:54
|
|
||||||
*/
|
|
||||||
public interface BaseService<L, D, Q, C extends BaseReq> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param pageQuery
|
|
||||||
* 分页查询条件
|
|
||||||
* @return 分页列表信息
|
|
||||||
*/
|
|
||||||
PageDataResp<L> page(Q query, PageQuery pageQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询树列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @param isSimple
|
|
||||||
* 是否为简单树结构(不包含基本树结构之外的扩展字段)
|
|
||||||
* @return 树列表信息
|
|
||||||
*/
|
|
||||||
List<Tree<Long>> tree(Q query, SortQuery sortQuery, boolean isSimple);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @return 列表信息
|
|
||||||
*/
|
|
||||||
List<L> list(Q query, SortQuery sortQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看详情
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* ID
|
|
||||||
* @return 详情信息
|
|
||||||
*/
|
|
||||||
D get(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* 创建信息
|
|
||||||
* @return 自增 ID
|
|
||||||
*/
|
|
||||||
Long add(C req);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* 修改信息
|
|
||||||
* @param id
|
|
||||||
* ID
|
|
||||||
*/
|
|
||||||
void update(C req, Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* ID 列表
|
|
||||||
*/
|
|
||||||
void delete(List<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @param response
|
|
||||||
* 响应对象
|
|
||||||
*/
|
|
||||||
void export(Q query, SortQuery sortQuery, HttpServletResponse response);
|
|
||||||
}
|
|
@ -1,261 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import cn.hutool.core.lang.Opt;
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
|
||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.TreeField;
|
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
|
||||||
import top.charles7c.cnadmin.common.service.CommonUserService;
|
|
||||||
import top.charles7c.cnadmin.common.util.ReflectUtils;
|
|
||||||
import top.charles7c.cnadmin.common.util.TreeUtils;
|
|
||||||
import top.charles7c.cnadmin.common.util.helper.QueryHelper;
|
|
||||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
|
||||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
|
||||||
import top.charles7c.continew.starter.file.excel.util.ExcelUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务实现基类
|
|
||||||
*
|
|
||||||
* @param <M>
|
|
||||||
* Mapper 接口
|
|
||||||
* @param <T>
|
|
||||||
* 实体类
|
|
||||||
* @param <L>
|
|
||||||
* 列表信息
|
|
||||||
* @param <D>
|
|
||||||
* 详情信息
|
|
||||||
* @param <Q>
|
|
||||||
* 查询条件
|
|
||||||
* @param <C>
|
|
||||||
* 创建或修改信息
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/26 21:52
|
|
||||||
*/
|
|
||||||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO, L, D, Q, C extends BaseReq>
|
|
||||||
implements BaseService<L, D, Q, C> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected M baseMapper;
|
|
||||||
|
|
||||||
private final Class<T> entityClass;
|
|
||||||
private final Class<L> listClass;
|
|
||||||
private final Class<D> detailClass;
|
|
||||||
|
|
||||||
protected BaseServiceImpl() {
|
|
||||||
this.entityClass = (Class<T>)ClassUtil.getTypeArgument(this.getClass(), 1);
|
|
||||||
this.listClass = (Class<L>)ClassUtil.getTypeArgument(this.getClass(), 2);
|
|
||||||
this.detailClass = (Class<D>)ClassUtil.getTypeArgument(this.getClass(), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageDataResp<L> page(Q query, PageQuery pageQuery) {
|
|
||||||
QueryWrapper<T> queryWrapper = QueryHelper.build(query);
|
|
||||||
IPage<T> page = baseMapper.selectPage(pageQuery.toPage(), queryWrapper);
|
|
||||||
PageDataResp<L> pageDataResp = PageDataResp.build(page, listClass);
|
|
||||||
pageDataResp.getList().forEach(this::fill);
|
|
||||||
return pageDataResp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Tree<Long>> tree(Q query, SortQuery sortQuery, boolean isSimple) {
|
|
||||||
List<L> list = this.list(query, sortQuery);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return new ArrayList<>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果构建简单树结构,则不包含基本树结构之外的扩展字段
|
|
||||||
TreeNodeConfig treeNodeConfig = TreeUtils.DEFAULT_CONFIG;
|
|
||||||
TreeField treeField = listClass.getDeclaredAnnotation(TreeField.class);
|
|
||||||
if (!isSimple) {
|
|
||||||
// 根据 @TreeField 配置生成树结构配置
|
|
||||||
treeNodeConfig = TreeUtils.genTreeNodeConfig(treeField);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建树
|
|
||||||
return TreeUtils.build(list, treeNodeConfig, (node, tree) -> {
|
|
||||||
// 转换器
|
|
||||||
tree.setId(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.value())));
|
|
||||||
tree.setParentId(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.parentIdKey())));
|
|
||||||
tree.setName(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.nameKey())));
|
|
||||||
tree.setWeight(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.weightKey())));
|
|
||||||
if (!isSimple) {
|
|
||||||
List<Field> fieldList = ReflectUtils.getNonStaticFields(listClass);
|
|
||||||
fieldList.removeIf(f -> StrUtil.containsAnyIgnoreCase(f.getName(), treeField.value(),
|
|
||||||
treeField.parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey()));
|
|
||||||
fieldList
|
|
||||||
.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, StrUtil.genGetter(f.getName()))));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<L> list(Q query, SortQuery sortQuery) {
|
|
||||||
List<L> list = this.list(query, sortQuery, listClass);
|
|
||||||
list.forEach(this::fill);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
* @param targetClass
|
|
||||||
* 指定类型
|
|
||||||
* @return 列表信息
|
|
||||||
*/
|
|
||||||
protected <E> List<E> list(Q query, SortQuery sortQuery, Class<E> targetClass) {
|
|
||||||
QueryWrapper<T> queryWrapper = QueryHelper.build(query);
|
|
||||||
// 设置排序
|
|
||||||
this.sort(queryWrapper, sortQuery);
|
|
||||||
List<T> entityList = baseMapper.selectList(queryWrapper);
|
|
||||||
return BeanUtil.copyToList(entityList, targetClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置排序
|
|
||||||
*
|
|
||||||
* @param queryWrapper
|
|
||||||
* 查询 Wrapper
|
|
||||||
* @param sortQuery
|
|
||||||
* 排序查询条件
|
|
||||||
*/
|
|
||||||
protected void sort(QueryWrapper<T> queryWrapper, SortQuery sortQuery) {
|
|
||||||
Sort sort = Opt.ofNullable(sortQuery).orElseGet(SortQuery::new).getSort();
|
|
||||||
for (Sort.Order order : sort) {
|
|
||||||
if (null != order) {
|
|
||||||
queryWrapper.orderBy(true, order.isAscending(), StrUtil.toUnderlineCase(order.getProperty()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public D get(Long id) {
|
|
||||||
T entity = this.getById(id);
|
|
||||||
D detail = BeanUtil.copyProperties(entity, detailClass);
|
|
||||||
this.fillDetail(detail);
|
|
||||||
return detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long add(C req) {
|
|
||||||
if (null == req) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
T entity = BeanUtil.copyProperties(req, entityClass);
|
|
||||||
baseMapper.insert(entity);
|
|
||||||
return entity.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void update(C req, Long id) {
|
|
||||||
T entity = this.getById(id);
|
|
||||||
BeanUtil.copyProperties(req, entity, CopyOptions.create().ignoreNullValue());
|
|
||||||
baseMapper.updateById(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void delete(List<Long> ids) {
|
|
||||||
baseMapper.deleteBatchIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void export(Q query, SortQuery sortQuery, HttpServletResponse response) {
|
|
||||||
List<D> list = this.list(query, sortQuery, detailClass);
|
|
||||||
list.forEach(this::fillDetail);
|
|
||||||
ExcelUtils.export(list, "导出数据", detailClass, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 ID 查询
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* ID
|
|
||||||
* @return 实体信息
|
|
||||||
*/
|
|
||||||
protected T getById(Object id) {
|
|
||||||
T entity = baseMapper.selectById(Convert.toStr(id));
|
|
||||||
CheckUtils.throwIfNotExists(entity, ClassUtil.getClassName(entityClass, true), "ID", id);
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 填充数据
|
|
||||||
*
|
|
||||||
* @param baseObj
|
|
||||||
* 待填充列表信息
|
|
||||||
*/
|
|
||||||
protected void fill(Object baseObj) {
|
|
||||||
if (baseObj instanceof BaseResp baseResp) {
|
|
||||||
Long createUser = baseResp.getCreateUser();
|
|
||||||
if (null == createUser) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CommonUserService userService = SpringUtil.getBean(CommonUserService.class);
|
|
||||||
baseResp.setCreateUserString(ExceptionUtils.exToNull(() -> userService.getNicknameById(createUser)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 填充详情数据
|
|
||||||
*
|
|
||||||
* @param detailObj
|
|
||||||
* 待填充详情信息
|
|
||||||
*/
|
|
||||||
public void fillDetail(Object detailObj) {
|
|
||||||
if (detailObj instanceof BaseDetailResp detail) {
|
|
||||||
this.fill(detail);
|
|
||||||
Long updateUser = detail.getUpdateUser();
|
|
||||||
if (null == updateUser) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CommonUserService userService = SpringUtil.getBean(CommonUserService.class);
|
|
||||||
detail.setUpdateUserString(ExceptionUtils.exToNull(() -> userService.getNicknameById(updateUser)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.DataPermission;
|
import top.charles7c.cnadmin.common.annotation.DataPermission;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限 Mapper 基类
|
* 数据权限 Mapper 基类
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 枚举接口
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* value 类型
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/2/5 20:44
|
|
||||||
*/
|
|
||||||
public interface IBaseEnum<T extends Serializable> extends IEnum<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 枚举描述
|
|
||||||
*
|
|
||||||
* @return 枚举描述
|
|
||||||
*/
|
|
||||||
String getDescription();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 颜色
|
|
||||||
*
|
|
||||||
* @return 颜色
|
|
||||||
*/
|
|
||||||
default String getColor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.base;
|
|
||||||
|
|
||||||
import jakarta.validation.groups.Default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组校验
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/5/7 19:41
|
|
||||||
*/
|
|
||||||
public interface ValidateGroup extends Default {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组校验-增删改查
|
|
||||||
*/
|
|
||||||
interface Crud extends ValidateGroup {
|
|
||||||
/**
|
|
||||||
* 分组校验-创建
|
|
||||||
*/
|
|
||||||
interface Add extends Crud {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组校验-修改
|
|
||||||
*/
|
|
||||||
interface Update extends Crud {}
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,7 +72,6 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
|||||||
// 否则 Spring Doc OpenAPI 的 /*/api-docs/**(例如:/v3/api-docs/default)接口响应内容会变为 Base64 编码后的内容,最终导致接口文档解析失败
|
// 否则 Spring Doc OpenAPI 的 /*/api-docs/**(例如:/v3/api-docs/default)接口响应内容会变为 Base64 编码后的内容,最终导致接口文档解析失败
|
||||||
// 详情请参阅:https://github.com/springdoc/springdoc-openapi/issues/2143
|
// 详情请参阅:https://github.com/springdoc/springdoc-openapi/issues/2143
|
||||||
converters.add(new ByteArrayHttpMessageConverter());
|
converters.add(new ByteArrayHttpMessageConverter());
|
||||||
|
|
||||||
converters.removeIf(MappingJackson2HttpMessageConverter.class::isInstance);
|
converters.removeIf(MappingJackson2HttpMessageConverter.class::isInstance);
|
||||||
if (Objects.isNull(mappingJackson2HttpMessageConverter)) {
|
if (Objects.isNull(mappingJackson2HttpMessageConverter)) {
|
||||||
converters.add(new MappingJackson2HttpMessageConverter());
|
converters.add(new MappingJackson2HttpMessageConverter());
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.format.support.FormattingConversionService;
|
|
||||||
import org.springframework.web.accept.ContentNegotiationManager;
|
|
||||||
import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration;
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
|
||||||
import org.springframework.web.servlet.resource.ResourceUrlProvider;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.handler.CrudRequestMappingHandlerMapping;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Web MVC 映射配置
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/30 22:57
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class WebMvcMappingConfiguration extends DelegatingWebMvcConfiguration {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CRUD 请求映射器处理器映射器(覆盖默认 RequestMappingHandlerMapping)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
|
|
||||||
return new CrudRequestMappingHandlerMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Primary
|
|
||||||
@Override
|
|
||||||
public RequestMappingHandlerMapping requestMappingHandlerMapping(
|
|
||||||
@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager,
|
|
||||||
@Qualifier("mvcConversionService") FormattingConversionService conversionService,
|
|
||||||
@Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) {
|
|
||||||
return super.requestMappingHandlerMapping(contentNegotiationManager, conversionService, resourceUrlProvider);
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,8 +26,8 @@ import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ClassUtil;
|
import cn.hutool.core.util.ClassUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Easy Excel 枚举基类转换器
|
* Easy Excel 枚举基类转换器
|
||||||
|
@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
|
|||||||
import cn.hutool.core.util.ClassUtil;
|
import cn.hutool.core.util.ClassUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用枚举基类 BaseEnum 反序列化器
|
* 通用枚举基类 BaseEnum 反序列化器
|
||||||
|
@ -23,7 +23,7 @@ import com.fasterxml.jackson.databind.JsonSerializer;
|
|||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
|
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用枚举接口 BaseEnum 序列化器
|
* 通用枚举接口 BaseEnum 序列化器
|
||||||
|
@ -25,7 +25,7 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jackson 配置
|
* Jackson 配置
|
||||||
|
@ -24,9 +24,9 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
|
||||||
import top.charles7c.cnadmin.common.exception.ServiceException;
|
|
||||||
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.exception.BusinessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MyBatis Plus 元对象处理器配置(插入或修改时自动填充)
|
* MyBatis Plus 元对象处理器配置(插入或修改时自动填充)
|
||||||
@ -70,7 +70,7 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler {
|
|||||||
this.fillFieldValue(metaObject, CREATE_TIME, createTime, false);
|
this.fillFieldValue(metaObject, CREATE_TIME, createTime, false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException("插入数据时自动填充异常:" + e.getMessage());
|
throw new BusinessException("插入数据时自动填充异常:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler {
|
|||||||
this.fillFieldValue(metaObject, UPDATE_TIME, updateTime, true);
|
this.fillFieldValue(metaObject, UPDATE_TIME, updateTime, true);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException("修改数据时自动填充异常:" + e.getMessage());
|
throw new BusinessException("修改数据时自动填充异常:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ package top.charles7c.cnadmin.common.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限枚举
|
* 数据权限枚举
|
||||||
|
@ -19,8 +19,8 @@ package top.charles7c.cnadmin.common.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
|
||||||
import top.charles7c.cnadmin.common.constant.UIConstants;
|
import top.charles7c.cnadmin.common.constant.UIConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用/禁用状态枚举
|
* 启用/禁用状态枚举
|
||||||
|
@ -19,7 +19,7 @@ package top.charles7c.cnadmin.common.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 性别枚举
|
* 性别枚举
|
||||||
|
@ -19,7 +19,7 @@ package top.charles7c.cnadmin.common.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单类型枚举
|
* 菜单类型枚举
|
||||||
|
@ -19,8 +19,8 @@ package top.charles7c.cnadmin.common.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
|
||||||
import top.charles7c.cnadmin.common.constant.UIConstants;
|
import top.charles7c.cnadmin.common.constant.UIConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息类型枚举
|
* 消息类型枚举
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询类型枚举
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/4/12 22:56
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum QueryTypeEnum implements IBaseEnum<Integer> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 等值查询,例如:WHERE `age` = 18
|
|
||||||
*/
|
|
||||||
EQUAL(1, "="),
|
|
||||||
/**
|
|
||||||
* 非等值查询,例如:WHERE `age` != 18
|
|
||||||
*/
|
|
||||||
NOT_EQUAL(2, "!="),
|
|
||||||
/**
|
|
||||||
* 大于查询,例如:WHERE `age` > 18
|
|
||||||
*/
|
|
||||||
GREATER_THAN(3, ">"),
|
|
||||||
/**
|
|
||||||
* 小于查询,例如:WHERE `age` < 18
|
|
||||||
*/
|
|
||||||
LESS_THAN(4, "<"),
|
|
||||||
/**
|
|
||||||
* 大于等于查询,例如:WHERE `age` >= 18
|
|
||||||
*/
|
|
||||||
GREATER_THAN_OR_EQUAL(5, ">="),
|
|
||||||
/**
|
|
||||||
* 小于等于查询,例如:WHERE `age` <= 18
|
|
||||||
*/
|
|
||||||
LESS_THAN_OR_EQUAL(6, "<="),
|
|
||||||
/**
|
|
||||||
* 范围查询,例如:WHERE `age` BETWEEN 10 AND 18
|
|
||||||
*/
|
|
||||||
BETWEEN(7, "BETWEEN"),
|
|
||||||
/**
|
|
||||||
* 左模糊查询,例如:WHERE `nickname` LIKE '%s'
|
|
||||||
*/
|
|
||||||
LEFT_LIKE(8, "LIKE '%s'"),
|
|
||||||
/**
|
|
||||||
* 中模糊查询,例如:WHERE `nickname` LIKE '%s%'
|
|
||||||
*/
|
|
||||||
INNER_LIKE(9, "LIKE '%s%'"),
|
|
||||||
/**
|
|
||||||
* 右模糊查询,例如:WHERE `nickname` LIKE 's%'
|
|
||||||
*/
|
|
||||||
RIGHT_LIKE(10, "LIKE 's%'"),
|
|
||||||
/**
|
|
||||||
* 包含查询,例如:WHERE `age` IN (10, 20, 30)
|
|
||||||
*/
|
|
||||||
IN(11, "IN"),
|
|
||||||
/**
|
|
||||||
* 不包含查询,例如:WHERE `age` NOT IN (20, 30)
|
|
||||||
*/
|
|
||||||
NOT_IN(12, "NOT IN"),
|
|
||||||
/**
|
|
||||||
* 空查询,例如:WHERE `email` IS NULL
|
|
||||||
*/
|
|
||||||
IS_NULL(13, "IS NULL"),
|
|
||||||
/**
|
|
||||||
* 非空查询,例如:WHERE `email` IS NOT NULL
|
|
||||||
*/
|
|
||||||
IS_NOT_NULL(14, "IS NOT NULL"),;
|
|
||||||
|
|
||||||
private final Integer value;
|
|
||||||
private final String description;
|
|
||||||
}
|
|
@ -19,8 +19,8 @@ package top.charles7c.cnadmin.common.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
|
||||||
import top.charles7c.cnadmin.common.constant.UIConstants;
|
import top.charles7c.cnadmin.common.constant.UIConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功/失败状态枚举
|
* 成功/失败状态枚举
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.exception;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义验证异常-错误请求
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2022/12/21 20:59
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class BadRequestException extends RuntimeException {
|
|
||||||
|
|
||||||
public BadRequestException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.exception;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务异常
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2022/12/23 22:55
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class ServiceException extends RuntimeException {
|
|
||||||
|
|
||||||
public ServiceException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.handler;
|
|
||||||
|
|
||||||
import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.springframework.lang.NonNull;
|
|
||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
|
||||||
import org.springframework.web.util.pattern.PathPatternParser;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
|
|
||||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CRUD 请求映射器处理器映射器
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/27 10:30
|
|
||||||
*/
|
|
||||||
public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMapping {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected RequestMappingInfo getMappingForMethod(@NonNull Method method, @NonNull Class<?> handlerType) {
|
|
||||||
RequestMappingInfo requestMappingInfo = super.getMappingForMethod(method, handlerType);
|
|
||||||
if (null == requestMappingInfo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果没有声明 @CrudRequestMapping 注解,直接返回
|
|
||||||
if (!handlerType.isAnnotationPresent(CrudRequestMapping.class)) {
|
|
||||||
return requestMappingInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取 @CrudRequestMapping 注解信息
|
|
||||||
CrudRequestMapping crudRequestMapping = handlerType.getDeclaredAnnotation(CrudRequestMapping.class);
|
|
||||||
// 拼接路径前缀(合并了 @RequestMapping 的部分能力)
|
|
||||||
String pathPrefix = crudRequestMapping.value();
|
|
||||||
if (StrUtil.isNotBlank(pathPrefix)) {
|
|
||||||
/*
|
|
||||||
* 问题:RequestMappingInfo.paths(pathPrefix) 返回的 RequestMappingInfo 对象里 pathPatternsCondition = null
|
|
||||||
* 导致 combine() 方法抛出断言异常! 修复:创建 options 对象,并设置 PatternParser
|
|
||||||
*/
|
|
||||||
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
|
|
||||||
options.setPatternParser(PathPatternParser.defaultInstance);
|
|
||||||
requestMappingInfo =
|
|
||||||
RequestMappingInfo.paths(pathPrefix).options(options).build().combine(requestMappingInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 过滤 API
|
|
||||||
Api[] apiArr = crudRequestMapping.api();
|
|
||||||
// 如果非本类中定义,且 API 列表中不包含,则忽略
|
|
||||||
Api api = ExceptionUtils.exToNull(() -> Api.valueOf(method.getName().toUpperCase()));
|
|
||||||
if (method.getDeclaringClass() != handlerType && !ArrayUtil.containsAny(apiArr, Api.ALL, api)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return requestMappingInfo;
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,7 +41,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.R;
|
import top.charles7c.continew.starter.extension.crud.model.resp.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局错误处理器
|
* 全局错误处理器
|
||||||
|
@ -40,12 +40,12 @@ import cn.dev33.satoken.exception.NotRoleException;
|
|||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.exception.BadRequestException;
|
|
||||||
import top.charles7c.cnadmin.common.exception.ServiceException;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.R;
|
|
||||||
import top.charles7c.cnadmin.common.util.StreamUtils;
|
import top.charles7c.cnadmin.common.util.StreamUtils;
|
||||||
import top.charles7c.cnadmin.common.util.holder.LogContextHolder;
|
import top.charles7c.cnadmin.common.util.holder.LogContextHolder;
|
||||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.exception.BadRequestException;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.exception.BusinessException;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.resp.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局异常处理器
|
* 全局异常处理器
|
||||||
@ -172,8 +172,8 @@ public class GlobalExceptionHandler {
|
|||||||
/**
|
/**
|
||||||
* 拦截业务异常
|
* 拦截业务异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(ServiceException.class)
|
@ExceptionHandler(BusinessException.class)
|
||||||
public R handleServiceException(ServiceException e, HttpServletRequest request) {
|
public R handleServiceException(BusinessException e, HttpServletRequest request) {
|
||||||
log.error("请求地址 [{}],发生业务异常。", request.getRequestURI(), e);
|
log.error("请求地址 [{}],发生业务异常。", request.getRequestURI(), e);
|
||||||
LogContextHolder.setErrorMsg(e.getMessage());
|
LogContextHolder.setErrorMsg(e.getMessage());
|
||||||
return R.fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage());
|
return R.fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage());
|
||||||
|
@ -31,8 +31,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.NoResponseAdvice;
|
import top.charles7c.continew.starter.extension.crud.annotation.NoResponseAdvice;
|
||||||
import top.charles7c.cnadmin.common.model.resp.R;
|
import top.charles7c.continew.starter.extension.crud.model.resp.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局响应结果处理器
|
* 全局响应结果处理器
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.model.query;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.Range;
|
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询条件
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/15 10:59
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ParameterObject
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Schema(description = "分页查询条件")
|
|
||||||
public class PageQuery extends SortQuery {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
/** 默认页码:1 */
|
|
||||||
private static final int DEFAULT_PAGE = 1;
|
|
||||||
/** 默认每页条数:10 */
|
|
||||||
private static final int DEFAULT_SIZE = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页码
|
|
||||||
*/
|
|
||||||
@Schema(description = "页码", example = "1")
|
|
||||||
@Min(value = 1, message = "页码最小值为 {value}")
|
|
||||||
private Integer page = DEFAULT_PAGE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每页条数
|
|
||||||
*/
|
|
||||||
@Schema(description = "每页条数", example = "10")
|
|
||||||
@Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max})")
|
|
||||||
private Integer size = DEFAULT_SIZE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于分页查询条件转换为 MyBatis Plus 分页条件
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* 列表数据类型
|
|
||||||
* @return MyBatis Plus 分页条件
|
|
||||||
*/
|
|
||||||
public <T> IPage<T> toPage() {
|
|
||||||
Page<T> mybatisPage = new Page<>(this.getPage(), this.getSize());
|
|
||||||
Sort pageSort = this.getSort();
|
|
||||||
if (CollUtil.isNotEmpty(pageSort)) {
|
|
||||||
for (Sort.Order order : pageSort) {
|
|
||||||
OrderItem orderItem = new OrderItem();
|
|
||||||
orderItem.setAsc(order.isAscending());
|
|
||||||
orderItem.setColumn(StrUtil.toUnderlineCase(order.getProperty()));
|
|
||||||
mybatisPage.addOrder(orderItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mybatisPage;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.model.query;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序查询条件
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/2/12 21:30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Schema(description = "排序查询条件")
|
|
||||||
public class SortQuery implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序条件
|
|
||||||
*/
|
|
||||||
@Schema(description = "排序条件", example = "createTime,desc")
|
|
||||||
private String[] sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析排序条件为 Spring 分页排序实体
|
|
||||||
*
|
|
||||||
* @return Spring 分页排序实体
|
|
||||||
*/
|
|
||||||
public Sort getSort() {
|
|
||||||
if (ArrayUtil.isEmpty(sort)) {
|
|
||||||
return Sort.unsorted();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Sort.Order> orders = new ArrayList<>(sort.length);
|
|
||||||
if (StrUtil.contains(sort[0], StringConstants.COMMA)) {
|
|
||||||
// e.g "sort=createTime,desc&sort=name,asc"
|
|
||||||
for (String s : sort) {
|
|
||||||
List<String> sortList = StrUtil.splitTrim(s, StringConstants.COMMA);
|
|
||||||
Sort.Order order =
|
|
||||||
new Sort.Order(Sort.Direction.valueOf(sortList.get(1).toUpperCase()), sortList.get(0));
|
|
||||||
orders.add(order);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// e.g "sort=createTime,desc"
|
|
||||||
Sort.Order order = new Sort.Order(Sort.Direction.valueOf(sort[1].toUpperCase()), sort[0]);
|
|
||||||
orders.add(order);
|
|
||||||
}
|
|
||||||
return Sort.by(orders);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,146 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.model.resp;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页信息
|
|
||||||
*
|
|
||||||
* @param <L>
|
|
||||||
* 列表数据类型
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/14 23:40
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Schema(description = "分页信息")
|
|
||||||
public class PageDataResp<L> implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表数据
|
|
||||||
*/
|
|
||||||
@Schema(description = "列表数据")
|
|
||||||
private List<L> list;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总记录数
|
|
||||||
*/
|
|
||||||
@Schema(description = "总记录数", example = "10")
|
|
||||||
private long total;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于 MyBatis Plus 分页数据构建分页信息,并将源数据转换为指定类型数据
|
|
||||||
*
|
|
||||||
* @param page
|
|
||||||
* MyBatis Plus 分页数据
|
|
||||||
* @param targetClass
|
|
||||||
* 目标类型 Class 对象
|
|
||||||
* @param <T>
|
|
||||||
* 源列表数据类型
|
|
||||||
* @param <L>
|
|
||||||
* 目标列表数据类型
|
|
||||||
* @return 分页信息
|
|
||||||
*/
|
|
||||||
public static <T, L> PageDataResp<L> build(IPage<T> page, Class<L> targetClass) {
|
|
||||||
if (null == page) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
PageDataResp<L> pageDataResp = new PageDataResp<>();
|
|
||||||
pageDataResp.setList(BeanUtil.copyToList(page.getRecords(), targetClass));
|
|
||||||
pageDataResp.setTotal(page.getTotal());
|
|
||||||
return pageDataResp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于 MyBatis Plus 分页数据构建分页信息
|
|
||||||
*
|
|
||||||
* @param page
|
|
||||||
* MyBatis Plus 分页数据
|
|
||||||
* @param <L>
|
|
||||||
* 列表数据类型
|
|
||||||
* @return 分页信息
|
|
||||||
*/
|
|
||||||
public static <L> PageDataResp<L> build(IPage<L> page) {
|
|
||||||
if (null == page) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
PageDataResp<L> pageDataResp = new PageDataResp<>();
|
|
||||||
pageDataResp.setList(page.getRecords());
|
|
||||||
pageDataResp.setTotal(page.getTotal());
|
|
||||||
return pageDataResp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于列表数据构建分页信息
|
|
||||||
*
|
|
||||||
* @param page
|
|
||||||
* 页码
|
|
||||||
* @param size
|
|
||||||
* 每页条数
|
|
||||||
* @param list
|
|
||||||
* 列表数据
|
|
||||||
* @param <L>
|
|
||||||
* 列表数据类型
|
|
||||||
* @return 分页信息
|
|
||||||
*/
|
|
||||||
public static <L> PageDataResp<L> build(int page, int size, List<L> list) {
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
PageDataResp<L> pageDataResp = new PageDataResp<>();
|
|
||||||
pageDataResp.setTotal(list.size());
|
|
||||||
// 对列表数据进行分页
|
|
||||||
int fromIndex = (page - 1) * size;
|
|
||||||
int toIndex = page * size + size;
|
|
||||||
if (fromIndex > list.size()) {
|
|
||||||
pageDataResp.setList(new ArrayList<>(0));
|
|
||||||
} else if (toIndex >= list.size()) {
|
|
||||||
pageDataResp.setList(list.subList(fromIndex, list.size()));
|
|
||||||
} else {
|
|
||||||
pageDataResp.setList(list.subList(fromIndex, toIndex));
|
|
||||||
}
|
|
||||||
return pageDataResp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 空分页信息
|
|
||||||
*
|
|
||||||
* @param <L>
|
|
||||||
* 列表数据类型
|
|
||||||
* @return 分页信息
|
|
||||||
*/
|
|
||||||
private static <L> PageDataResp<L> empty() {
|
|
||||||
PageDataResp<L> pageDataResp = new PageDataResp<>();
|
|
||||||
pageDataResp.setList(new ArrayList<>(0));
|
|
||||||
return pageDataResp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.model.resp;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应信息
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2022/12/10 23:31
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
@Schema(description = "响应信息")
|
|
||||||
public class R<T> implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 是否成功 */
|
|
||||||
@Schema(description = "是否成功", example = "true")
|
|
||||||
private boolean success;
|
|
||||||
|
|
||||||
/** 业务状态码 */
|
|
||||||
@Schema(description = "业务状态码", example = "200")
|
|
||||||
private int code;
|
|
||||||
|
|
||||||
/** 业务状态信息 */
|
|
||||||
@Schema(description = "业务状态信息", example = "操作成功")
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
/** 响应数据 */
|
|
||||||
@Schema(description = "响应数据")
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
/** 时间戳 */
|
|
||||||
@Schema(description = "时间戳", example = "1691453288")
|
|
||||||
private long timestamp = DateUtil.currentSeconds();
|
|
||||||
|
|
||||||
/** 成功状态码 */
|
|
||||||
private static final int SUCCESS_CODE = HttpStatus.OK.value();
|
|
||||||
/** 失败状态码 */
|
|
||||||
private static final int FAIL_CODE = HttpStatus.INTERNAL_SERVER_ERROR.value();
|
|
||||||
|
|
||||||
private R(boolean success, int code, String msg, T data) {
|
|
||||||
this.success = success;
|
|
||||||
this.code = code;
|
|
||||||
this.msg = msg;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok() {
|
|
||||||
return new R<>(true, SUCCESS_CODE, "操作成功", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(T data) {
|
|
||||||
return new R<>(true, SUCCESS_CODE, "操作成功", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(String msg) {
|
|
||||||
return new R<>(true, SUCCESS_CODE, msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(String msg, T data) {
|
|
||||||
return new R<>(true, SUCCESS_CODE, msg, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail() {
|
|
||||||
return new R<>(false, FAIL_CODE, "操作失败", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(String msg) {
|
|
||||||
return new R<>(false, FAIL_CODE, msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(T data) {
|
|
||||||
return new R<>(false, FAIL_CODE, "操作失败", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(String msg, T data) {
|
|
||||||
return new R<>(false, FAIL_CODE, msg, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(int code, String msg) {
|
|
||||||
return new R<>(false, code, msg, null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公共用户业务接口
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/2/13 20:37
|
|
||||||
*/
|
|
||||||
public interface CommonUserService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 ID 查询昵称
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* ID
|
|
||||||
* @return 昵称
|
|
||||||
*/
|
|
||||||
String getNicknameById(Long id);
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.util;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反射工具类
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/15 22:05
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class ReflectUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得一个类中所有非静态字段名列表,包括其父类中的字段<br>
|
|
||||||
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。
|
|
||||||
*
|
|
||||||
* @param beanClass
|
|
||||||
* 类
|
|
||||||
* @return 非静态字段名列表
|
|
||||||
* @throws SecurityException
|
|
||||||
* 安全检查异常
|
|
||||||
*/
|
|
||||||
public static List<String> getNonStaticFieldsName(Class<?> beanClass) throws SecurityException {
|
|
||||||
List<Field> nonStaticFields = getNonStaticFields(beanClass);
|
|
||||||
return nonStaticFields.stream().map(Field::getName).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得一个类中所有非静态字段列表,包括其父类中的字段<br>
|
|
||||||
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。
|
|
||||||
*
|
|
||||||
* @param beanClass
|
|
||||||
* 类
|
|
||||||
* @return 非静态字段列表
|
|
||||||
* @throws SecurityException
|
|
||||||
* 安全检查异常
|
|
||||||
*/
|
|
||||||
public static List<Field> getNonStaticFields(Class<?> beanClass) throws SecurityException {
|
|
||||||
Field[] fields = ReflectUtil.getFields(beanClass);
|
|
||||||
return Arrays.stream(fields).filter(f -> !Modifier.isStatic(f.getModifiers())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ import cn.hutool.crypto.SecureUtil;
|
|||||||
import cn.hutool.crypto.asymmetric.KeyType;
|
import cn.hutool.crypto.asymmetric.KeyType;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.config.properties.RsaProperties;
|
import top.charles7c.cnadmin.common.config.properties.RsaProperties;
|
||||||
import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
|
import top.charles7c.continew.starter.extension.crud.util.validate.ValidationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密/解密工具类
|
* 加密/解密工具类
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
|
||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
||||||
import cn.hutool.core.lang.tree.TreeUtil;
|
|
||||||
import cn.hutool.core.lang.tree.parser.NodeParser;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.TreeField;
|
|
||||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树工具类
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/22 22:11
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class TreeUtils {
|
|
||||||
|
|
||||||
/** 默认字段配置对象(根据前端树结构灵活调整名称) */
|
|
||||||
public static final TreeNodeConfig DEFAULT_CONFIG =
|
|
||||||
TreeNodeConfig.DEFAULT_CONFIG.setNameKey("title").setIdKey("key").setWeightKey("sort");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树构建
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* 转换的实体 为数据源里的对象类型
|
|
||||||
* @param <E>
|
|
||||||
* ID类型
|
|
||||||
* @param list
|
|
||||||
* 源数据集合
|
|
||||||
* @param nodeParser
|
|
||||||
* 转换器
|
|
||||||
* @return List 树列表
|
|
||||||
*/
|
|
||||||
public static <T, E> List<Tree<E>> build(List<T> list, NodeParser<T, E> nodeParser) {
|
|
||||||
return build(list, DEFAULT_CONFIG, nodeParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树构建
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* 转换的实体 为数据源里的对象类型
|
|
||||||
* @param <E>
|
|
||||||
* ID类型
|
|
||||||
* @param list
|
|
||||||
* 源数据集合
|
|
||||||
* @param treeNodeConfig
|
|
||||||
* 配置
|
|
||||||
* @param nodeParser
|
|
||||||
* 转换器
|
|
||||||
* @return List 树列表
|
|
||||||
*/
|
|
||||||
public static <T, E> List<Tree<E>> build(List<T> list, TreeNodeConfig treeNodeConfig, NodeParser<T, E> nodeParser) {
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return new ArrayList<>(0);
|
|
||||||
}
|
|
||||||
E parentId = (E)ReflectUtil.getFieldValue(list.get(0), treeNodeConfig.getParentIdKey());
|
|
||||||
return TreeUtil.build(list, parentId, treeNodeConfig, nodeParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 @TreeField 配置生成树结构配置
|
|
||||||
*
|
|
||||||
* @param treeField
|
|
||||||
* 树结构字段注解
|
|
||||||
* @return 树结构配置
|
|
||||||
*/
|
|
||||||
public static TreeNodeConfig genTreeNodeConfig(TreeField treeField) {
|
|
||||||
CheckUtils.throwIfNull(treeField, "请添加并配置 @TreeField 树结构信息");
|
|
||||||
return new TreeNodeConfig().setIdKey(treeField.value()).setParentIdKey(treeField.parentIdKey())
|
|
||||||
.setNameKey(treeField.nameKey()).setWeightKey(treeField.weightKey()).setChildrenKey(treeField.childrenKey())
|
|
||||||
.setDeep(treeField.deep() < 0 ? null : treeField.deep());
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,11 +32,11 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import top.charles7c.cnadmin.common.constant.CacheConstants;
|
import top.charles7c.cnadmin.common.constant.CacheConstants;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LogContext;
|
import top.charles7c.cnadmin.common.model.dto.LogContext;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
||||||
import top.charles7c.cnadmin.common.service.CommonUserService;
|
|
||||||
import top.charles7c.cnadmin.common.util.ServletUtils;
|
import top.charles7c.cnadmin.common.util.ServletUtils;
|
||||||
import top.charles7c.cnadmin.common.util.holder.LogContextHolder;
|
import top.charles7c.cnadmin.common.util.holder.LogContextHolder;
|
||||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
||||||
import top.charles7c.continew.starter.core.util.IpUtils;
|
import top.charles7c.continew.starter.core.util.IpUtils;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.CommonUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录助手
|
* 登录助手
|
||||||
|
@ -1,178 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.util.helper;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
|
||||||
import top.charles7c.cnadmin.common.exception.BadRequestException;
|
|
||||||
import top.charles7c.cnadmin.common.util.ReflectUtils;
|
|
||||||
import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询助手
|
|
||||||
*
|
|
||||||
* @author Zheng Jie(ELADMIN)
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/15 18:17
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class QueryHelper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据查询条件构建 MyBatis Plus 查询条件封装对象
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param <Q>
|
|
||||||
* 查询条件数据类型
|
|
||||||
* @param <R>
|
|
||||||
* 查询数据类型
|
|
||||||
* @return MyBatis Plus 查询条件封装对象
|
|
||||||
*/
|
|
||||||
public static <Q, R> QueryWrapper<R> build(Q query) {
|
|
||||||
QueryWrapper<R> queryWrapper = new QueryWrapper<>();
|
|
||||||
// 没有查询条件,直接返回
|
|
||||||
if (null == query) {
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
// 获取查询条件中所有的字段
|
|
||||||
List<Field> fieldList = ReflectUtils.getNonStaticFields(query.getClass());
|
|
||||||
fieldList.forEach(field -> buildQuery(query, field, queryWrapper));
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建 MyBatis Plus 查询条件封装对象
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* 查询条件
|
|
||||||
* @param field
|
|
||||||
* 字段
|
|
||||||
* @param queryWrapper
|
|
||||||
* MyBatis Plus 查询条件封装对象
|
|
||||||
* @param <Q>
|
|
||||||
* 查询条件数据类型
|
|
||||||
* @param <R>
|
|
||||||
* 查询数据类型
|
|
||||||
*/
|
|
||||||
private static <Q, R> void buildQuery(Q query, Field field, QueryWrapper<R> queryWrapper) {
|
|
||||||
boolean accessible = field.canAccess(query);
|
|
||||||
try {
|
|
||||||
field.setAccessible(true);
|
|
||||||
// 没有 @Query,直接返回
|
|
||||||
Query queryAnnotation = field.getAnnotation(Query.class);
|
|
||||||
if (null == queryAnnotation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果字段值为空,直接返回
|
|
||||||
Object fieldValue = field.get(query);
|
|
||||||
if (ObjectUtil.isEmpty(fieldValue)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析查询条件
|
|
||||||
parse(queryAnnotation, field.getName(), fieldValue, queryWrapper);
|
|
||||||
} catch (BadRequestException e) {
|
|
||||||
log.error("Build query occurred an validation error: {}. Query: {}, Field: {}.", e.getMessage(), query,
|
|
||||||
field, e);
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Build query occurred an error: {}. Query: {}, Field: {}.", e.getMessage(), query, field, e);
|
|
||||||
} finally {
|
|
||||||
field.setAccessible(accessible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析查询条件
|
|
||||||
*
|
|
||||||
* @param queryAnnotation
|
|
||||||
* 查询注解
|
|
||||||
* @param fieldName
|
|
||||||
* 字段名
|
|
||||||
* @param fieldValue
|
|
||||||
* 字段值
|
|
||||||
* @param queryWrapper
|
|
||||||
* MyBatis Plus 查询条件封装对象
|
|
||||||
* @param <R>
|
|
||||||
* 查询数据类型
|
|
||||||
*/
|
|
||||||
private static <R> void parse(Query queryAnnotation, String fieldName, Object fieldValue,
|
|
||||||
QueryWrapper<R> queryWrapper) {
|
|
||||||
// 解析多属性模糊查询
|
|
||||||
// 如果设置了多属性模糊查询,分割属性进行条件拼接
|
|
||||||
String[] blurryPropertyArr = queryAnnotation.blurry();
|
|
||||||
if (ArrayUtil.isNotEmpty(blurryPropertyArr)) {
|
|
||||||
queryWrapper.and(wrapper -> {
|
|
||||||
for (String blurryProperty : blurryPropertyArr) {
|
|
||||||
wrapper.or().like(StrUtil.toUnderlineCase(blurryProperty), fieldValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析单个属性查询
|
|
||||||
// 如果没有单独指定属性名,就和使用该注解的属性的名称一致
|
|
||||||
// 注意:数据库规范中列采用下划线连接法命名,程序规范中变量采用驼峰法命名
|
|
||||||
String property = queryAnnotation.property();
|
|
||||||
String columnName = StrUtil.toUnderlineCase(StrUtil.blankToDefault(property, fieldName));
|
|
||||||
QueryTypeEnum queryType = queryAnnotation.type();
|
|
||||||
switch (queryType) {
|
|
||||||
case EQUAL -> queryWrapper.eq(columnName, fieldValue);
|
|
||||||
case NOT_EQUAL -> queryWrapper.ne(columnName, fieldValue);
|
|
||||||
case GREATER_THAN -> queryWrapper.gt(columnName, fieldValue);
|
|
||||||
case LESS_THAN -> queryWrapper.lt(columnName, fieldValue);
|
|
||||||
case GREATER_THAN_OR_EQUAL -> queryWrapper.ge(columnName, fieldValue);
|
|
||||||
case LESS_THAN_OR_EQUAL -> queryWrapper.le(columnName, fieldValue);
|
|
||||||
case BETWEEN -> {
|
|
||||||
List<Object> between = new ArrayList<>((List<Object>)fieldValue);
|
|
||||||
ValidationUtils.throwIf(between.size() != 2, "[{}] 必须是一个范围", fieldName);
|
|
||||||
queryWrapper.between(columnName, between.get(0), between.get(1));
|
|
||||||
}
|
|
||||||
case LEFT_LIKE -> queryWrapper.likeLeft(columnName, fieldValue);
|
|
||||||
case INNER_LIKE -> queryWrapper.like(columnName, fieldValue);
|
|
||||||
case RIGHT_LIKE -> queryWrapper.likeRight(columnName, fieldValue);
|
|
||||||
case IN -> {
|
|
||||||
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName);
|
|
||||||
queryWrapper.in(columnName, (List<Object>)fieldValue);
|
|
||||||
}
|
|
||||||
case NOT_IN -> {
|
|
||||||
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName);
|
|
||||||
queryWrapper.notIn(columnName, (List<Object>)fieldValue);
|
|
||||||
}
|
|
||||||
case IS_NULL -> queryWrapper.isNull(columnName);
|
|
||||||
case IS_NOT_NULL -> queryWrapper.isNotNull(columnName);
|
|
||||||
default -> throw new IllegalArgumentException(String.format("暂不支持 [%s] 查询类型", queryType));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,254 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.util.validate;
|
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.exception.ServiceException;
|
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务参数校验工具类(抛出 500 ServiceException)
|
|
||||||
*
|
|
||||||
* @see ServiceException
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/2 22:12
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class CheckUtils extends Validator {
|
|
||||||
|
|
||||||
private static final Class<ServiceException> EXCEPTION_TYPE = ServiceException.class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不存在,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param entityName
|
|
||||||
* 实体名
|
|
||||||
* @param fieldName
|
|
||||||
* 字段名
|
|
||||||
* @param fieldValue
|
|
||||||
* 字段值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
|
||||||
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue,
|
|
||||||
StrUtil.replace(entityName, "DO", StringConstants.EMPTY));
|
|
||||||
throwIfNull(obj, message, EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNull(Object obj, String template, Object... params) {
|
|
||||||
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
|
||||||
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果存在,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param entityName
|
|
||||||
* 实体名
|
|
||||||
* @param fieldName
|
|
||||||
* 字段名
|
|
||||||
* @param fieldValue
|
|
||||||
* 字段值
|
|
||||||
*/
|
|
||||||
public static void throwIfExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
|
||||||
String message = String.format("%s 为 [%s] 的 %s 记录已存在", fieldName, fieldValue, entityName);
|
|
||||||
throwIfNotNull(obj, message, EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
|
||||||
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
|
||||||
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
* 被检测的字符串
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
|
||||||
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
* 被检测的字符串
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
|
||||||
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果相同,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* 要比较的对象1
|
|
||||||
* @param obj2
|
|
||||||
* 要比较的对象2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
|
||||||
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不相同,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* 要比较的对象1
|
|
||||||
* @param obj2
|
|
||||||
* 要比较的对象2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
|
||||||
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果相同,抛出异常(不区分大小写)
|
|
||||||
*
|
|
||||||
* @param str1
|
|
||||||
* 要比较的字符串1
|
|
||||||
* @param str2
|
|
||||||
* 要比较的字符串2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
|
||||||
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不相同,抛出异常(不区分大小写)
|
|
||||||
*
|
|
||||||
* @param str1
|
|
||||||
* 要比较的字符串1
|
|
||||||
* @param str2
|
|
||||||
* 要比较的字符串2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template,
|
|
||||||
Object... params) {
|
|
||||||
throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果条件成立,抛出异常
|
|
||||||
*
|
|
||||||
* @param condition
|
|
||||||
* 条件
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIf(boolean condition, String template, Object... params) {
|
|
||||||
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果条件成立,抛出异常
|
|
||||||
*
|
|
||||||
* @param conditionSupplier
|
|
||||||
* 条件
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
|
||||||
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,218 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.util.validate;
|
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.exception.BadRequestException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基本参数校验工具类(抛出 400 BadRequestException)
|
|
||||||
*
|
|
||||||
* @see BadRequestException
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2022/12/21 20:56
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class ValidationUtils extends Validator {
|
|
||||||
|
|
||||||
private static final Class<BadRequestException> EXCEPTION_TYPE = BadRequestException.class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNull(Object obj, String template, Object... params) {
|
|
||||||
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
|
||||||
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
|
||||||
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
|
||||||
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
* 被检测的字符串
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
|
||||||
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
* 被检测的字符串
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
|
||||||
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果相同,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* 要比较的对象1
|
|
||||||
* @param obj2
|
|
||||||
* 要比较的对象2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
|
||||||
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不相同,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* 要比较的对象1
|
|
||||||
* @param obj2
|
|
||||||
* 要比较的对象2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
|
||||||
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果相同,抛出异常(不区分大小写)
|
|
||||||
*
|
|
||||||
* @param str1
|
|
||||||
* 要比较的字符串1
|
|
||||||
* @param str2
|
|
||||||
* 要比较的字符串2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
|
||||||
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不相同,抛出异常(不区分大小写)
|
|
||||||
*
|
|
||||||
* @param str1
|
|
||||||
* 要比较的字符串1
|
|
||||||
* @param str2
|
|
||||||
* 要比较的字符串2
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template,
|
|
||||||
Object... params) {
|
|
||||||
throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果条件成立,抛出异常
|
|
||||||
*
|
|
||||||
* @param condition
|
|
||||||
* 条件
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIf(boolean condition, String template, Object... params) {
|
|
||||||
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果条件成立,抛出异常
|
|
||||||
*
|
|
||||||
* @param conditionSupplier
|
|
||||||
* 条件
|
|
||||||
* @param template
|
|
||||||
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null"
|
|
||||||
* @param params
|
|
||||||
* 参数值
|
|
||||||
*/
|
|
||||||
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
|
||||||
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,227 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.common.util.validate;
|
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验器
|
|
||||||
*
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2023/1/2 22:12
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
public class Validator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(null == obj, message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(null != obj, message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(ObjectUtil.isEmpty(obj), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* 被检测的对象
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfNotEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(ObjectUtil.isNotEmpty(obj), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
* 被检测的字符串
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfBlank(CharSequence str, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(StrUtil.isBlank(str), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不为空,抛出异常
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
* 被检测的字符串
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfNotBlank(CharSequence str, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(StrUtil.isNotBlank(str), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果相同,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* 要比较的对象1
|
|
||||||
* @param obj2
|
|
||||||
* 要比较的对象2
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfEqual(Object obj1, Object obj2, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(ObjectUtil.equal(obj1, obj2), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不相同,抛出异常
|
|
||||||
*
|
|
||||||
* @param obj1
|
|
||||||
* 要比较的对象1
|
|
||||||
* @param obj2
|
|
||||||
* 要比较的对象2
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfNotEqual(Object obj1, Object obj2, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(ObjectUtil.notEqual(obj1, obj2), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果相同,抛出异常(不区分大小写)
|
|
||||||
*
|
|
||||||
* @param str1
|
|
||||||
* 要比较的字符串1
|
|
||||||
* @param str2
|
|
||||||
* 要比较的字符串2
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果不相同,抛出异常(不区分大小写)
|
|
||||||
*
|
|
||||||
* @param str1
|
|
||||||
* 要比较的字符串1
|
|
||||||
* @param str2
|
|
||||||
* 要比较的字符串2
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
throwIf(!StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果条件成立,抛出异常
|
|
||||||
*
|
|
||||||
* @param condition
|
|
||||||
* 条件
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIf(boolean condition, String message, Class<? extends RuntimeException> exceptionType) {
|
|
||||||
if (condition) {
|
|
||||||
log.error(message);
|
|
||||||
throw ReflectUtil.newInstance(exceptionType, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果条件成立,抛出异常
|
|
||||||
*
|
|
||||||
* @param conditionSupplier
|
|
||||||
* 条件
|
|
||||||
* @param message
|
|
||||||
* 错误信息
|
|
||||||
* @param exceptionType
|
|
||||||
* 异常类型
|
|
||||||
*/
|
|
||||||
protected static void throwIf(BooleanSupplier conditionSupplier, String message,
|
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
|
||||||
if (null != conditionSupplier && conditionSupplier.getAsBoolean()) {
|
|
||||||
log.error(message);
|
|
||||||
throw ReflectUtil.newInstance(exceptionType, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ package top.charles7c.cnadmin.monitor.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作状态枚举
|
* 操作状态枚举
|
||||||
|
@ -53,7 +53,6 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import top.charles7c.cnadmin.auth.model.req.AccountLoginReq;
|
import top.charles7c.cnadmin.auth.model.req.AccountLoginReq;
|
||||||
import top.charles7c.cnadmin.common.constant.SysConstants;
|
import top.charles7c.cnadmin.common.constant.SysConstants;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LogContext;
|
import top.charles7c.cnadmin.common.model.dto.LogContext;
|
||||||
import top.charles7c.cnadmin.common.model.resp.R;
|
|
||||||
import top.charles7c.cnadmin.common.util.ServletUtils;
|
import top.charles7c.cnadmin.common.util.ServletUtils;
|
||||||
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
||||||
import top.charles7c.cnadmin.common.util.holder.LogContextHolder;
|
import top.charles7c.cnadmin.common.util.holder.LogContextHolder;
|
||||||
@ -65,6 +64,7 @@ import top.charles7c.cnadmin.system.service.UserService;
|
|||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
||||||
import top.charles7c.continew.starter.core.util.IpUtils;
|
import top.charles7c.continew.starter.core.util.IpUtils;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.resp.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统日志拦截器
|
* 系统日志拦截器
|
||||||
|
@ -21,11 +21,11 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.monitor.model.entity.LogDO;
|
import top.charles7c.cnadmin.monitor.model.entity.LogDO;
|
||||||
import top.charles7c.cnadmin.monitor.model.resp.DashboardAccessTrendResp;
|
import top.charles7c.cnadmin.monitor.model.resp.DashboardAccessTrendResp;
|
||||||
import top.charles7c.cnadmin.monitor.model.resp.DashboardPopularModuleResp;
|
import top.charles7c.cnadmin.monitor.model.resp.DashboardPopularModuleResp;
|
||||||
import top.charles7c.cnadmin.monitor.model.resp.DashboardTotalResp;
|
import top.charles7c.cnadmin.monitor.model.resp.DashboardTotalResp;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统日志 Mapper
|
* 系统日志 Mapper
|
||||||
|
@ -29,8 +29,8 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录日志查询条件
|
* 登录日志查询条件
|
||||||
|
@ -29,8 +29,8 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作日志查询条件
|
* 操作日志查询条件
|
||||||
|
@ -29,8 +29,8 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统日志查询条件
|
* 系统日志查询条件
|
||||||
|
@ -19,12 +19,12 @@ package top.charles7c.cnadmin.monitor.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
|
||||||
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
||||||
import top.charles7c.cnadmin.monitor.model.query.OperationLogQuery;
|
import top.charles7c.cnadmin.monitor.model.query.OperationLogQuery;
|
||||||
import top.charles7c.cnadmin.monitor.model.query.SystemLogQuery;
|
import top.charles7c.cnadmin.monitor.model.query.SystemLogQuery;
|
||||||
import top.charles7c.cnadmin.monitor.model.resp.*;
|
import top.charles7c.cnadmin.monitor.model.resp.*;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.resp.PageDataResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统日志业务接口
|
* 系统日志业务接口
|
||||||
|
@ -34,12 +34,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.constant.SysConstants;
|
import top.charles7c.cnadmin.common.constant.SysConstants;
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
|
||||||
import top.charles7c.cnadmin.common.service.CommonUserService;
|
|
||||||
import top.charles7c.cnadmin.common.util.ReflectUtils;
|
|
||||||
import top.charles7c.cnadmin.common.util.helper.QueryHelper;
|
|
||||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
|
||||||
import top.charles7c.cnadmin.monitor.mapper.LogMapper;
|
import top.charles7c.cnadmin.monitor.mapper.LogMapper;
|
||||||
import top.charles7c.cnadmin.monitor.model.entity.LogDO;
|
import top.charles7c.cnadmin.monitor.model.entity.LogDO;
|
||||||
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
||||||
@ -48,6 +42,12 @@ import top.charles7c.cnadmin.monitor.model.query.SystemLogQuery;
|
|||||||
import top.charles7c.cnadmin.monitor.model.resp.*;
|
import top.charles7c.cnadmin.monitor.model.resp.*;
|
||||||
import top.charles7c.cnadmin.monitor.service.LogService;
|
import top.charles7c.cnadmin.monitor.service.LogService;
|
||||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
import top.charles7c.continew.starter.core.util.ExceptionUtils;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.CommonUserService;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.resp.PageDataResp;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.util.QueryHelper;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.util.ReflectUtils;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.util.validate.CheckUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统日志业务实现
|
* 系统日志业务实现
|
||||||
|
@ -21,8 +21,8 @@ import java.util.List;
|
|||||||
import top.charles7c.cnadmin.auth.model.query.OnlineUserQuery;
|
import top.charles7c.cnadmin.auth.model.query.OnlineUserQuery;
|
||||||
import top.charles7c.cnadmin.auth.model.resp.OnlineUserResp;
|
import top.charles7c.cnadmin.auth.model.resp.OnlineUserResp;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
import top.charles7c.continew.starter.extension.crud.model.resp.PageDataResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户业务接口
|
* 在线用户业务接口
|
||||||
|
@ -38,7 +38,6 @@ import top.charles7c.cnadmin.auth.model.resp.MetaResp;
|
|||||||
import top.charles7c.cnadmin.auth.model.resp.RouteResp;
|
import top.charles7c.cnadmin.auth.model.resp.RouteResp;
|
||||||
import top.charles7c.cnadmin.auth.service.LoginService;
|
import top.charles7c.cnadmin.auth.service.LoginService;
|
||||||
import top.charles7c.cnadmin.auth.service.PermissionService;
|
import top.charles7c.cnadmin.auth.service.PermissionService;
|
||||||
import top.charles7c.cnadmin.common.annotation.TreeField;
|
|
||||||
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
||||||
import top.charles7c.cnadmin.common.constant.SysConstants;
|
import top.charles7c.cnadmin.common.constant.SysConstants;
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
@ -47,9 +46,7 @@ import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
|||||||
import top.charles7c.cnadmin.common.enums.MessageTypeEnum;
|
import top.charles7c.cnadmin.common.enums.MessageTypeEnum;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
||||||
import top.charles7c.cnadmin.common.util.SecureUtils;
|
import top.charles7c.cnadmin.common.util.SecureUtils;
|
||||||
import top.charles7c.cnadmin.common.util.TreeUtils;
|
|
||||||
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
||||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
|
||||||
import top.charles7c.cnadmin.system.enums.MessageTemplateEnum;
|
import top.charles7c.cnadmin.system.enums.MessageTemplateEnum;
|
||||||
import top.charles7c.cnadmin.system.model.entity.RoleDO;
|
import top.charles7c.cnadmin.system.model.entity.RoleDO;
|
||||||
import top.charles7c.cnadmin.system.model.entity.UserDO;
|
import top.charles7c.cnadmin.system.model.entity.UserDO;
|
||||||
@ -59,6 +56,9 @@ import top.charles7c.cnadmin.system.model.resp.DeptDetailResp;
|
|||||||
import top.charles7c.cnadmin.system.model.resp.MenuResp;
|
import top.charles7c.cnadmin.system.model.resp.MenuResp;
|
||||||
import top.charles7c.cnadmin.system.service.*;
|
import top.charles7c.cnadmin.system.service.*;
|
||||||
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
|
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.annotation.TreeField;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.util.TreeUtils;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.util.validate.CheckUtils;
|
||||||
|
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
import me.zhyd.oauth.model.AuthUser;
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ import top.charles7c.cnadmin.auth.model.query.OnlineUserQuery;
|
|||||||
import top.charles7c.cnadmin.auth.model.resp.OnlineUserResp;
|
import top.charles7c.cnadmin.auth.model.resp.OnlineUserResp;
|
||||||
import top.charles7c.cnadmin.auth.service.OnlineUserService;
|
import top.charles7c.cnadmin.auth.service.OnlineUserService;
|
||||||
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
import top.charles7c.cnadmin.common.model.dto.LoginUser;
|
||||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
|
||||||
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.model.resp.PageDataResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户业务实现
|
* 在线用户业务实现
|
||||||
|
@ -19,8 +19,8 @@ package top.charles7c.cnadmin.system.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.IBaseEnum;
|
|
||||||
import top.charles7c.cnadmin.common.constant.UIConstants;
|
import top.charles7c.cnadmin.common.constant.UIConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.IBaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告状态枚举
|
* 公告状态枚举
|
||||||
|
@ -18,9 +18,9 @@ package top.charles7c.cnadmin.system.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.AnnouncementDO;
|
import top.charles7c.cnadmin.system.model.entity.AnnouncementDO;
|
||||||
import top.charles7c.cnadmin.system.model.resp.DashboardAnnouncementResp;
|
import top.charles7c.cnadmin.system.model.resp.DashboardAnnouncementResp;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告 Mapper
|
* 公告 Mapper
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package top.charles7c.cnadmin.system.mapper;
|
package top.charles7c.cnadmin.system.mapper;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.DeptDO;
|
import top.charles7c.cnadmin.system.model.entity.DeptDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门 Mapper
|
* 部门 Mapper
|
||||||
|
@ -20,9 +20,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.common.model.resp.LabelValueResp;
|
import top.charles7c.cnadmin.common.model.resp.LabelValueResp;
|
||||||
import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项 Mapper
|
* 字典项 Mapper
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package top.charles7c.cnadmin.system.mapper;
|
package top.charles7c.cnadmin.system.mapper;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.DictDO;
|
import top.charles7c.cnadmin.system.model.entity.DictDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 Mapper
|
* 字典 Mapper
|
||||||
|
@ -21,8 +21,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.MenuDO;
|
import top.charles7c.cnadmin.system.model.entity.MenuDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单 Mapper
|
* 菜单 Mapper
|
||||||
|
@ -22,9 +22,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.MessageDO;
|
import top.charles7c.cnadmin.system.model.entity.MessageDO;
|
||||||
import top.charles7c.cnadmin.system.model.resp.MessageResp;
|
import top.charles7c.cnadmin.system.model.resp.MessageResp;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息 Mapper
|
* 消息 Mapper
|
||||||
|
@ -18,8 +18,8 @@ package top.charles7c.cnadmin.system.mapper;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.MessageUserDO;
|
import top.charles7c.cnadmin.system.model.entity.MessageUserDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息和用户 Mapper
|
* 消息和用户 Mapper
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package top.charles7c.cnadmin.system.mapper;
|
package top.charles7c.cnadmin.system.mapper;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.OptionDO;
|
import top.charles7c.cnadmin.system.model.entity.OptionDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数 Mapper
|
* 参数 Mapper
|
||||||
|
@ -21,8 +21,8 @@ import java.util.List;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.RoleDeptDO;
|
import top.charles7c.cnadmin.system.model.entity.RoleDeptDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色和部门 Mapper
|
* 角色和部门 Mapper
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package top.charles7c.cnadmin.system.mapper;
|
package top.charles7c.cnadmin.system.mapper;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.RoleDO;
|
import top.charles7c.cnadmin.system.model.entity.RoleDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色 Mapper
|
* 角色 Mapper
|
||||||
|
@ -18,8 +18,8 @@ package top.charles7c.cnadmin.system.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.RoleMenuDO;
|
import top.charles7c.cnadmin.system.model.entity.RoleMenuDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色和菜单 Mapper
|
* 角色和菜单 Mapper
|
||||||
|
@ -21,8 +21,8 @@ import java.util.List;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.UserRoleDO;
|
import top.charles7c.cnadmin.system.model.entity.UserRoleDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户和角色 Mapper
|
* 用户和角色 Mapper
|
||||||
|
@ -18,8 +18,8 @@ package top.charles7c.cnadmin.system.mapper;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
|
||||||
import top.charles7c.cnadmin.system.model.entity.UserSocialDO;
|
import top.charles7c.cnadmin.system.model.entity.UserSocialDO;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户社会化关联 Mapper
|
* 用户社会化关联 Mapper
|
||||||
|
@ -23,7 +23,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告实体
|
* 公告实体
|
||||||
|
@ -22,8 +22,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门实体
|
* 部门实体
|
||||||
|
@ -22,7 +22,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典实体
|
* 字典实体
|
||||||
|
@ -22,7 +22,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项实体
|
* 字典项实体
|
||||||
|
@ -22,9 +22,9 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单实体
|
* 菜单实体
|
||||||
|
@ -22,9 +22,9 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
|
||||||
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
|
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色实体
|
* 角色实体
|
||||||
|
@ -23,9 +23,9 @@ import lombok.Data;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
import top.charles7c.cnadmin.common.enums.GenderEnum;
|
import top.charles7c.cnadmin.common.enums.GenderEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户实体
|
* 用户实体
|
||||||
|
@ -23,8 +23,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告查询条件
|
* 公告查询条件
|
||||||
|
@ -23,8 +23,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门查询条件
|
* 部门查询条件
|
||||||
|
@ -23,7 +23,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项查询条件
|
* 字典项查询条件
|
||||||
|
@ -23,7 +23,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典查询条件
|
* 字典查询条件
|
||||||
|
@ -23,8 +23,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单查询条件
|
* 菜单查询条件
|
||||||
|
@ -22,8 +22,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息查询条件
|
* 消息查询条件
|
||||||
|
@ -26,8 +26,8 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数查询条件
|
* 参数查询条件
|
||||||
|
@ -23,7 +23,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色查询条件
|
* 角色查询条件
|
||||||
|
@ -29,8 +29,8 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.annotation.Query;
|
import top.charles7c.continew.starter.extension.crud.annotation.Query;
|
||||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
import top.charles7c.continew.starter.extension.crud.enums.QueryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户查询条件
|
* 用户查询条件
|
||||||
|
@ -27,7 +27,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改公告信息
|
* 创建或修改公告信息
|
||||||
|
@ -29,10 +29,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
|
||||||
import top.charles7c.cnadmin.common.base.ValidateGroup;
|
|
||||||
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.ValidateGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改部门信息
|
* 创建或修改部门信息
|
||||||
|
@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改字典项信息
|
* 创建或修改字典项信息
|
||||||
|
@ -26,8 +26,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
|
||||||
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改字典信息
|
* 创建或修改字典信息
|
||||||
|
@ -28,9 +28,9 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改菜单信息
|
* 创建或修改菜单信息
|
||||||
|
@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
|
||||||
import top.charles7c.cnadmin.common.enums.MessageTypeEnum;
|
import top.charles7c.cnadmin.common.enums.MessageTypeEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建消息信息
|
* 创建消息信息
|
||||||
|
@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改参数信息
|
* 修改参数信息
|
||||||
|
@ -30,10 +30,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
|
||||||
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
||||||
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
|
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改角色信息
|
* 创建或修改角色信息
|
||||||
|
@ -30,10 +30,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseReq;
|
|
||||||
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
import top.charles7c.cnadmin.common.constant.RegexConstants;
|
||||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||||
import top.charles7c.cnadmin.common.enums.GenderEnum;
|
import top.charles7c.cnadmin.common.enums.GenderEnum;
|
||||||
|
import top.charles7c.continew.starter.extension.crud.base.BaseReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建或修改用户信息
|
* 创建或修改用户信息
|
||||||
|
@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseDetailResp;
|
import top.charles7c.continew.starter.extension.crud.base.BaseDetailResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告详情信息
|
* 公告详情信息
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user