Merge pull request #42 from burningimlam/For-Pure
补充缺少的javadoc&消除部分代码检查警告
This commit is contained in:
commit
f03f441cb4
@ -5,6 +5,7 @@ import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.exception.error.ErrorCode.Business;
|
||||
import com.agileboot.domain.common.dto.CurrentLoginUserDTO;
|
||||
import com.agileboot.domain.common.dto.TokenDTO;
|
||||
import com.agileboot.domain.system.menu.MenuApplicationService;
|
||||
import com.agileboot.domain.system.menu.dto.RouterDTO;
|
||||
import com.agileboot.domain.system.user.UserApplicationService;
|
||||
@ -17,7 +18,6 @@ import com.agileboot.infrastructure.web.domain.login.CaptchaDTO;
|
||||
import com.agileboot.infrastructure.web.domain.login.ConfigDTO;
|
||||
import com.agileboot.infrastructure.web.domain.login.LoginDTO;
|
||||
import com.agileboot.infrastructure.web.domain.login.LoginUser;
|
||||
import com.agileboot.domain.common.dto.TokenDTO;
|
||||
import com.agileboot.infrastructure.web.domain.ratelimit.RateLimitKey;
|
||||
import com.agileboot.infrastructure.web.service.LoginService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -67,7 +67,8 @@ public class LoginController {
|
||||
|
||||
/**
|
||||
* 获取系统的内置配置
|
||||
* @return
|
||||
*
|
||||
* @return 配置信息
|
||||
*/
|
||||
@GetMapping("/getConfig")
|
||||
public ResponseDTO<ConfigDTO> getConfig() {
|
||||
|
||||
@ -55,9 +55,10 @@ public class MonitorController extends BaseController {
|
||||
|
||||
/**
|
||||
* 获取在线用户列表
|
||||
* @param ipaddr
|
||||
* @param userName
|
||||
* @return
|
||||
*
|
||||
* @param ipaddr ip地址
|
||||
* @param userName 用户名
|
||||
* @return 分页处理后的在线用户信息
|
||||
*/
|
||||
@Operation(summary = "在线用户列表")
|
||||
@PreAuthorize("@permission.has('monitor:online:list')")
|
||||
|
||||
@ -6,12 +6,12 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
* 定制banner.txt的网站
|
||||
* http://patorjk.com/software/taag
|
||||
* http://www.network-science.de/ascii/
|
||||
* http://www.degraeve.com/img2txt.php
|
||||
* http://life.chacuo.net/convertfont2char
|
||||
* 启动程序 定制banner.txt的网站
|
||||
* <a href="http://patorjk.com/software/taag">http://patorjk.com/software/taag</a>
|
||||
* <a href="http://www.network-science.de/ascii/">http://www.network-science.de/ascii/</a>
|
||||
* <a href="http://www.degraeve.com/img2txt.php">http://www.degraeve.com/img2txt.php</a>
|
||||
* <a href="http://life.chacuo.net/convertfont2char">http://life.chacuo.net/convertfont2char</a>
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
|
||||
@ -35,6 +35,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -266,7 +267,7 @@ public class JacksonUtil {
|
||||
*/
|
||||
public static <V> List<V> fromList(String json, Class<V> type) {
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, type);
|
||||
@ -281,7 +282,7 @@ public class JacksonUtil {
|
||||
*/
|
||||
public static Map<String, Object> fromMap(String json) {
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return null;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
try {
|
||||
MapType mapType = mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class);
|
||||
@ -497,12 +498,12 @@ public class JacksonUtil {
|
||||
*/
|
||||
public static byte[] getAsBytes(String json, String key) {
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return null;
|
||||
return new byte[0];
|
||||
}
|
||||
try {
|
||||
JsonNode jsonNode = getAsJsonObject(json, key);
|
||||
if (null == jsonNode) {
|
||||
return null;
|
||||
return new byte[0];
|
||||
}
|
||||
return jsonNode.isBinary() ? jsonNode.binaryValue() : getAsString(jsonNode).getBytes();
|
||||
} catch (Exception e) {
|
||||
@ -540,12 +541,12 @@ public class JacksonUtil {
|
||||
*/
|
||||
public static <V> List<V> getAsList(String json, String key, Class<V> type) {
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
JsonNode jsonNode = getAsJsonObject(json, key);
|
||||
if (null == jsonNode) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, type);
|
||||
return from(getAsString(jsonNode), collectionType);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
package com.agileboot.common.utils.time;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
@ -15,11 +14,10 @@ public class DatePickUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全地获取日期的一天开始时间, date为null 则返回null
|
||||
* DateUtil.beginOfDay(date) 如果传null 会NPE
|
||||
* 安全地获取日期的一天开始时间, date为null 则返回null DateUtil.beginOfDay(date) 如果传null 会NPE
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
* @param date 当前日期
|
||||
* @return 日期的一天开始时间
|
||||
*/
|
||||
public static Date getBeginOfTheDay(Date date) {
|
||||
if (date == null) {
|
||||
@ -37,7 +35,7 @@ public class DatePickUtil {
|
||||
* 安全地获取日期的一天结束时间, date为null 则返回null。 避免NPE
|
||||
* DateUtil.endOfDay(date) 如果传null 会NPE
|
||||
* @param date 23:59:59
|
||||
* @return
|
||||
* @return 日期的一天结束时间
|
||||
*/
|
||||
public static Date getEndOfTheDay(Date date) {
|
||||
if (date == null) {
|
||||
|
||||
@ -13,10 +13,12 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ConfigModel extends SysConfigEntity {
|
||||
|
||||
|
||||
@ -3,10 +3,12 @@ package com.agileboot.domain.system.dept.command;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.PositiveOrZero;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdateDeptCommand extends AddDeptCommand {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.Objects;
|
||||
*/
|
||||
public class DeptModel extends SysDeptEntity {
|
||||
|
||||
private ISysDeptService deptService;
|
||||
private final ISysDeptService deptService;
|
||||
|
||||
public DeptModel(ISysDeptService deptService) {
|
||||
this.deptService = deptService;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.agileboot.domain.system.menu;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
@ -11,10 +10,8 @@ import com.agileboot.domain.system.menu.dto.MenuDTO;
|
||||
import com.agileboot.domain.system.menu.dto.RouterDTO;
|
||||
import com.agileboot.domain.system.menu.model.MenuModel;
|
||||
import com.agileboot.domain.system.menu.model.MenuModelFactory;
|
||||
import com.agileboot.domain.system.menu.model.RouterModel;
|
||||
import com.agileboot.domain.system.menu.query.MenuQuery;
|
||||
import com.agileboot.infrastructure.web.domain.login.LoginUser;
|
||||
import com.agileboot.orm.common.enums.MenuTypeEnum;
|
||||
import com.agileboot.orm.system.entity.SysMenuEntity;
|
||||
import com.agileboot.orm.system.service.ISysMenuService;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@ -2,10 +2,12 @@ package com.agileboot.domain.system.menu.command;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdateMenuCommand extends AddMenuCommand {
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.agileboot.domain.system.menu.dto;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.agileboot.orm.common.enums.StatusEnum;
|
||||
import com.agileboot.orm.common.util.BasicEnumUtil;
|
||||
import com.agileboot.orm.system.entity.SysMenuEntity;
|
||||
|
||||
@ -5,7 +5,6 @@ import com.agileboot.orm.system.entity.SysMenuEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.agileboot.domain.system.menu.model;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.domain.system.menu.command.AddMenuCommand;
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
package com.agileboot.domain.system.menu.model;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.agileboot.common.constant.Constants;
|
||||
import com.agileboot.domain.system.menu.dto.MetaDTO;
|
||||
import com.agileboot.domain.system.menu.dto.RouterDTO;
|
||||
import com.agileboot.orm.common.enums.MenuComponentEnum;
|
||||
import com.agileboot.orm.common.enums.MenuTypeEnum;
|
||||
import com.agileboot.orm.system.entity.SysMenuEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
|
||||
@ -6,10 +6,12 @@ import com.agileboot.orm.system.entity.SysMenuEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import java.util.Arrays;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MenuQuery extends AbstractQuery<SysMenuEntity> {
|
||||
|
||||
|
||||
@ -3,10 +3,12 @@ package com.agileboot.domain.system.notice.command;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class NoticeUpdateCommand extends NoticeAddCommand {
|
||||
|
||||
|
||||
@ -8,11 +8,13 @@ import com.agileboot.orm.common.enums.StatusEnum;
|
||||
import com.agileboot.orm.common.util.BasicEnumUtil;
|
||||
import com.agileboot.orm.system.entity.SysNoticeEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class NoticeModel extends SysNoticeEntity {
|
||||
|
||||
@ -3,10 +3,12 @@ package com.agileboot.domain.system.post.command;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdatePostCommand extends AddPostCommand {
|
||||
|
||||
|
||||
@ -3,10 +3,12 @@ package com.agileboot.domain.system.role.command;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.PositiveOrZero;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdateRoleCommand extends AddRoleCommand {
|
||||
|
||||
|
||||
@ -17,11 +17,13 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class RoleModel extends SysRoleEntity {
|
||||
|
||||
@ -5,10 +5,12 @@ import com.agileboot.orm.common.query.AbstractPageQuery;
|
||||
import com.agileboot.orm.system.entity.SysUserEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AllocatedRoleQuery extends AbstractPageQuery<SysUserEntity> {
|
||||
|
||||
|
||||
@ -5,10 +5,12 @@ import com.agileboot.orm.common.query.AbstractPageQuery;
|
||||
import com.agileboot.orm.system.entity.SysUserEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UnallocatedRoleQuery extends AbstractPageQuery<SysUserEntity> {
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ import com.agileboot.domain.system.user.dto.UserProfileDTO;
|
||||
import com.agileboot.domain.system.user.model.UserModel;
|
||||
import com.agileboot.domain.system.user.model.UserModelFactory;
|
||||
import com.agileboot.domain.system.user.query.SearchUserQuery;
|
||||
import com.agileboot.infrastructure.cache.map.MapCache;
|
||||
import com.agileboot.infrastructure.web.domain.login.LoginUser;
|
||||
import com.agileboot.orm.system.entity.SysPostEntity;
|
||||
import com.agileboot.orm.system.entity.SysRoleEntity;
|
||||
@ -75,7 +74,8 @@ public class UserApplicationService {
|
||||
|
||||
/**
|
||||
* 获取当前登录用户信息
|
||||
* @return
|
||||
*
|
||||
* @return 当前登录用户信息
|
||||
*/
|
||||
public CurrentLoginUserDTO getLoginUserInfo(LoginUser loginUser) {
|
||||
CurrentLoginUserDTO permissionDTO = new CurrentLoginUserDTO();
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.agileboot.domain.system.user.command;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdateUserCommand extends AddUserCommand {
|
||||
|
||||
|
||||
@ -19,11 +19,13 @@ import com.agileboot.orm.system.entity.SysUserEntity;
|
||||
import com.agileboot.orm.system.service.ISysUserService;
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class UserModel extends SysUserEntity {
|
||||
|
||||
@ -4,11 +4,13 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.orm.common.query.AbstractPageQuery;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 当出现复用Query的情况,我们需要把泛型加到类本身,通过传入类型 来进行复用
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SearchUserQuery<T> extends AbstractPageQuery<T> {
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ class DeptModelTest {
|
||||
void testCheckHasChildDept() {
|
||||
DeptModel deptModel = deptModelFactory.create();
|
||||
deptModel.setDeptId(DEPT_ID);
|
||||
when(deptService.hasChildrenDept(eq(DEPT_ID), eq(null))).thenReturn(true);
|
||||
when(deptService.hasChildrenDept((DEPT_ID), eq(null))).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, deptModel::checkHasChildDept);
|
||||
|
||||
@ -64,7 +64,7 @@ class DeptModelTest {
|
||||
void testCheckDeptAssignedToUsers() {
|
||||
DeptModel deptModel = deptModelFactory.create();
|
||||
deptModel.setDeptId(DEPT_ID);
|
||||
when(deptService.isDeptAssignedToUsers(eq(DEPT_ID))).thenReturn(true);
|
||||
when(deptService.isDeptAssignedToUsers(DEPT_ID)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class,
|
||||
deptModel::checkDeptAssignedToUsers);
|
||||
@ -86,7 +86,7 @@ class DeptModelTest {
|
||||
void testGenerateAncestorsWhenParentDeptNotExist() {
|
||||
DeptModel deptModel = deptModelFactory.create();
|
||||
deptModel.setParentId(PARENT_ID);
|
||||
when(deptService.getById(eq(PARENT_ID))).thenReturn(null);
|
||||
when(deptService.getById(PARENT_ID)).thenReturn(null);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, deptModel::generateAncestors);
|
||||
|
||||
@ -100,7 +100,7 @@ class DeptModelTest {
|
||||
SysDeptEntity parentDept = new SysDeptEntity();
|
||||
parentDept.setStatus(0);
|
||||
|
||||
when(deptService.getById(eq(PARENT_ID))).thenReturn(parentDept);
|
||||
when(deptService.getById(PARENT_ID)).thenReturn(parentDept);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, deptModel::generateAncestors);
|
||||
Assertions.assertEquals(Business.DEPT_PARENT_DEPT_NO_EXIST_OR_DISABLED, exception.getErrorCode());
|
||||
@ -114,7 +114,7 @@ class DeptModelTest {
|
||||
SysDeptEntity parentDept = new SysDeptEntity();
|
||||
parentDept.setStatus(1);
|
||||
parentDept.setAncestors("1,100");
|
||||
when(deptService.getById(eq(PARENT_ID))).thenReturn(parentDept);
|
||||
when(deptService.getById(PARENT_ID)).thenReturn(parentDept);
|
||||
deptModel.generateAncestors();
|
||||
|
||||
Assertions.assertEquals("1,100,2", deptModel.getAncestors());
|
||||
@ -126,7 +126,7 @@ class DeptModelTest {
|
||||
DeptModel deptModel = deptModelFactory.create();
|
||||
deptModel.setDeptId(DEPT_ID);
|
||||
deptModel.setStatus(0);
|
||||
when(deptService.hasChildrenDept(eq(DEPT_ID), eq(true))).thenReturn(true);
|
||||
when(deptService.hasChildrenDept(DEPT_ID, true)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, deptModel::checkStatusAllowChange);
|
||||
|
||||
@ -139,7 +139,7 @@ class DeptModelTest {
|
||||
DeptModel deptModel = deptModelFactory.create();
|
||||
deptModel.setDeptId(DEPT_ID);
|
||||
deptModel.setStatus(0);
|
||||
when(deptService.hasChildrenDept(eq(DEPT_ID), eq(true))).thenReturn(false);
|
||||
when(deptService.hasChildrenDept(DEPT_ID, true)).thenReturn(false);
|
||||
|
||||
Assertions.assertDoesNotThrow(deptModel::checkStatusAllowChange);
|
||||
}
|
||||
@ -150,8 +150,7 @@ class DeptModelTest {
|
||||
DeptModel deptModel = deptModelFactory.create();
|
||||
deptModel.setDeptId(DEPT_ID);
|
||||
deptModel.setStatus(1);
|
||||
when(deptService.hasChildrenDept(eq(DEPT_ID), eq(true))).thenReturn(true);
|
||||
|
||||
when(deptService.hasChildrenDept(DEPT_ID, true)).thenReturn(true);
|
||||
Assertions.assertDoesNotThrow(deptModel::checkStatusAllowChange);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.agileboot.domain.system.menu.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -76,7 +75,7 @@ class MenuModelTest {
|
||||
void testCheckHasChildMenus() {
|
||||
MenuModel menuModel = menuModelFactory.create();
|
||||
menuModel.setMenuId(MENU_ID);
|
||||
when(menuService.hasChildrenMenu(eq(MENU_ID))).thenReturn(true);
|
||||
when(menuService.hasChildrenMenu(MENU_ID)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, menuModel::checkHasChildMenus);
|
||||
|
||||
@ -88,7 +87,7 @@ class MenuModelTest {
|
||||
void testCheckMenuAlreadyAssignToRole() {
|
||||
MenuModel menuModel = menuModelFactory.create();
|
||||
menuModel.setMenuId(MENU_ID);
|
||||
when(menuService.isMenuAssignToRoles(eq(MENU_ID))).thenReturn(true);
|
||||
when(menuService.isMenuAssignToRoles(MENU_ID)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, menuModel::checkMenuAlreadyAssignToRole);
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class PostModelTest {
|
||||
PostModel postModel = postModelFactory.create();
|
||||
postModel.setPostId(POST_ID);
|
||||
|
||||
when(postService.isAssignedToUsers(eq(POST_ID))).thenReturn(true);
|
||||
when(postService.isAssignedToUsers(POST_ID)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, postModel::checkCanBeDelete);
|
||||
Assertions.assertEquals(Business.POST_ALREADY_ASSIGNED_TO_USER_CAN_NOT_BE_DELETED, exception.getErrorCode());
|
||||
@ -42,7 +42,7 @@ class PostModelTest {
|
||||
PostModel postModel = postModelFactory.create();
|
||||
postModel.setPostId(POST_ID);
|
||||
|
||||
when(postService.isAssignedToUsers(eq(POST_ID))).thenReturn(true);
|
||||
when(postService.isAssignedToUsers(POST_ID)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, postModel::checkCanBeDelete);
|
||||
Assertions.assertEquals(Business.POST_ALREADY_ASSIGNED_TO_USER_CAN_NOT_BE_DELETED, exception.getErrorCode());
|
||||
@ -58,8 +58,8 @@ class PostModelTest {
|
||||
postWithNewName.setPostName("post 2");
|
||||
postWithNewName.setPostId(POST_ID);
|
||||
|
||||
when(postService.isPostNameDuplicated(eq(POST_ID), eq("post 1"))).thenReturn(true);
|
||||
when(postService.isPostNameDuplicated(eq(POST_ID), eq("post 2"))).thenReturn(false);
|
||||
when(postService.isPostNameDuplicated(POST_ID, eq("post 1"))).thenReturn(true);
|
||||
when(postService.isPostNameDuplicated(POST_ID, eq("post 2"))).thenReturn(false);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, postWithSameName::checkPostNameUnique);
|
||||
Assertions.assertEquals(Business.POST_NAME_IS_NOT_UNIQUE, exception.getErrorCode());
|
||||
@ -75,8 +75,8 @@ class PostModelTest {
|
||||
postWithNewCode.setPostId(POST_ID);
|
||||
postWithNewCode.setPostCode("code 2");
|
||||
|
||||
when(postService.isPostCodeDuplicated(eq(POST_ID), eq("code 1"))).thenReturn(true);
|
||||
when(postService.isPostCodeDuplicated(eq(POST_ID), eq("code 2"))).thenReturn(false);
|
||||
when(postService.isPostCodeDuplicated(POST_ID, "code 1")).thenReturn(true);
|
||||
when(postService.isPostCodeDuplicated(POST_ID, "code 2")).thenReturn(false);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, postWithSameCode::checkPostCodeUnique);
|
||||
Assertions.assertEquals(Business.POST_CODE_IS_NOT_UNIQUE, exception.getErrorCode());
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.agileboot.domain.system.role.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -33,8 +32,8 @@ class RoleModelTest {
|
||||
roleWithNewName.setRoleId(ROLE_ID);
|
||||
roleWithNewName.setRoleName("role 2");
|
||||
|
||||
when(roleService.isRoleNameDuplicated(eq(ROLE_ID), eq("role 1"))).thenReturn(true);
|
||||
when(roleService.isRoleNameDuplicated(eq(ROLE_ID), eq("role 2"))).thenReturn(false);
|
||||
when(roleService.isRoleNameDuplicated(ROLE_ID, "role 1")).thenReturn(true);
|
||||
when(roleService.isRoleNameDuplicated(ROLE_ID, "role 2")).thenReturn(false);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, roleWithSameName::checkRoleNameUnique);
|
||||
Assertions.assertEquals(Business.ROLE_NAME_IS_NOT_UNIQUE, exception.getErrorCode());
|
||||
@ -47,7 +46,7 @@ class RoleModelTest {
|
||||
RoleModel roleModel = roleModelFactory.create();
|
||||
roleModel.setRoleId(ROLE_ID);
|
||||
|
||||
when(roleService.isAssignedToUsers(eq(ROLE_ID))).thenReturn(true);
|
||||
when(roleService.isAssignedToUsers(ROLE_ID)).thenReturn(true);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, roleModel::checkRoleCanBeDelete);
|
||||
Assertions.assertEquals(Business.ROLE_ALREADY_ASSIGN_TO_USER, exception.getErrorCode());
|
||||
@ -62,8 +61,8 @@ class RoleModelTest {
|
||||
roleWithNewKey.setRoleId(ROLE_ID);
|
||||
roleWithNewKey.setRoleKey("key 2");
|
||||
|
||||
when(roleService.isRoleKeyDuplicated(eq(ROLE_ID), eq("key 1"))).thenReturn(true);
|
||||
when(roleService.isRoleKeyDuplicated(eq(ROLE_ID), eq("key 2"))).thenReturn(false);
|
||||
when(roleService.isRoleKeyDuplicated(ROLE_ID, "key 1")).thenReturn(true);
|
||||
when(roleService.isRoleKeyDuplicated(ROLE_ID, "key 2")).thenReturn(false);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, roleWithSameKey::checkRoleKeyUnique);
|
||||
Assertions.assertEquals(Business.ROLE_KEY_IS_NOT_UNIQUE, exception.getErrorCode());
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.agileboot.domain.system.user.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -39,8 +38,8 @@ class UserModelTest {
|
||||
userWithNewName.setUserId(USER_ID);
|
||||
userWithNewName.setUsername("user 2");
|
||||
|
||||
when(userService.isUserNameDuplicated(eq("user 1"))).thenReturn(true);
|
||||
when(userService.isUserNameDuplicated(eq("user 2"))).thenReturn(false);
|
||||
when(userService.isUserNameDuplicated("user 1")).thenReturn(true);
|
||||
when(userService.isUserNameDuplicated("user 2")).thenReturn(false);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, userWithSameName::checkUsernameIsUnique);
|
||||
Assertions.assertEquals(Business.USER_NAME_IS_NOT_UNIQUE, exception.getErrorCode());
|
||||
@ -73,8 +72,8 @@ class UserModelTest {
|
||||
userWithNewNumber.setUserId(USER_ID);
|
||||
userWithNewNumber.setEmail("2@2.com");
|
||||
|
||||
when(userService.isEmailDuplicated(eq("1@1.com"), eq(USER_ID))).thenReturn(true);
|
||||
when(userService.isEmailDuplicated(eq("2@2.com"), eq(USER_ID))).thenReturn(false);
|
||||
when(userService.isEmailDuplicated("1@1.com", USER_ID)).thenReturn(true);
|
||||
when(userService.isEmailDuplicated("2@2.com", USER_ID)).thenReturn(false);
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, userWithSameEmail::checkEmailIsUnique);
|
||||
Assertions.assertEquals(Business.USER_EMAIL_IS_NOT_UNIQUE, exception.getErrorCode());
|
||||
|
||||
@ -25,9 +25,9 @@ public class DbExceptionAspect {
|
||||
|
||||
/**
|
||||
* 包装成ApiException 再交给globalExceptionHandler处理
|
||||
* @param joinPoint
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*
|
||||
* @param joinPoint joinPoint
|
||||
* @return object
|
||||
*/
|
||||
@Around("dbException()")
|
||||
public Object aroundDbException(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
|
||||
@ -97,8 +97,9 @@ public abstract class AbstractGuavaCacheTemplate<T> {
|
||||
|
||||
/**
|
||||
* 从数据库加载数据
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param id id
|
||||
* @return T
|
||||
*/
|
||||
public abstract T getObjectFromDb(Object id);
|
||||
|
||||
|
||||
@ -47,8 +47,8 @@ public class RedisCacheTemplate<T> {
|
||||
|
||||
/**
|
||||
* 从缓存中获取对象 如果获取不到的话 从DB层面获取
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
public T getObjectById(Object id) {
|
||||
String cachedKey = generateKey(id);
|
||||
@ -71,8 +71,7 @@ public class RedisCacheTemplate<T> {
|
||||
|
||||
/**
|
||||
* 从缓存中获取 对象, 即使找不到的话 也不从DB中找
|
||||
* @param id
|
||||
* @return
|
||||
* @param id id
|
||||
*/
|
||||
public T getObjectOnlyInCacheById(Object id) {
|
||||
String cachedKey = generateKey(id);
|
||||
@ -89,7 +88,6 @@ public class RedisCacheTemplate<T> {
|
||||
/**
|
||||
* 从缓存中获取 对象, 即使找不到的话 也不从DB中找
|
||||
* @param cachedKey 直接通过redis的key来搜索
|
||||
* @return
|
||||
*/
|
||||
public T getObjectOnlyInCacheByKey(String cachedKey) {
|
||||
try {
|
||||
|
||||
@ -25,8 +25,8 @@ import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
public class GlobalTransactionConfig {
|
||||
|
||||
/**
|
||||
* 配置全局事务的切点为service层的所有方法
|
||||
* AOP切面表达式 可参考(https://blog.csdn.net/ycf921244819/article/details/106599489)
|
||||
* 配置全局事务的切点为service层的所有方法 AOP切面表达式 可参考(<a
|
||||
* href="https://blog.csdn.net/ycf921244819/article/details/106599489">https://blog.csdn.net/ycf921244819/article/details/106599489</a>)
|
||||
* 本项目设置在 applicationService层
|
||||
*/
|
||||
private static final String POINTCUT_EXPRESSION = "execution(public * com.agileboot.domain..*.*ApplicationService.*(..))";
|
||||
@ -40,7 +40,8 @@ public class GlobalTransactionConfig {
|
||||
|
||||
/**
|
||||
* 配置事务拦截器
|
||||
* @return
|
||||
*
|
||||
* @return TransactionInterceptor
|
||||
*/
|
||||
@Bean
|
||||
public TransactionInterceptor txAdvice() {
|
||||
@ -92,7 +93,7 @@ public class GlobalTransactionConfig {
|
||||
|
||||
/**
|
||||
* 设置切面
|
||||
* @return
|
||||
* @return Advisor
|
||||
*/
|
||||
@Bean
|
||||
public Advisor txAdviceAdvisor() {
|
||||
|
||||
@ -49,7 +49,6 @@ public class CodeGenerator {
|
||||
/**
|
||||
* 避免覆盖掉原有生成的类 生成的类 放在orm子模块下的/target/generated-code目录底下
|
||||
* 有需要更新的实体自己在手动覆盖 或者 挪动过去
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// 默认读取application-dev yml中的master数据库配置
|
||||
|
||||
@ -48,7 +48,7 @@ public class ScheduleJobManager {
|
||||
|
||||
/**
|
||||
* cron:使用Cron表达式。 每分钟的1,2秒运行
|
||||
* https://cron.qqe2.com/
|
||||
* <a href="https://cron.qqe2.com/">https://cron.qqe2.com/</a>
|
||||
* cron表达式 在线解析
|
||||
*/
|
||||
@Scheduled(cron = "1-2 * * * * ? ")
|
||||
|
||||
@ -15,9 +15,10 @@ public abstract class AbstractDataPermissionChecker {
|
||||
|
||||
/**
|
||||
* 检测当前用户对于 给定条件的数据 是否有权限
|
||||
* @param loginUser
|
||||
* @param condition
|
||||
* @return
|
||||
*
|
||||
* @param loginUser 登录用户
|
||||
* @param condition 条件
|
||||
* @return 校验结果
|
||||
*/
|
||||
public abstract boolean check(LoginUser loginUser, DataCondition condition);
|
||||
|
||||
|
||||
@ -5,11 +5,13 @@ import com.agileboot.infrastructure.web.domain.permission.AbstractDataPermission
|
||||
import com.agileboot.infrastructure.web.domain.permission.DataCondition;
|
||||
import com.agileboot.orm.system.service.ISysDeptService;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AllDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
|
||||
@ -8,12 +8,14 @@ import com.agileboot.orm.system.service.ISysDeptService;
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -5,11 +5,13 @@ import com.agileboot.infrastructure.web.domain.permission.AbstractDataPermission
|
||||
import com.agileboot.infrastructure.web.domain.permission.DataCondition;
|
||||
import com.agileboot.orm.system.service.ISysDeptService;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DefaultDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
|
||||
@ -7,12 +7,14 @@ import com.agileboot.orm.system.service.ISysDeptService;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -7,12 +7,14 @@ import com.agileboot.orm.system.service.ISysDeptService;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -7,12 +7,14 @@ import com.agileboot.orm.system.service.ISysDeptService;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -9,7 +9,8 @@ public abstract class AbstractRateLimitChecker {
|
||||
|
||||
/**
|
||||
* 检查是否超出限流
|
||||
* @param rateLimiter
|
||||
*
|
||||
* @param rateLimiter RateLimit
|
||||
*/
|
||||
public abstract void check(RateLimit rateLimiter);
|
||||
|
||||
|
||||
@ -26,7 +26,8 @@ public class DataPermissionService {
|
||||
|
||||
/**
|
||||
* 通过userId 校验当前用户 对 目标用户是否有操作权限
|
||||
* @param userId
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 检验结果
|
||||
*/
|
||||
public boolean checkUserId(Long userId) {
|
||||
@ -40,8 +41,8 @@ public class DataPermissionService {
|
||||
|
||||
/**
|
||||
* 通过userId 校验当前用户 对 目标用户是否有操作权限
|
||||
* @param userIds
|
||||
* @return
|
||||
* @param userIds 用户id列表
|
||||
* @return 校验结果
|
||||
*/
|
||||
public boolean checkUserIds(List<Long> userIds) {
|
||||
if (CollUtil.isNotEmpty(userIds)) {
|
||||
|
||||
@ -28,12 +28,9 @@ import com.agileboot.infrastructure.web.domain.login.LoginDTO;
|
||||
import com.agileboot.infrastructure.web.domain.login.LoginUser;
|
||||
import com.agileboot.orm.common.enums.ConfigKeyEnum;
|
||||
import com.agileboot.orm.common.enums.LoginStatusEnum;
|
||||
import com.agileboot.orm.common.result.DictionaryData;
|
||||
import com.agileboot.orm.system.entity.SysUserEntity;
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -115,7 +112,8 @@ public class LoginService {
|
||||
|
||||
/**
|
||||
* 获取验证码 data
|
||||
* @return
|
||||
*
|
||||
* @return {@link ConfigDTO}
|
||||
*/
|
||||
public ConfigDTO getConfig() {
|
||||
ConfigDTO configDTO = new ConfigDTO();
|
||||
@ -128,7 +126,8 @@ public class LoginService {
|
||||
|
||||
/**
|
||||
* 获取验证码 data
|
||||
* @return
|
||||
*
|
||||
* @return 验证码
|
||||
*/
|
||||
public CaptchaDTO generateCaptchaImg() {
|
||||
CaptchaDTO captchaDTO = new CaptchaDTO();
|
||||
@ -137,7 +136,8 @@ public class LoginService {
|
||||
captchaDTO.setIsCaptchaOn(isCaptchaOn);
|
||||
|
||||
if (isCaptchaOn) {
|
||||
String expression, answer = null;
|
||||
String expression;
|
||||
String answer = null;
|
||||
BufferedImage image = null;
|
||||
|
||||
// 生成验证码
|
||||
@ -200,7 +200,7 @@ public class LoginService {
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
* @param loginUser
|
||||
* @param loginUser 登录用户
|
||||
*/
|
||||
public void recordLoginInfo(LoginUser loginUser) {
|
||||
ThreadPoolManager.execute(AsyncTaskFactory.loginInfoTask(loginUser.getUsername(), LoginStatusEnum.LOGIN_SUCCESS,
|
||||
|
||||
@ -5,9 +5,8 @@ import com.agileboot.common.utils.time.DatePickUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 如果是简单的排序 和 时间范围筛选 可以使用内置的这几个字段
|
||||
@ -78,7 +77,8 @@ public abstract class AbstractQuery<T> {
|
||||
|
||||
if (ASC.equals(this.orderDirection)) {
|
||||
isAsc = true;
|
||||
}if (DESC.equals(this.orderDirection)) {
|
||||
}
|
||||
if (DESC.equals(this.orderDirection)) {
|
||||
isAsc = false;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user