-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alan Yeh <[email protected]>
- Loading branch information
Showing
11 changed files
with
1,425 additions
and
114 deletions.
There are no files selected for viewing
57 changes: 0 additions & 57 deletions
57
...ard/src/main/java/central/studio/dashboard/controller/authority/SystemRoleController.java
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
...board/src/main/java/central/studio/dashboard/controller/authority/UnitRoleController.java
This file was deleted.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
...rc/main/java/central/studio/dashboard/controller/authority/controller/RoleController.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,132 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022-present Alan Yeh <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package central.studio.dashboard.controller.authority.controller; | ||
|
||
import central.bean.Page; | ||
import central.data.authority.Role; | ||
import central.starter.web.param.IdsParams; | ||
import central.starter.web.query.IdQuery; | ||
import central.studio.dashboard.controller.authority.param.RoleParams; | ||
import central.studio.dashboard.controller.authority.query.RolePageQuery; | ||
import central.studio.dashboard.logic.authority.RoleLogic; | ||
import central.validation.group.Insert; | ||
import central.validation.group.Update; | ||
import central.web.XForwardedHeaders; | ||
import jakarta.validation.groups.Default; | ||
import lombok.Setter; | ||
import org.apache.shiro.authz.annotation.RequiresAuthentication; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* System Role Controller | ||
* <p> | ||
* 系统角色管理 | ||
* | ||
* @author Alan Yeh | ||
* @since 2024/12/13 | ||
*/ | ||
@RestController | ||
@RequiresAuthentication | ||
@RequestMapping("/dashboard/api/authority/roles") | ||
public class RoleController { | ||
/** | ||
* 权限 | ||
*/ | ||
public interface Permissions { | ||
String VIEW = "${application}:authority:system:role:view"; | ||
String ADD = "${application}:authority:system:role:add"; | ||
String EDIT = "${application}:authority:system:role:edit"; | ||
String REMOVE = "${application}:authority:system:role:remove"; | ||
String ENABLE = "${application}:authority:system:role:enable"; | ||
String DISABLE = "${application}:authority:system:role:disable"; | ||
} | ||
@Setter(onMethod_ = @Autowired) | ||
private RoleLogic logic; | ||
|
||
/** | ||
* 按条件分页查询数据列表 | ||
* | ||
* @param query 查询 | ||
* @param tenant 租户标识 | ||
* @return 分页结果 | ||
*/ | ||
@GetMapping("/page") | ||
public Page<Role> page(@Validated RolePageQuery query, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.pageBy(query.getPageIndex(), query.getPageSize(), query.build(), null, tenant); | ||
} | ||
|
||
/** | ||
* 根据主键查询数据详情 | ||
* | ||
* @param query 查询 | ||
* @param tenant 租户标识 | ||
* @return 详情 | ||
*/ | ||
@GetMapping("/details") | ||
public Role details(@Validated IdQuery<Role> query, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.findById(query.getId(), tenant); | ||
} | ||
|
||
/** | ||
* 新增数据 | ||
* | ||
* @param params 数据入参 | ||
* @param accountId 当前登录帐号 | ||
* @param tenant 租户标识 | ||
* @return 新增后数据 | ||
*/ | ||
@PostMapping | ||
public Role add(@RequestBody @Validated({Insert.class, Default.class}) RoleParams params, @RequestAttribute String accountId, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.insert(params.toInput(), accountId, tenant); | ||
} | ||
|
||
/** | ||
* 更新数据 | ||
* | ||
* @param params 数据入参 | ||
* @param accountId 当前登录帐号 | ||
* @param tenant 租户标识 | ||
* @return 更新后数据 | ||
*/ | ||
@PutMapping | ||
public Role update(@RequestBody @Validated({Update.class, Default.class}) RoleParams params, @RequestAttribute String accountId, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.update(params.toInput(), accountId, tenant); | ||
} | ||
|
||
/** | ||
* 根据主键删除数据 | ||
* | ||
* @param params 待删除主键 | ||
* @param accountId 当前登录帐号 | ||
* @param tenant 租户标识 | ||
* @return 受影响数据行数 | ||
*/ | ||
@DeleteMapping | ||
public long delete(@Validated IdsParams params, @RequestAttribute String accountId, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.deleteByIds(params.getIds(), accountId, tenant); | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
...ain/java/central/studio/dashboard/controller/authority/controller/UnitRoleController.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,135 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022-present Alan Yeh <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package central.studio.dashboard.controller.authority.controller; | ||
|
||
import central.bean.Page; | ||
import central.data.authority.Role; | ||
import central.starter.web.param.IdsParams; | ||
import central.starter.web.query.IdQuery; | ||
import central.studio.dashboard.controller.authority.param.UnitRoleParams; | ||
import central.studio.dashboard.controller.authority.query.UnitRolePageQuery; | ||
import central.studio.dashboard.logic.authority.RoleLogic; | ||
import central.validation.group.Insert; | ||
import central.validation.group.Update; | ||
import central.web.XForwardedHeaders; | ||
import jakarta.validation.groups.Default; | ||
import lombok.Setter; | ||
import org.apache.shiro.authz.annotation.RequiresAuthentication; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* Unit Role Controller | ||
* <p> | ||
* 单位角色管理 | ||
* | ||
* @author Alan Yeh | ||
* @since 2024/12/13 | ||
*/ | ||
@RestController | ||
@RequiresAuthentication | ||
@RequestMapping("/dashboard/api/authority/unit-roles") | ||
public class UnitRoleController { | ||
|
||
/** | ||
* 权限 | ||
*/ | ||
public interface Permissions { | ||
String VIEW = "${application}:authority:unit:role:view"; | ||
String ADD = "${application}:authority:unit:role:add"; | ||
String EDIT = "${application}:authority:unit:role:edit"; | ||
String REMOVE = "${application}:authority:unit:role:remove"; | ||
String ENABLE = "${application}:authority:unit:role:enable"; | ||
String DISABLE = "${application}:authority:unit:role:disable"; | ||
} | ||
|
||
|
||
@Setter(onMethod_ = @Autowired) | ||
private RoleLogic logic; | ||
|
||
/** | ||
* 按条件分页查询数据列表 | ||
* | ||
* @param query 查询 | ||
* @param tenant 租户标识 | ||
* @return 分页结果 | ||
*/ | ||
@GetMapping("/page") | ||
public Page<Role> page(@Validated UnitRolePageQuery query, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.pageBy(query.getPageIndex(), query.getPageSize(), query.build(), null, tenant); | ||
} | ||
|
||
/** | ||
* 根据主键查询数据详情 | ||
* | ||
* @param query 查询 | ||
* @param tenant 租户标识 | ||
* @return 详情 | ||
*/ | ||
@GetMapping("/details") | ||
public Role details(@Validated IdQuery<Role> query, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.findById(query.getId(), tenant); | ||
} | ||
|
||
/** | ||
* 新增数据 | ||
* | ||
* @param params 数据入参 | ||
* @param accountId 当前登录帐号 | ||
* @param tenant 租户标识 | ||
* @return 新增后数据 | ||
*/ | ||
@PostMapping | ||
public Role add(@RequestBody @Validated({Insert.class, Default.class}) UnitRoleParams params, @RequestAttribute String accountId, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.insert(params.toInput(), accountId, tenant); | ||
} | ||
|
||
/** | ||
* 更新数据 | ||
* | ||
* @param params 数据入参 | ||
* @param accountId 当前登录帐号 | ||
* @param tenant 租户标识 | ||
* @return 更新后数据 | ||
*/ | ||
@PutMapping | ||
public Role update(@RequestBody @Validated({Update.class, Default.class}) UnitRoleParams params, @RequestAttribute String accountId, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.update(params.toInput(), accountId, tenant); | ||
} | ||
|
||
/** | ||
* 根据主键删除数据 | ||
* | ||
* @param params 待删除主键 | ||
* @param accountId 当前登录帐号 | ||
* @param tenant 租户标识 | ||
* @return 受影响数据行数 | ||
*/ | ||
@DeleteMapping | ||
public long delete(@Validated IdsParams params, @RequestAttribute String accountId, @RequestHeader(XForwardedHeaders.TENANT) String tenant) { | ||
return this.logic.deleteByIds(params.getIds(), accountId, tenant); | ||
} | ||
} |
Oops, something went wrong.