refactor(system): 重构系统模块的数据查询和分页功能

This commit is contained in:
2026-01-12 15:12:40 +08:00
parent e511ccdd6d
commit ff22d3072c
49 changed files with 102 additions and 211 deletions
@@ -151,7 +151,7 @@
</template> </template>
<script> <script>
import crudRoles, {getCurrentUserRoleLevel} from '@/api/system/role' import crudRoles from '@/api/system/role'
import { searchDept, searchDeptTree } from '@/api/system/dept' import { searchDept, searchDeptTree } from '@/api/system/dept'
import { listChildMenuSetByMenuId, listMenuByPid } from '@/api/system/menu' import { listChildMenuSetByMenuId, listMenuByPid } from '@/api/system/menu'
import CRUD, { crud, form, header, presenter } from '@crud/crud' import CRUD, { crud, form, header, presenter } from '@crud/crud'
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.annotation; package cn.odboy.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.annotation; package cn.odboy.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.annotation; package cn.odboy.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.annotation; package cn.odboy.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.annotation; package cn.odboy.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.util.Date; import java.util.Date;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@@ -29,8 +28,7 @@ import lombok.Setter;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class KitBaseCreateTimeTb extends KitObject { public class KitBaseCreateTimeTb extends KitObject {
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
createTime; private Date createTime;
} }
@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.util.Date; import java.util.Date;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@@ -30,11 +29,9 @@ import lombok.Setter;
public class KitBaseTimeTb extends KitObject { public class KitBaseTimeTb extends KitObject {
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
private Date private Date createTime;
createTime;
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
private Date updateTime; private Date updateTime;
} }
@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.util.Date; import java.util.Date;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@@ -29,7 +28,7 @@ import lombok.Setter;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class KitBaseUpdateTimeTb extends KitObject { public class KitBaseUpdateTimeTb extends KitObject {
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
private Date updateTime; private Date updateTime;
} }
@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Date; import java.util.Date;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -34,13 +33,12 @@ public class KitBaseUserCreateTimeTb extends KitObject {
@CreatedBy @CreatedBy
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@Schema(name = "创建人", hidden = true) @ApiModelProperty(value = "创建人", hidden = true)
private String createBy; private String
createBy;
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
private Date private Date createTime;
createTime;
@Override @Override
public String toString() { public String toString() {
@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.util.Date; import java.util.Date;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -38,21 +37,21 @@ public class KitBaseUserTimeLogicTb extends KitObject {
@CreatedBy @CreatedBy
@TableField(value = "create_by", fill = FieldFill.INSERT) @TableField(value = "create_by", fill = FieldFill.INSERT)
@Schema(name = "创建人", hidden = true) @ApiModelProperty(value = "创建人", hidden = true)
private String createBy; private String createBy;
@LastModifiedBy @LastModifiedBy
@TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
@Schema(name = "更新人", hidden = true) @ApiModelProperty(value = "更新人", hidden = true)
private String updateBy; private String updateBy;
@TableField(value = "create_time", fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
@Schema(name = "创建时间", hidden = true) @ApiModelProperty(value = "创建时间", hidden = true)
private Date private Date createTime;
createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@Schema(name = "更新时间", hidden = true) @ApiModelProperty(value = "更新时间", hidden = true)
private Date updateTime; private Date updateTime;
@Schema(name = "数据有效性", hidden = true) @ApiModelProperty(value = "数据有效性", hidden = true)
@TableLogic @TableLogic
@TableField("available") @TableField("available")
private Integer available; private Integer
available;
} }
@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Date; import java.util.Date;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -35,22 +34,18 @@ public class KitBaseUserTimeTb extends KitObject {
@CreatedBy @CreatedBy
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@Schema(name = "创建人", hidden = true) @ApiModelProperty(value = "创建人", hidden = true)
private String createBy; private String
createBy;
@LastModifiedBy @LastModifiedBy
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(name = "更新人", hidden = true) @ApiModelProperty(value = "更新人", hidden = true)
private String private String updateBy;
updateBy;
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
private Date private Date createTime;
createTime;
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
private Date updateTime; private Date updateTime;
@Override @Override
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
@@ -27,6 +25,5 @@ import java.io.Serializable;
*/ */
public class KitObject implements Serializable { public class KitObject implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -37,11 +36,11 @@ public class KitPageArgs<T> implements Serializable {
@NotNull(message = "参数page不能为空") @NotNull(message = "参数page不能为空")
@Min(value = 1, message = "参数page最小值为1") @Min(value = 1, message = "参数page最小值为1")
@Schema(name = "页码", example = "1") @ApiModelProperty(value = "页码", example = "1")
private Integer page; private Integer page;
@NotNull(message = "参数size不能为空") @NotNull(message = "参数size不能为空")
@Min(value = 1, message = "参数size最小值为1") @Min(value = 1, message = "参数size最小值为1")
@Schema(name = "每页数据量", example = "10") @ApiModelProperty(value = "每页数据量", example = "10")
private Integer size; private Integer size;
private T args; private T args;
} }
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.base; package cn.odboy.base;
import java.util.Map; import java.util.Map;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.constant; package cn.odboy.constant;
/** /**
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.constant; package cn.odboy.constant;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -24,7 +23,6 @@ import lombok.Getter;
public enum FileTypeEnum { public enum FileTypeEnum {
/* 文件类型 */ /* 文件类型 */
IMAGE("image", "图片"), DOC("doc", "文档"), VOICE("voice", "音频"), VIDEO("video", "视频"), OTHER("other", "其他"); IMAGE("image", "图片"), DOC("doc", "文档"), VOICE("voice", "音频"), VIDEO("video", "视频"), OTHER("other", "其他");
private final String code; private final String code;
private final String description; private final String description;
} }
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.constant; package cn.odboy.constant;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -22,37 +21,30 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum RequestMethodEnum { public enum RequestMethodEnum {
/** /**
* 搜寻 @AnonymousGetMapping * 搜寻 @AnonymousGetMapping
*/ */
GET("GET"), GET("GET"),
/** /**
* 搜寻 @AnonymousPostMapping * 搜寻 @AnonymousPostMapping
*/ */
POST("POST"), POST("POST"),
/** /**
* 搜寻 @AnonymousPutMapping * 搜寻 @AnonymousPutMapping
*/ */
PUT("PUT"), PUT("PUT"),
/** /**
* 搜寻 @AnonymousPatchMapping * 搜寻 @AnonymousPatchMapping
*/ */
PATCH("PATCH"), PATCH("PATCH"),
/** /**
* 搜寻 @AnonymousDeleteMapping * 搜寻 @AnonymousDeleteMapping
*/ */
DELETE("DELETE"), DELETE("DELETE"),
/** /**
* 否则就是所有 Request 接口都放行 * 否则就是所有 Request 接口都放行
*/ */
ALL("All"); ALL("All");
/** /**
* Request 类型 * Request 类型
*/ */
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.constant; package cn.odboy.constant;
/** /**
@@ -25,22 +24,18 @@ public interface SystemConst {
* win 系统 * win 系统
*/ */
String WIN = "win"; String WIN = "win";
/** /**
* mac 系统 * mac 系统
*/ */
String MAC = "mac"; String MAC = "mac";
/** /**
* 请求头名称 * 请求头名称
*/ */
String HEADER_NAME = "Authorization"; String HEADER_NAME = "Authorization";
/** /**
* Token前缀 * Token前缀
*/ */
String TOKEN_PREFIX = "Bearer"; String TOKEN_PREFIX = "Bearer";
/** /**
* 小数点 * 小数点
*/ */
@@ -48,7 +48,7 @@ public class KitAnonTagUtil {
RequestMappingHandlerMapping requestMappingHandlerMapping = RequestMappingHandlerMapping requestMappingHandlerMapping =
(RequestMappingHandlerMapping) applicationContext.getBean("requestMappingHandlerMapping"); (RequestMappingHandlerMapping) applicationContext.getBean("requestMappingHandlerMapping");
Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods(); Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods();
Map<String, Set<String>> anonymousUrls = new HashMap<>(8); Map<String, java.util.Set<String>> anonymousUrls = new HashMap<>(8);
// 获取匿名标记 // 获取匿名标记
Set<String> get = new HashSet<>(); Set<String> get = new HashSet<>();
Set<String> post = new HashSet<>(); Set<String> post = new HashSet<>();
@@ -17,6 +17,7 @@ package cn.odboy.util;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitSelectOptionVo; import cn.odboy.base.KitSelectOptionVo;
import cn.odboy.framework.exception.BadRequestException;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -39,7 +40,7 @@ import lombok.experimental.UtilityClass;
* @date 2022-11-09 * @date 2022-11-09
*/ */
@UtilityClass @UtilityClass
public final class KitCollUtil extends CollUtil { public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
private static <T, K> Predicate<T> distinctPredicate(Function<? super T, ? extends K> keyMapper) { private static <T, K> Predicate<T> distinctPredicate(Function<? super T, ? extends K> keyMapper) {
Map<Object, Boolean> map = new HashMap<>(3); Map<Object, Boolean> map = new HashMap<>(3);
@@ -28,9 +28,6 @@ import cn.hutool.poi.excel.ExcelUtil;
import cn.odboy.constant.FileTypeEnum; import cn.odboy.constant.FileTypeEnum;
import cn.odboy.constant.SystemConst; import cn.odboy.constant.SystemConst;
import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.exception.BadRequestException;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@@ -45,6 +42,9 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
@@ -72,9 +72,8 @@ public class SystemRoleController {
@ApiOperation("查询角色") @ApiOperation("查询角色")
@PostMapping(value = "/searchRole") @PostMapping(value = "/searchRole")
@PreAuthorize("@el.check('roles:list')") @PreAuthorize("@el.check('roles:list')")
public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs( public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs(@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> pageArgs) {
@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> pageArgs) { Page<SystemRoleTb> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
Page<Object> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
return ResponseEntity.ok(systemRoleService.searchRoleByArgs(pageArgs.getArgs(), page)); return ResponseEntity.ok(systemRoleService.searchRoleByArgs(pageArgs.getArgs(), page));
} }
@@ -23,8 +23,4 @@ public class SystemQueryDictArgs {
@ApiModelProperty(value = "模糊查询") @ApiModelProperty(value = "模糊查询")
private String blurry; private String blurry;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -31,8 +31,4 @@ public class SystemQueryJobArgs {
private Boolean enabled; private Boolean enabled;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -27,10 +27,4 @@ public class SystemQueryRoleArgs {
private String blurry; private String blurry;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
@ApiModelProperty(value = "偏移量", hidden = true)
private long offset;
} }
@@ -40,8 +40,4 @@ public class SystemQueryUserArgs extends KitObject {
private Long deptId; private Long deptId;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -18,7 +18,6 @@ package cn.odboy.system.dal.mysql;
import cn.odboy.system.dal.dataobject.SystemDictTb; import cn.odboy.system.dal.dataobject.SystemDictTb;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
@@ -29,10 +28,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface SystemDictMapper extends BaseMapper<SystemDictTb> { public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
default List<SystemDictTb> listAll() {
return selectList(null);
}
default SystemDictTb getByName(String dictName) { default SystemDictTb getByName(String dictName) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemDictTb::getName, dictName); wrapper.eq(SystemDictTb::getName, dictName);
@@ -43,8 +43,8 @@ public class BizLockAspect {
public Object around(ProceedingJoinPoint joinPoint, BizLock bizLock) throws Throwable { public Object around(ProceedingJoinPoint joinPoint, BizLock bizLock) throws Throwable {
// 解析SpEL表达式生成最终的lockKey // 解析SpEL表达式生成最终的lockKey
String lockKey = parseLockKey(joinPoint, bizLock); String lockKey = parseLockKey(joinPoint, bizLock);
Boolean success = redisHelper.setIfAbsent(lockKey, lockKey, bizLock.leaseTime(), bizLock.timeUnit()); boolean success = redisHelper.setIfAbsent(lockKey, lockKey, bizLock.leaseTime(), bizLock.timeUnit());
if (success == null || !success) { if (!success) {
throw new BadRequestException(bizLock.errorMessage()); throw new BadRequestException(bizLock.errorMessage());
} }
try { try {
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.system.framework.mybatisplus; package cn.odboy.system.framework.mybatisplus;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
@@ -55,4 +54,3 @@ public class MpMetaObjectHandler implements MetaObjectHandler {
this.strictUpdateFill(metaObject, "updateBy", String.class, username); this.strictUpdateFill(metaObject, "updateBy", String.class, username);
} }
} }
@@ -27,8 +27,8 @@ import cn.odboy.util.KitBrowserUtil;
import cn.odboy.util.KitIPUtil; import cn.odboy.util.KitIPUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
@@ -96,7 +96,7 @@ public class OperationLogAspect {
} }
} }
if (StrUtil.isBlank(bizName)) { if (StrUtil.isBlank(bizName)) {
bizName = "Default"; bizName = "默认业务";
} }
String method = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()"; String method = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.system.framework.storage; package cn.odboy.system.framework.storage;
import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.exception.BadRequestException;
@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.system.framework.storage.local; package cn.odboy.system.framework.storage.local;
import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.properties.AppProperties;
import jakarta.servlet.MultipartConfigElement;
import java.io.File; import java.io.File;
import jakarta.servlet.MultipartConfigElement;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.odboy.system.framework.storage.minio; package cn.odboy.system.framework.storage.minio;
import cn.hutool.core.io.FastByteArrayOutputStream; import cn.hutool.core.io.FastByteArrayOutputStream;
@@ -44,13 +43,13 @@ import io.minio.Result;
import io.minio.http.Method; import io.minio.http.Method;
import io.minio.messages.Bucket; import io.minio.messages.Bucket;
import io.minio.messages.Item; import io.minio.messages.Item;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -153,13 +152,11 @@ public class MinioRepository {
String type = FileTypeUtil.getType(tempFile); String type = FileTypeUtil.getType(tempFile);
String prefix = KitFileUtil.getPrefix(tempFile); String prefix = KitFileUtil.getPrefix(tempFile);
String suffix = KitFileUtil.getSuffix(tempFile); String suffix = KitFileUtil.getSuffix(tempFile);
String fileCode = IdUtil.fastSimpleUUID(); String fileCode = IdUtil.fastSimpleUUID();
String fileName = fileCode + FileUtil.getSuffix(originalFilename); String fileName = fileCode + FileUtil.getSuffix(originalFilename);
String objectName = KitDateUtil.getNowDateStr() + "/" + fileName; String objectName = KitDateUtil.getNowDateStr() + "/" + fileName;
log.info("上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName); log.info("上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName);
String fileUrl = ossMinioConfig.getEndpoint() + "/" + ossMinioConfig.getBucketName() + "/" + objectName; String fileUrl = ossMinioConfig.getEndpoint() + "/" + ossMinioConfig.getBucketName() + "/" + objectName;
SystemOssStorageTb systemOssStorageTb = new SystemOssStorageTb(); SystemOssStorageTb systemOssStorageTb = new SystemOssStorageTb();
systemOssStorageTb.setServiceType("minio"); systemOssStorageTb.setServiceType("minio");
systemOssStorageTb.setEndpoint(ossMinioConfig.getEndpoint()); systemOssStorageTb.setEndpoint(ossMinioConfig.getEndpoint());
@@ -173,7 +170,6 @@ public class MinioRepository {
systemOssStorageTb.setFileUrl(fileUrl); systemOssStorageTb.setFileUrl(fileUrl);
systemOssStorageTb.setFileCode(fileCode); systemOssStorageTb.setFileCode(fileCode);
systemOssStorageTb.setObjectName(objectName); systemOssStorageTb.setObjectName(objectName);
try (InputStream fileInputStream = KitFileUtil.getInputStream(tempFile)) { try (InputStream fileInputStream = KitFileUtil.getInputStream(tempFile)) {
PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(ossMinioConfig.getBucketName()).object(objectName) PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(ossMinioConfig.getBucketName()).object(objectName)
.stream(fileInputStream, fileSize, -1).contentType(contentType).build(); .stream(fileInputStream, fileSize, -1).contentType(contentType).build();
@@ -203,14 +199,11 @@ public class MinioRepository {
if (StrUtil.isBlank(originalFilename)) { if (StrUtil.isBlank(originalFilename)) {
throw new BadRequestException("文件名不能为空"); throw new BadRequestException("文件名不能为空");
} }
long size = file.getSize(); long size = file.getSize();
KitFileUtil.checkSize(properties.getOss().getMaxSize(), size); KitFileUtil.checkSize(properties.getOss().getMaxSize(), size);
String fileName = UUID.randomUUID() + FileUtil.getSuffix(originalFilename); String fileName = UUID.randomUUID() + FileUtil.getSuffix(originalFilename);
// yyyy/MM/dd/fileName.xxx // yyyy/MM/dd/fileName.xxx
String objectName = KitDateUtil.getNowDateTimeStr() + "/" + fileName; String objectName = KitDateUtil.getNowDateTimeStr() + "/" + fileName;
log.info("准备上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName); log.info("准备上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName);
try (InputStream fileInputStream = file.getInputStream()) { try (InputStream fileInputStream = file.getInputStream()) {
PutObjectArgs objectArgs = PutObjectArgs objectArgs =
@@ -286,17 +279,14 @@ public class MinioRepository {
public void download(String fileName, HttpServletResponse res) { public void download(String fileName, HttpServletResponse res) {
GetObjectArgs objectArgs = GetObjectArgs objectArgs =
GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build(); GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build();
try (GetObjectResponse response = minioClient.getObject(objectArgs); try (GetObjectResponse response = minioClient.getObject(objectArgs);
FastByteArrayOutputStream os = new FastByteArrayOutputStream()) { FastByteArrayOutputStream os = new FastByteArrayOutputStream()) {
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
int len; int len;
while ((len = response.read(buf)) != -1) { while ((len = response.read(buf)) != -1) {
os.write(buf, 0, len); os.write(buf, 0, len);
} }
os.flush(); os.flush();
byte[] bytes = os.toByteArray(); byte[] bytes = os.toByteArray();
res.setCharacterEncoding("utf-8"); res.setCharacterEncoding("utf-8");
res.addHeader("Content-Disposition", "attachment;fileName=" + fileName); res.addHeader("Content-Disposition", "attachment;fileName=" + fileName);
@@ -318,12 +308,10 @@ public class MinioRepository {
public void downloadOptimizedVersion(String fileName, HttpServletResponse res) { public void downloadOptimizedVersion(String fileName, HttpServletResponse res) {
GetObjectArgs objectArgs = GetObjectArgs objectArgs =
GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build(); GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build();
try (GetObjectResponse response = minioClient.getObject(objectArgs)) { try (GetObjectResponse response = minioClient.getObject(objectArgs)) {
// 增大缓冲区 // 增大缓冲区
byte[] buf = new byte[1024 * 4]; byte[] buf = new byte[1024 * 4];
int len; int len;
// 分块下载并输出到响应流 // 分块下载并输出到响应流
try (ServletOutputStream stream = res.getOutputStream()) { try (ServletOutputStream stream = res.getOutputStream()) {
res.setCharacterEncoding("utf-8"); res.setCharacterEncoding("utf-8");
@@ -331,7 +319,6 @@ public class MinioRepository {
res.setHeader("Cache-Control", "no-store"); res.setHeader("Cache-Control", "no-store");
res.setHeader("Pragma", "no-cache"); res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", "0"); res.setHeader("Expires", "0");
while ((len = response.read(buf)) != -1) { while ((len = response.read(buf)) != -1) {
stream.write(buf, 0, len); stream.write(buf, 0, len);
// 确保实时写入 // 确保实时写入
@@ -92,7 +92,7 @@ public class SystemDictService {
*/ */
public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page) { public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
injectQueryParams(args, wrapper); this.injectQueryParams(args, wrapper);
Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, wrapper); Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, wrapper);
return KitPageUtil.toPage(selectPage); return KitPageUtil.toPage(selectPage);
} }
@@ -105,7 +105,7 @@ public class SystemDictService {
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) { public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
injectQueryParams(args, wrapper); this.injectQueryParams(args, wrapper);
return systemDictMapper.selectList(wrapper); return systemDictMapper.selectList(wrapper);
} }
@@ -20,6 +20,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.framework.logging.ExecutionTimeStatisticsFace;
import cn.odboy.system.constant.SystemTransferProtocolConst; import cn.odboy.system.constant.SystemTransferProtocolConst;
import cn.odboy.system.constant.SystemYesOrNoChConst; import cn.odboy.system.constant.SystemYesOrNoChConst;
import cn.odboy.system.dal.dataobject.SystemMenuTb; import cn.odboy.system.dal.dataobject.SystemMenuTb;
@@ -68,7 +68,7 @@ public class SystemRoleService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveRole(SystemCreateRoleArgs args) { public void saveRole(SystemCreateRoleArgs args) {
checkRoleLevels(args.getLevel()); checkRoleLevels(args.getLevel());
if (this.getRoleByName(args.getName()) != null) { if (this.countRoleByName(args.getName()) > 0) {
throw new BadRequestException("角色名称已存在"); throw new BadRequestException("角色名称已存在");
} }
SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class); SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class);
@@ -85,6 +85,12 @@ public class SystemRoleService {
return systemRoleMapper.selectOne(wrapper); return systemRoleMapper.selectOne(wrapper);
} }
private long countRoleByName(String name) {
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemRoleTb::getName, name);
return systemRoleMapper.selectCount(wrapper);
}
/** /**
* 修改 * 修改
* *
@@ -166,10 +172,11 @@ public class SystemRoleService {
/** /**
* 根据条件查询全部角色 * 根据条件查询全部角色
* *
* @param args 条件 * @param args 条件
* @param rolePage 分页参数
* @return / * @return /
*/ */
public List<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs args) { public List<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs args, Page<SystemRoleTb> rolePage) {
KitValidUtil.notNull(args); KitValidUtil.notNull(args);
// 查询角色基本信息 // 查询角色基本信息
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
@@ -181,27 +188,25 @@ public class SystemRoleService {
args.getCreateTime().get(1)); args.getCreateTime().get(1));
} }
wrapper.orderByAsc(SystemRoleTb::getLevel); wrapper.orderByAsc(SystemRoleTb::getLevel);
if (args.getSize() != null) { List<SystemRoleTb> roles;
Page<SystemRoleTb> rolePage = new Page<>(args.getPage(), args.getSize()); if (rolePage == null) {
Page<SystemRoleTb> page = systemRoleMapper.selectPage(rolePage, wrapper); roles = systemRoleMapper.selectList(wrapper);
List<SystemRoleTb> roles = page.getRecords();
return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList());
} else { } else {
List<SystemRoleTb> roles = systemRoleMapper.selectList(wrapper); Page<SystemRoleTb> page = systemRoleMapper.selectPage(rolePage, wrapper);
return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList()); roles = page.getRecords();
} }
return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList());
} }
/** /**
* 分页查询角色 * 分页查询角色
* *
* @param args 条件 * @param args 条件
* @param page 分页参数 * @param page 分页条件
* @return / * @return /
*/ */
public KitPageResult<SystemRoleVo> searchRoleByArgs(SystemQueryRoleArgs args, Page<Object> page) { public KitPageResult<SystemRoleVo> searchRoleByArgs(SystemQueryRoleArgs args, Page<SystemRoleTb> page) {
args.setOffset(page.offset()); List<SystemRoleVo> roles = this.queryRoleByArgs(args, page);
List<SystemRoleVo> roles = this.queryRoleByArgs(args);
Long total = this.countRoleByArgs(args); Long total = this.countRoleByArgs(args);
return KitPageUtil.toPage(roles, total); return KitPageUtil.toPage(roles, total);
} }
@@ -280,7 +285,7 @@ public class SystemRoleService {
} }
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) { public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
List<SystemRoleVo> systemRoleVos = this.queryRoleByArgs(args); List<SystemRoleVo> systemRoleVos = this.queryRoleByArgs(args, null);
List<SystemRoleExportRowVo> rowVos = new ArrayList<>(); List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
for (SystemRoleVo dataObject : systemRoleVos) { for (SystemRoleVo dataObject : systemRoleVos) {
SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo(); SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo();
@@ -343,20 +343,6 @@ public class SystemUserService {
return KitPageUtil.toPage(userVos, userPage.getTotal()); return KitPageUtil.toPage(userVos, userPage.getTotal());
} }
// /**
// * 查询全部不分页
// *
// * @param args 条件
// * @return /
// */
// public List<SystemUserVo> queryUserVoByArgs(SystemQueryUserArgs args) {
// // 查询用户基本信息
// LambdaQueryWrapper<SystemUserTb> wrapper = buildUserQueryWrapper(args);
// List<SystemUserTb> users = systemUserMapper.selectList(wrapper);
// // 转换为SystemUserVo并关联查询
// return users.stream().map(this::convertToUserVo).collect(Collectors.toList());
// }
public long countUserByArgs(SystemQueryUserArgs args) { public long countUserByArgs(SystemQueryUserArgs args) {
LambdaQueryWrapper<SystemUserTb> wrapper = buildUserQueryWrapper(args); LambdaQueryWrapper<SystemUserTb> wrapper = buildUserQueryWrapper(args);
return systemUserMapper.selectCount(wrapper); return systemUserMapper.selectCount(wrapper);
@@ -385,7 +371,7 @@ public class SystemUserService {
c.or(); c.or();
c.like(SystemUserTb::getNickName, args.getBlurry()); c.like(SystemUserTb::getNickName, args.getBlurry());
}); });
return systemUserMapper.selectPage(new Page<>(args.getPage(), 50), wrapper).getRecords().stream().map(m -> { return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> {
Map<String, Object> ext = new HashMap<>(1); Map<String, Object> ext = new HashMap<>(1);
ext.put("id", m.getId()); ext.put("id", m.getId());
ext.put("deptId", m.getDeptId()); ext.put("deptId", m.getDeptId());
@@ -72,9 +72,8 @@ public class SystemRoleController {
@ApiOperation("查询角色") @ApiOperation("查询角色")
@PostMapping(value = "/searchRole") @PostMapping(value = "/searchRole")
@PreAuthorize("@el.check('roles:list')") @PreAuthorize("@el.check('roles:list')")
public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs( public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs(@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> pageArgs) {
@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> pageArgs) { Page<SystemRoleTb> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
Page<Object> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
return ResponseEntity.ok(systemRoleService.searchRoleByArgs(pageArgs.getArgs(), page)); return ResponseEntity.ok(systemRoleService.searchRoleByArgs(pageArgs.getArgs(), page));
} }
@@ -23,8 +23,4 @@ public class SystemQueryDictArgs {
@ApiModelProperty(value = "模糊查询") @ApiModelProperty(value = "模糊查询")
private String blurry; private String blurry;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -31,8 +31,4 @@ public class SystemQueryJobArgs {
private Boolean enabled; private Boolean enabled;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -27,10 +27,4 @@ public class SystemQueryRoleArgs {
private String blurry; private String blurry;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
@ApiModelProperty(value = "偏移量", hidden = true)
private long offset;
} }
@@ -40,8 +40,4 @@ public class SystemQueryUserArgs extends KitObject {
private Long deptId; private Long deptId;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -18,7 +18,6 @@ package cn.odboy.system.dal.mysql;
import cn.odboy.system.dal.dataobject.SystemDictTb; import cn.odboy.system.dal.dataobject.SystemDictTb;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
@@ -29,10 +28,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface SystemDictMapper extends BaseMapper<SystemDictTb> { public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
default List<SystemDictTb> listAll() {
return selectList(null);
}
default SystemDictTb getByName(String dictName) { default SystemDictTb getByName(String dictName) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemDictTb::getName, dictName); wrapper.eq(SystemDictTb::getName, dictName);
@@ -92,7 +92,7 @@ public class SystemDictService {
*/ */
public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page) { public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
injectQueryParams(args, wrapper); this.injectQueryParams(args, wrapper);
Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, wrapper); Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, wrapper);
return KitPageUtil.toPage(selectPage); return KitPageUtil.toPage(selectPage);
} }
@@ -105,7 +105,7 @@ public class SystemDictService {
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) { public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
injectQueryParams(args, wrapper); this.injectQueryParams(args, wrapper);
return systemDictMapper.selectList(wrapper); return systemDictMapper.selectList(wrapper);
} }
@@ -68,7 +68,7 @@ public class SystemRoleService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveRole(SystemCreateRoleArgs args) { public void saveRole(SystemCreateRoleArgs args) {
checkRoleLevels(args.getLevel()); checkRoleLevels(args.getLevel());
if (this.getRoleByName(args.getName()) != null) { if (this.countRoleByName(args.getName()) > 0) {
throw new BadRequestException("角色名称已存在"); throw new BadRequestException("角色名称已存在");
} }
SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class); SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class);
@@ -85,6 +85,12 @@ public class SystemRoleService {
return systemRoleMapper.selectOne(wrapper); return systemRoleMapper.selectOne(wrapper);
} }
private long countRoleByName(String name) {
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemRoleTb::getName, name);
return systemRoleMapper.selectCount(wrapper);
}
/** /**
* 修改 * 修改
* *
@@ -166,10 +172,11 @@ public class SystemRoleService {
/** /**
* 根据条件查询全部角色 * 根据条件查询全部角色
* *
* @param args 条件 * @param args 条件
* @param rolePage 分页参数
* @return / * @return /
*/ */
public List<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs args) { public List<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs args, Page<SystemRoleTb> rolePage) {
KitValidUtil.notNull(args); KitValidUtil.notNull(args);
// 查询角色基本信息 // 查询角色基本信息
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
@@ -181,27 +188,25 @@ public class SystemRoleService {
args.getCreateTime().get(1)); args.getCreateTime().get(1));
} }
wrapper.orderByAsc(SystemRoleTb::getLevel); wrapper.orderByAsc(SystemRoleTb::getLevel);
if (args.getSize() != null) { List<SystemRoleTb> roles;
Page<SystemRoleTb> rolePage = new Page<>(args.getPage(), args.getSize()); if (rolePage == null) {
Page<SystemRoleTb> page = systemRoleMapper.selectPage(rolePage, wrapper); roles = systemRoleMapper.selectList(wrapper);
List<SystemRoleTb> roles = page.getRecords();
return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList());
} else { } else {
List<SystemRoleTb> roles = systemRoleMapper.selectList(wrapper); Page<SystemRoleTb> page = systemRoleMapper.selectPage(rolePage, wrapper);
return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList()); roles = page.getRecords();
} }
return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList());
} }
/** /**
* 分页查询角色 * 分页查询角色
* *
* @param args 条件 * @param args 条件
* @param page 分页参数 * @param page 分页条件
* @return / * @return /
*/ */
public KitPageResult<SystemRoleVo> searchRoleByArgs(SystemQueryRoleArgs args, Page<Object> page) { public KitPageResult<SystemRoleVo> searchRoleByArgs(SystemQueryRoleArgs args, Page<SystemRoleTb> page) {
args.setOffset(page.offset()); List<SystemRoleVo> roles = this.queryRoleByArgs(args, page);
List<SystemRoleVo> roles = this.queryRoleByArgs(args);
Long total = this.countRoleByArgs(args); Long total = this.countRoleByArgs(args);
return KitPageUtil.toPage(roles, total); return KitPageUtil.toPage(roles, total);
} }
@@ -280,7 +285,7 @@ public class SystemRoleService {
} }
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) { public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
List<SystemRoleVo> systemRoleVos = this.queryRoleByArgs(args); List<SystemRoleVo> systemRoleVos = this.queryRoleByArgs(args, null);
List<SystemRoleExportRowVo> rowVos = new ArrayList<>(); List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
for (SystemRoleVo dataObject : systemRoleVos) { for (SystemRoleVo dataObject : systemRoleVos) {
SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo(); SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo();
@@ -371,7 +371,7 @@ public class SystemUserService {
c.or(); c.or();
c.like(SystemUserTb::getNickName, args.getBlurry()); c.like(SystemUserTb::getNickName, args.getBlurry());
}); });
return systemUserMapper.selectPage(new Page<>(args.getPage(), 50), wrapper).getRecords().stream().map(m -> { return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> {
Map<String, Object> ext = new HashMap<>(1); Map<String, Object> ext = new HashMap<>(1);
ext.put("id", m.getId()); ext.put("id", m.getId());
ext.put("deptId", m.getDeptId()); ext.put("deptId", m.getDeptId());