chore: 并入 iotlcm-admin-svr 历史到 admin-svr/(原提交 49818c6)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/agent/v1"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model/response"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) RoleList(ctx context.Context, req *v1.RoleListReq) (res *v1.RoleListRes, err error) {
|
||||
data, total, err := service.AgentRole().RoleList(ctx, &req.AgentRoleListParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RoleListRes{PageResult: response.PageResult{Total: total}, Data: data}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) RoleView(ctx context.Context, req *v1.RoleViewReq) (res *v1.RoleViewRes, err error) {
|
||||
data, err := service.AgentRole().RoleView(ctx, req.RoleId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RoleViewRes{AgentRoleViewModel: *data}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) RoleSave(ctx context.Context, req *v1.RoleSaveReq) (res *v1.RoleSaveRes, err error) {
|
||||
roleId, err := service.AgentRole().RoleSave(ctx, &req.AgentRoleSaveParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RoleSaveRes{RoleId: roleId}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) RoleDelete(ctx context.Context, req *v1.RoleDeleteReq) (res *v1.RoleDeleteRes, err error) {
|
||||
roleIds := req.RoleIds
|
||||
if req.RoleId != 0 {
|
||||
roleIds = append(roleIds, req.RoleId)
|
||||
}
|
||||
err = service.AgentRole().RoleDelete(ctx, roleIds)
|
||||
return &v1.RoleDeleteRes{}, err
|
||||
}
|
||||
Reference in New Issue
Block a user