opt
This commit is contained in:
parent
08bfb9cfff
commit
a89cca5909
@ -45,6 +45,8 @@ public interface UserAppService {
|
|||||||
|
|
||||||
// 角色授权信息
|
// 角色授权信息
|
||||||
List<RoleFileRuleDTO> listRoleFileRules(Long roleId);
|
List<RoleFileRuleDTO> listRoleFileRules(Long roleId);
|
||||||
|
|
||||||
|
List<RoleFileRuleDTO> listAllRules();
|
||||||
boolean addRoleFileRule(RoleFileRuleDTO rule);
|
boolean addRoleFileRule(RoleFileRuleDTO rule);
|
||||||
boolean removeRoleFileRule(Long id);
|
boolean removeRoleFileRule(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,6 +146,13 @@ public class UserAppServiceImpl implements UserAppService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RoleFileRuleDTO> listAllRules() {
|
||||||
|
return Optional.ofNullable(userDomainService.listAllRules()).orElse(Lists.newArrayList()).stream()
|
||||||
|
.map(e -> RoleFileRuleDtoConverter.toDTO(e))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addRoleFileRule(RoleFileRuleDTO rule) {
|
public boolean addRoleFileRule(RoleFileRuleDTO rule) {
|
||||||
return userDomainService.addRoleFileRule(RoleFileRuleDtoConverter.toDO(rule));
|
return userDomainService.addRoleFileRule(RoleFileRuleDtoConverter.toDO(rule));
|
||||||
|
|||||||
@ -1,11 +1,20 @@
|
|||||||
package com.knowledge.base.domain.user.model;
|
package com.knowledge.base.domain.user.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luke.ye
|
* @author Luke.ye
|
||||||
* @date 2025/6/9 10:37
|
* @date 2025/6/9 10:37
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class RoleDO {
|
public class RoleDO {
|
||||||
public Long id;
|
private Long id;
|
||||||
public String roleCode;
|
private String roleCode;
|
||||||
public String roleName;
|
private String roleName;
|
||||||
|
|
||||||
|
private LocalDateTime addTime;
|
||||||
|
|
||||||
|
private LocalDateTime updateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,18 @@ package com.knowledge.base.domain.user.model;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luke.ye
|
* @author Luke.ye
|
||||||
* @date 2025/6/9 10:39
|
* @date 2025/6/9 10:39
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RoleFileRuleDO {
|
public class RoleFileRuleDO {
|
||||||
public Long id;
|
private Long id;
|
||||||
public Long roleId;
|
private Long roleId;
|
||||||
public String filePattern;
|
private String filePattern;
|
||||||
public String remark;
|
private String remark;
|
||||||
|
private LocalDateTime addTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,4 +9,6 @@ public interface RoleFileRuleDomainSupport {
|
|||||||
List<RoleFileRuleDO> findByRoleId(Long roleId);
|
List<RoleFileRuleDO> findByRoleId(Long roleId);
|
||||||
boolean addRoleFileRule(RoleFileRuleDO rule);
|
boolean addRoleFileRule(RoleFileRuleDO rule);
|
||||||
boolean removeRoleFileRule(Long ruleId);
|
boolean removeRoleFileRule(Long ruleId);
|
||||||
|
|
||||||
|
List<RoleFileRuleDO> listAllRules();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,8 @@ public interface UserDomainService {
|
|||||||
|
|
||||||
// 角色-文件规则
|
// 角色-文件规则
|
||||||
List<RoleFileRuleDO> findRoleFileRules(Long roleId);
|
List<RoleFileRuleDO> findRoleFileRules(Long roleId);
|
||||||
|
|
||||||
|
List<RoleFileRuleDO> listAllRules();
|
||||||
boolean addRoleFileRule(RoleFileRuleDO rule);
|
boolean addRoleFileRule(RoleFileRuleDO rule);
|
||||||
boolean removeRoleFileRule(Long ruleId);
|
boolean removeRoleFileRule(Long ruleId);
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,8 @@ public class RoleFileRuleDomainSupportImpl implements RoleFileRuleDomainSupport
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addRoleFileRule(RoleFileRuleDO rule) {
|
public boolean addRoleFileRule(RoleFileRuleDO rule) {
|
||||||
return roleFileRuleRepository.save(RoleFileRuleDomainConverter.toPO(rule));
|
return roleFileRuleRepository.save(RoleFileRuleDomainConverter.toPO(rule));
|
||||||
@ -34,4 +36,11 @@ public class RoleFileRuleDomainSupportImpl implements RoleFileRuleDomainSupport
|
|||||||
public boolean removeRoleFileRule(Long ruleId) {
|
public boolean removeRoleFileRule(Long ruleId) {
|
||||||
return roleFileRuleRepository.deleteById(ruleId);
|
return roleFileRuleRepository.deleteById(ruleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RoleFileRuleDO> listAllRules() {
|
||||||
|
return Optional.ofNullable(roleFileRuleRepository.findAll()).orElse(Lists.newArrayList()).stream()
|
||||||
|
.map(e -> RoleFileRuleDomainConverter.toDO(e))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,12 @@ public class UserDomainServiceImpl implements UserDomainService {
|
|||||||
public List<RoleFileRuleDO> findRoleFileRules(Long roleId) {
|
public List<RoleFileRuleDO> findRoleFileRules(Long roleId) {
|
||||||
return roleFileRuleDomainSupport.findByRoleId(roleId);
|
return roleFileRuleDomainSupport.findByRoleId(roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RoleFileRuleDO> listAllRules() {
|
||||||
|
return roleFileRuleDomainSupport.listAllRules();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addRoleFileRule(RoleFileRuleDO rule) {
|
public boolean addRoleFileRule(RoleFileRuleDO rule) {
|
||||||
return roleFileRuleDomainSupport.addRoleFileRule(rule);
|
return roleFileRuleDomainSupport.addRoleFileRule(rule);
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.knowledge.base.infrastructure.config;
|
package com.knowledge.base.infrastructure.config;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luke.ye
|
* @author Luke.ye
|
||||||
* @date 2025/5/19 11:18
|
* @date 2025/5/19 11:18
|
||||||
@ -10,4 +12,7 @@ public class ConstantConfig {
|
|||||||
* cookie对应的key
|
* cookie对应的key
|
||||||
*/
|
*/
|
||||||
public static final String COOKIE_KEY = "auth_token";
|
public static final String COOKIE_KEY = "auth_token";
|
||||||
|
|
||||||
|
public static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
package com.knowledge.base.infrastructure.converter;
|
package com.knowledge.base.infrastructure.converter;
|
||||||
|
|
||||||
import com.knowledge.base.domain.user.model.RoleDO;
|
import com.knowledge.base.domain.user.model.RoleDO;
|
||||||
|
import com.knowledge.base.infrastructure.config.ConstantConfig;
|
||||||
import com.knowledge.base.infrastructure.north.dto.role.RoleDTO;
|
import com.knowledge.base.infrastructure.north.dto.role.RoleDTO;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
|
||||||
public class RoleDtoConverter {
|
public class RoleDtoConverter {
|
||||||
public static RoleDO toDO(RoleDTO dto) {
|
public static RoleDO toDO(RoleDTO dto) {
|
||||||
if (dto == null) return null;
|
if (dto == null) return null;
|
||||||
@ -15,6 +18,8 @@ public class RoleDtoConverter {
|
|||||||
if (doObj == null) return null;
|
if (doObj == null) return null;
|
||||||
RoleDTO dto = new RoleDTO();
|
RoleDTO dto = new RoleDTO();
|
||||||
BeanUtils.copyProperties(doObj, dto);
|
BeanUtils.copyProperties(doObj, dto);
|
||||||
|
dto.setAddTime(doObj.getAddTime() == null ? null : doObj.getAddTime().atZone(ZoneId.of("Asia/Shanghai")).format(ConstantConfig.DTF));
|
||||||
|
dto.setUpdateTime(doObj.getUpdateTime() == null ? null : doObj.getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).format(ConstantConfig.DTF));
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
package com.knowledge.base.infrastructure.converter;
|
package com.knowledge.base.infrastructure.converter;
|
||||||
|
|
||||||
import com.knowledge.base.domain.user.model.RoleFileRuleDO;
|
import com.knowledge.base.domain.user.model.RoleFileRuleDO;
|
||||||
|
import com.knowledge.base.infrastructure.config.ConstantConfig;
|
||||||
import com.knowledge.base.infrastructure.north.dto.role.RoleFileRuleDTO;
|
import com.knowledge.base.infrastructure.north.dto.role.RoleFileRuleDTO;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
|
||||||
public class RoleFileRuleDtoConverter {
|
public class RoleFileRuleDtoConverter {
|
||||||
public static RoleFileRuleDO toDO(RoleFileRuleDTO dto) {
|
public static RoleFileRuleDO toDO(RoleFileRuleDTO dto) {
|
||||||
if (dto == null) return null;
|
if (dto == null) return null;
|
||||||
@ -15,6 +18,8 @@ public class RoleFileRuleDtoConverter {
|
|||||||
if (doObj == null) return null;
|
if (doObj == null) return null;
|
||||||
RoleFileRuleDTO dto = new RoleFileRuleDTO();
|
RoleFileRuleDTO dto = new RoleFileRuleDTO();
|
||||||
BeanUtils.copyProperties(doObj, dto);
|
BeanUtils.copyProperties(doObj, dto);
|
||||||
|
dto.setAddTime(doObj.getAddTime() == null ? null : doObj.getAddTime().atZone(ZoneId.of("Asia/Shanghai")).format(ConstantConfig.DTF));
|
||||||
|
dto.setUpdateTime(doObj.getUpdateTime() == null ? null : doObj.getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).format(ConstantConfig.DTF));
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package com.knowledge.base.infrastructure.converter;
|
package com.knowledge.base.infrastructure.converter;
|
||||||
|
|
||||||
import com.knowledge.base.domain.user.model.UserDO;
|
import com.knowledge.base.domain.user.model.UserDO;
|
||||||
|
import com.knowledge.base.infrastructure.config.ConstantConfig;
|
||||||
import com.knowledge.base.infrastructure.north.dto.user.UserDTO;
|
import com.knowledge.base.infrastructure.north.dto.user.UserDTO;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,7 +13,6 @@ import java.time.format.DateTimeFormatter;
|
|||||||
* @date 2025/6/9 09:44
|
* @date 2025/6/9 09:44
|
||||||
*/
|
*/
|
||||||
public class UserDtoConverter {
|
public class UserDtoConverter {
|
||||||
private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
public static UserDO toDO(UserDTO dto) {
|
public static UserDO toDO(UserDTO dto) {
|
||||||
if (dto == null) return null;
|
if (dto == null) return null;
|
||||||
UserDO doObj = new UserDO();
|
UserDO doObj = new UserDO();
|
||||||
@ -24,7 +23,7 @@ public class UserDtoConverter {
|
|||||||
if (doObj == null) return null;
|
if (doObj == null) return null;
|
||||||
UserDTO dto = new UserDTO();
|
UserDTO dto = new UserDTO();
|
||||||
BeanUtils.copyProperties(doObj, dto);
|
BeanUtils.copyProperties(doObj, dto);
|
||||||
dto.setAddTime(doObj.getAddTime() == null ? null : doObj.getAddTime().atZone(ZoneId.of("Asia/Shanghai")).format(DTF));
|
dto.setAddTime(doObj.getAddTime() == null ? null : doObj.getAddTime().atZone(ZoneId.of("Asia/Shanghai")).format(ConstantConfig.DTF));
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,4 +34,9 @@ public class RoleQueryController {
|
|||||||
return ResponseEntity.ok(userAppService.listRoleFileRules(roleId));
|
return ResponseEntity.ok(userAppService.listRoleFileRules(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list-all-rules")
|
||||||
|
public ResponseEntity<?> listAllRules() {
|
||||||
|
return ResponseEntity.ok(userAppService.listAllRules());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,9 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RoleDTO {
|
public class RoleDTO {
|
||||||
public Long id;
|
private Long id;
|
||||||
public String roleCode;
|
private String roleCode;
|
||||||
public String roleName;
|
private String roleName;
|
||||||
|
private String addTime;
|
||||||
|
private String updateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,10 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RoleFileRuleDTO {
|
public class RoleFileRuleDTO {
|
||||||
public Long id;
|
private Long id;
|
||||||
public Long roleId;
|
private Long roleId;
|
||||||
public String filePattern;
|
private String filePattern;
|
||||||
public String remark;
|
private String remark;
|
||||||
|
private String addTime;
|
||||||
|
private String updateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user