mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 23:57:12 +08:00
添加权限类型
This commit is contained in:
@@ -8,7 +8,9 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreatePermissionDto extends CommonDto {
|
||||
private String permissionType;
|
||||
|
||||
private String permissionTypeName;
|
||||
private String parentName;
|
||||
private List<String> resources;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ public class PermissionDto extends OrgCommonDto {
|
||||
private String parentName;
|
||||
private List<ResourceDto> resources;
|
||||
|
||||
private String permissionType;
|
||||
|
||||
private String permissionTypeName;
|
||||
|
||||
@Data
|
||||
public static class ResourceDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ public class PermissionExportDto extends CommonDto {
|
||||
|
||||
private String parentName;
|
||||
private List<PermissionDto.ResourceDto> resources;
|
||||
private String permissionType;
|
||||
|
||||
private String permissionTypeName;
|
||||
|
||||
@Data
|
||||
public static class ResourceDto extends CommonDto {
|
||||
|
||||
@@ -8,7 +8,9 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdatePermissionDto extends CommonDto {
|
||||
private String permissionType;
|
||||
|
||||
private String permissionTypeName;
|
||||
private String parentName;
|
||||
private List<String> resources;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,6 +22,19 @@ import java.util.List;
|
||||
@Cacheable
|
||||
public class PermissionEntity extends CommonEntity {
|
||||
|
||||
@Comment("权限类型")
|
||||
private String permissionType;
|
||||
|
||||
@Formula(
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'permission.type'\n"
|
||||
+ " and i.code = item_type)")
|
||||
@Comment("权限类型-名称")
|
||||
private String permissionTypeName;
|
||||
|
||||
@ManyToMany()
|
||||
@JoinTable(
|
||||
foreignKey =
|
||||
|
||||
@@ -9,4 +9,6 @@ import org.springframework.stereotype.Repository;
|
||||
public interface UserRepository extends BaseRepository<UserEntity> {
|
||||
|
||||
UserEntity findByUsername(String username);
|
||||
|
||||
int countByUsername(String username);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public class UserService extends BaseService<UserEntity, UserRepository> {
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
checkDuplicateUserName(request.getUsername());
|
||||
try {
|
||||
stopWatch.start("encode");
|
||||
request.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||
@@ -83,10 +84,17 @@ public class UserService extends BaseService<UserEntity, UserRepository> {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDuplicateUserName(String username) {
|
||||
|
||||
if (this.repository.countByUsername(username) > 0) {
|
||||
throw new BizException("用户名以及存在");
|
||||
}
|
||||
}
|
||||
|
||||
public UserDto createOrgAdmin(CreateOrgAdminDto request) {
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
checkDuplicateUserName(request.getUsername());
|
||||
try {
|
||||
stopWatch.start("encode");
|
||||
request.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
[
|
||||
{
|
||||
"code": "permission.type",
|
||||
"name": "权限类型",
|
||||
"item": [
|
||||
{
|
||||
"code": "0",
|
||||
"name": "匿名"
|
||||
},
|
||||
{
|
||||
"code": "1",
|
||||
"name": "公共"
|
||||
},
|
||||
{
|
||||
"code": "2",
|
||||
"name": "机构"
|
||||
},
|
||||
{
|
||||
"code": "3",
|
||||
"name": "平台"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "status.type",
|
||||
"name": "通用状态类型",
|
||||
|
||||
Reference in New Issue
Block a user