-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($auth-center): provide remote service for
api-portal
: get perm…
…ission list by role id list
- Loading branch information
1 parent
e0cc398
commit 8aca3d0
Showing
13 changed files
with
588 additions
and
62 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...r/src/main/java/com/jmsoftware/authcenter/permission/controller/PermissionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.jmsoftware.authcenter.permission.controller; | ||
|
||
import com.jmsoftware.authcenter.permission.entity.PermissionPersistence; | ||
import com.jmsoftware.authcenter.permission.service.PermissionService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.annotation.Resource; | ||
|
||
/** | ||
* <h1>PermissionController</h1> | ||
* <p> | ||
* Controller implementation of Permission.(Permission) | ||
* | ||
* @author Johnny Miller (鍾俊), e-mail: johnnysviva@outlook.com | ||
* @date 5/11/20 8:34 AM | ||
*/ | ||
@RestController | ||
@RequestMapping("permission") | ||
public class PermissionController { | ||
@Resource | ||
private PermissionService permissionService; | ||
|
||
@GetMapping("selectOne") | ||
public PermissionPersistence selectOne(Long id) { | ||
return this.permissionService.queryById(id); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...nter/src/main/java/com/jmsoftware/authcenter/permission/entity/PermissionPersistence.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.jmsoftware.authcenter.permission.entity; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
/** | ||
* Permission.(Permission) Persistence object class | ||
* | ||
* @author Johnny Miller (鍾俊), e-mail: johnnysviva@outlook.com | ||
* @date 5/11/20 8:34 AM | ||
*/ | ||
@Data | ||
public class PermissionPersistence implements Serializable { | ||
private static final long serialVersionUID = -56601096713236790L; | ||
/** | ||
* Primary key | ||
*/ | ||
private Long id; | ||
/** | ||
* URL. If type of record is page (1), URL stands for route; if type of record is button (2), URL stands for API | ||
*/ | ||
private String url; | ||
/** | ||
* Permission description | ||
*/ | ||
private String description; | ||
/** | ||
* Permission type. 1 - page; 2 - button | ||
*/ | ||
private Integer type; | ||
/** | ||
* Permission expression | ||
*/ | ||
private String permissionExpression; | ||
/** | ||
* HTTP method of API | ||
*/ | ||
private String method; | ||
/** | ||
* Sort number | ||
*/ | ||
private Integer sort; | ||
/** | ||
* Primary key of parent | ||
*/ | ||
private Long parentId; | ||
/** | ||
* Deleted flag | ||
*/ | ||
private Integer deleted; | ||
/** | ||
* Created time | ||
*/ | ||
private Date createdTime; | ||
/** | ||
* Modified time | ||
*/ | ||
private Date modifiedTime; | ||
} |
75 changes: 75 additions & 0 deletions
75
auth-center/src/main/java/com/jmsoftware/authcenter/permission/mapper/PermissionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.jmsoftware.authcenter.permission.mapper; | ||
|
||
import com.jmsoftware.authcenter.permission.entity.PermissionPersistence; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* <h1>PermissionMapper</h1> | ||
* <p> | ||
* Mapper of Permission.(Permission) | ||
* | ||
* @author Johnny Miller (鍾俊), e-mail: johnnysviva@outlook.com | ||
* @date 5 /11/20 8:34 AM | ||
*/ | ||
@Mapper | ||
public interface PermissionMapper { | ||
/** | ||
* Query by id permission persistence. | ||
* | ||
* @param id the id | ||
* @return the permission persistence | ||
*/ | ||
PermissionPersistence queryById(Long id); | ||
|
||
/** | ||
* Query all by limit list. | ||
* | ||
* @param offset the offset | ||
* @param limit the limit | ||
* @return the list | ||
*/ | ||
List<PermissionPersistence> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit); | ||
|
||
/** | ||
* Query all list. | ||
* | ||
* @param permissionPersistence the permission persistence | ||
* @return the list | ||
*/ | ||
List<PermissionPersistence> queryAll(PermissionPersistence permissionPersistence); | ||
|
||
/** | ||
* Insert int. | ||
* | ||
* @param permissionPersistence the permission persistence | ||
* @return the int | ||
*/ | ||
int insert(PermissionPersistence permissionPersistence); | ||
|
||
/** | ||
* Update int. | ||
* | ||
* @param permissionPersistence the permission persistence | ||
* @return the int | ||
*/ | ||
int update(PermissionPersistence permissionPersistence); | ||
|
||
/** | ||
* Delete by id int. | ||
* | ||
* @param id the id | ||
* @return the int | ||
*/ | ||
int deleteById(Long id); | ||
|
||
/** | ||
* Select permission list by role id list list. | ||
* | ||
* @param roleIdList the role id list | ||
* @return the list | ||
*/ | ||
List<PermissionPersistence> selectPermissionListByRoleIdList(List<Long> roleIdList); | ||
} |
35 changes: 35 additions & 0 deletions
35
.../main/java/com/jmsoftware/authcenter/permission/remote/PermissionRemoteApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.jmsoftware.authcenter.permission.remote; | ||
|
||
import com.jmsoftware.authcenter.permission.service.PermissionService; | ||
import com.jmsoftware.common.bean.ResponseBodyBean; | ||
import com.jmsoftware.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload; | ||
import com.jmsoftware.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse; | ||
import io.swagger.annotations.Api; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.validation.Valid; | ||
|
||
/** | ||
* <h1>PermissionRemoteApiController</h1> | ||
* <p> | ||
* Change description here. | ||
* | ||
* @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com | ||
* @date 5/11/20 8:24 AM | ||
**/ | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/permission-remote-api") | ||
@Api(tags = {"Permission Remote API Controller"}) | ||
public class PermissionRemoteApiController { | ||
private final PermissionService permissionService; | ||
|
||
@PostMapping("/get-permission-list-by-role-id-list") | ||
public ResponseBodyBean<GetPermissionListByRoleIdListResponse> getPermissionListByRoleIdList(@Valid @RequestBody GetPermissionListByRoleIdListPayload payload) { | ||
return ResponseBodyBean.ofSuccess(permissionService.getPermissionListByRoleIdList(payload)); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...-center/src/main/java/com/jmsoftware/authcenter/permission/service/PermissionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.jmsoftware.authcenter.permission.service; | ||
|
||
import com.jmsoftware.authcenter.permission.entity.PermissionPersistence; | ||
import com.jmsoftware.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload; | ||
import com.jmsoftware.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse; | ||
import lombok.NonNull; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* <h1>PermissionService</h1> | ||
* <p> | ||
* Service of Permission.(Permission) | ||
* | ||
* @author Johnny Miller (鍾俊), e-mail: johnnysviva@outlook.com | ||
* @date 5 /11/20 8:34 AM | ||
*/ | ||
public interface PermissionService { | ||
/** | ||
* Query by ID | ||
* | ||
* @param id the primary key ID | ||
* @return the entity | ||
*/ | ||
PermissionPersistence queryById(Long id); | ||
|
||
/** | ||
* Query all by limit | ||
* | ||
* @param offset the offset | ||
* @param limit the limit | ||
* @return the entity list | ||
*/ | ||
List<PermissionPersistence> queryAllByLimit(int offset, int limit); | ||
|
||
/** | ||
* Insert | ||
* | ||
* @param permissionPersistence the entity | ||
* @return the entity | ||
*/ | ||
PermissionPersistence insert(PermissionPersistence permissionPersistence); | ||
|
||
/** | ||
* Update | ||
* | ||
* @param permissionPersistence the entity | ||
* @return the entity | ||
*/ | ||
PermissionPersistence update(PermissionPersistence permissionPersistence); | ||
|
||
/** | ||
* Delete by ID | ||
* | ||
* @param id the primary key ID | ||
* @return the boolean | ||
*/ | ||
boolean deleteById(Long id); | ||
|
||
/** | ||
* Gets permission list by role id list. | ||
* | ||
* @param payload the payload | ||
* @return the permission list by role id list | ||
*/ | ||
GetPermissionListByRoleIdListResponse getPermissionListByRoleIdList(GetPermissionListByRoleIdListPayload payload); | ||
|
||
/** | ||
* Gets permission list by role id list. | ||
* | ||
* @param roleIdList the role id list | ||
* @return the permission list by role id list | ||
*/ | ||
List<PermissionPersistence> getPermissionListByRoleIdList(@NonNull List<Long> roleIdList); | ||
} |
81 changes: 81 additions & 0 deletions
81
...rc/main/java/com/jmsoftware/authcenter/permission/service/impl/PermissionServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.jmsoftware.authcenter.permission.service.impl; | ||
|
||
import cn.hutool.core.bean.BeanUtil; | ||
import cn.hutool.core.collection.CollUtil; | ||
import com.jmsoftware.authcenter.permission.entity.PermissionPersistence; | ||
import com.jmsoftware.authcenter.permission.mapper.PermissionMapper; | ||
import com.jmsoftware.authcenter.permission.service.PermissionService; | ||
import com.jmsoftware.authcenter.universal.aspect.ValidateArgument; | ||
import com.jmsoftware.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload; | ||
import com.jmsoftware.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse; | ||
import lombok.NonNull; | ||
import lombok.val; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.Resource; | ||
import javax.validation.Valid; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* <h1>PermissionServiceImpl</h1> | ||
* <p> | ||
* Service implementation of Permission.(Permission) | ||
* | ||
* @author Johnny Miller (鍾俊), e-mail: johnnysviva@outlook.com | ||
* @date 5/11/20 8:34 AM | ||
*/ | ||
@Service("permissionService") | ||
public class PermissionServiceImpl implements PermissionService { | ||
@Resource | ||
private PermissionMapper permissionMapper; | ||
|
||
@Override | ||
public PermissionPersistence queryById(Long id) { | ||
return this.permissionMapper.queryById(id); | ||
} | ||
|
||
@Override | ||
public List<PermissionPersistence> queryAllByLimit(int offset, int limit) { | ||
return this.permissionMapper.queryAllByLimit(offset, limit); | ||
} | ||
|
||
@Override | ||
public PermissionPersistence insert(PermissionPersistence permissionPersistence) { | ||
this.permissionMapper.insert(permissionPersistence); | ||
return permissionPersistence; | ||
} | ||
|
||
@Override | ||
public PermissionPersistence update(PermissionPersistence permissionPersistence) { | ||
this.permissionMapper.update(permissionPersistence); | ||
return this.queryById(permissionPersistence.getId()); | ||
} | ||
|
||
@Override | ||
public boolean deleteById(Long id) { | ||
return this.permissionMapper.deleteById(id) > 0; | ||
} | ||
|
||
@Override | ||
@ValidateArgument | ||
public GetPermissionListByRoleIdListResponse getPermissionListByRoleIdList(@Valid GetPermissionListByRoleIdListPayload payload) { | ||
val permissionList = this.getPermissionListByRoleIdList(payload.getRoleIdList()); | ||
val response = new GetPermissionListByRoleIdListResponse(); | ||
permissionList.forEach(permissionPersistence -> { | ||
GetPermissionListByRoleIdListResponse.Permission permission = | ||
new GetPermissionListByRoleIdListResponse.Permission(); | ||
BeanUtil.copyProperties(permissionPersistence, permission); | ||
response.getPermissionList().add(permission); | ||
}); | ||
return response; | ||
} | ||
|
||
@Override | ||
public List<PermissionPersistence> getPermissionListByRoleIdList(@NonNull List<Long> roleIdList) { | ||
if (CollUtil.isEmpty(roleIdList)) { | ||
return Collections.emptyList(); | ||
} | ||
return permissionMapper.selectPermissionListByRoleIdList(roleIdList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.