权限,列表,详情
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"admin/internal/dao"
|
||||
"admin/internal/model"
|
||||
"admin/validator"
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"admin/admin"
|
||||
"admin/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"pkg.local/modelbase"
|
||||
"pkg.local/utils"
|
||||
)
|
||||
|
||||
type AuthorityInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewAuthorityInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthorityInfoLogic {
|
||||
return &AuthorityInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AuthorityInfoLogic) AuthorityInfo(in *admin.InfoRequest) (*admin.Response, error) {
|
||||
var v validator.AuthorityInfoValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
info := dao.AuthorityInfo{}
|
||||
modelObj := model.AuthorityModel{}.Init()
|
||||
w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}}
|
||||
err := modelObj.GetOne(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.ErrorNotFund), nil
|
||||
}
|
||||
new := dao.AuthorityInfoNew{
|
||||
AuthorityInfo: info,
|
||||
}
|
||||
if info.Type == dao.TypeData {
|
||||
var items []dao.AuthorityGetJsonIds
|
||||
w = modelbase.Params{Other: map[string]string{"FIND_IN_SET(?, data_ids)": strconv.FormatInt(info.Id, utils.NumberTen)}}
|
||||
err = modelObj.Items(w, &items)
|
||||
|
||||
if len(items) == utils.NumberThree {
|
||||
w = modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(items[utils.NumberZero].Id, utils.NumberTen)}}
|
||||
err = modelObj.GetOne(w, &info)
|
||||
new = dao.AuthorityInfoNew{
|
||||
AuthorityInfo: info,
|
||||
}
|
||||
new.JsonDataAll = items[utils.NumberZero].JsonTreeData
|
||||
new.JsonDataDepartment = items[utils.NumberOne].JsonTreeData
|
||||
new.JsonDataOneself = items[utils.NumberTwo].JsonTreeData
|
||||
}
|
||||
}
|
||||
|
||||
return l.ok(new), nil
|
||||
}
|
||||
Reference in New Issue
Block a user