正在显示
9 个修改的文件
包含
51 行增加
和
35 行删除
@@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | @@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | ||
5 | type QueryCycleCommand struct { | 5 | type QueryCycleCommand struct { |
6 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
7 | Name string `cname:"周期名称" json:"name"` | 7 | Name string `cname:"周期名称" json:"name"` |
8 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
9 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 8 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
9 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
10 | } | 10 | } |
11 | 11 | ||
12 | type StatisticCycleProjectUserCommand struct { | 12 | type StatisticCycleProjectUserCommand struct { |
@@ -8,8 +8,8 @@ type QueryProjectCommand struct { | @@ -8,8 +8,8 @@ type QueryProjectCommand struct { | ||
8 | Name string `cname:"项目名称" json:"name"` | 8 | Name string `cname:"项目名称" json:"name"` |
9 | State int `cname:"项目状态" json:"state"` | 9 | State int `cname:"项目状态" json:"state"` |
10 | PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` | 10 | PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` |
11 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
12 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 11 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
12 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
13 | } | 13 | } |
14 | 14 | ||
15 | func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | 15 | func (in *QueryProjectCommand) Valid(validation *validation.Validation) { |
@@ -7,8 +7,8 @@ type QueryRuleCommand struct { | @@ -7,8 +7,8 @@ type QueryRuleCommand struct { | ||
7 | NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` | 7 | NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` |
8 | Type int `cname:"评估方式(0评级、1评分)" json:"type"` | 8 | Type int `cname:"评估方式(0评级、1评分)" json:"type"` |
9 | CreatorId int64 `cname:"创建人ID" json:"creatorId,string"` | 9 | CreatorId int64 `cname:"创建人ID" json:"creatorId,string"` |
10 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
11 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 10 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
11 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
12 | } | 12 | } |
13 | 13 | ||
14 | func (in *QueryRuleCommand) Valid(validation *validation.Validation) { | 14 | func (in *QueryRuleCommand) Valid(validation *validation.Validation) { |
@@ -10,8 +10,8 @@ type QueryTemplateCommand struct { | @@ -10,8 +10,8 @@ type QueryTemplateCommand struct { | ||
10 | Name string `cname:"模板名称" json:"name"` | 10 | Name string `cname:"模板名称" json:"name"` |
11 | State int `cname:"模板状态" json:"state"` | 11 | State int `cname:"模板状态" json:"state"` |
12 | CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` | 12 | CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` |
13 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
14 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 13 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
14 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
15 | } | 15 | } |
16 | 16 | ||
17 | func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | 17 | func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { |
@@ -20,15 +20,3 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | @@ -20,15 +20,3 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | ||
20 | return | 20 | return |
21 | } | 21 | } |
22 | } | 22 | } |
23 | - | ||
24 | -//// AllEnableTemplateCommand 查询所有已启用的模板 | ||
25 | -//type AllEnableTemplateCommand struct { | ||
26 | -// CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
27 | -//} | ||
28 | -// | ||
29 | -//func (in *AllEnableTemplateCommand) Valid(validation *validation.Validation) { | ||
30 | -// if in.CompanyId == 0 { | ||
31 | -// validation.SetError("companyId", "公司ID无效") | ||
32 | -// return | ||
33 | -// } | ||
34 | -//} |
@@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | @@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | ||
5 | // QueryRoleUserCommand 查询角色列表(关联用户) | 5 | // QueryRoleUserCommand 查询角色列表(关联用户) |
6 | type QueryRoleUserCommand struct { | 6 | type QueryRoleUserCommand struct { |
7 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 7 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
8 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
9 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 8 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
9 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
10 | } | 10 | } |
11 | 11 | ||
12 | func (in *QueryRoleUserCommand) Valid(validation *validation.Validation) { | 12 | func (in *QueryRoleUserCommand) Valid(validation *validation.Validation) { |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/adapter" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/adapter" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type RoleService struct { | 12 | type RoleService struct { |
@@ -150,11 +151,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -150,11 +151,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
150 | if err != nil { | 151 | if err != nil { |
151 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 152 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
152 | } | 153 | } |
153 | - if len(roles) == 0 { | ||
154 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据") | ||
155 | - } | ||
156 | 154 | ||
157 | adapterList := make([]*adapter.RoleUserAdapter, 0) | 155 | adapterList := make([]*adapter.RoleUserAdapter, 0) |
156 | + | ||
157 | + // 如果不存在系统预支hrbp角色时,插入一条数据 | ||
158 | + var havaSystemType = false | ||
159 | + for i := range roles { | ||
160 | + if roles[i].Type == domain.RoleTypeSystem { | ||
161 | + havaSystemType = true | ||
162 | + break | ||
163 | + } | ||
164 | + } | ||
165 | + if !havaSystemType { | ||
166 | + role := &domain.Role{ | ||
167 | + Id: 0, | ||
168 | + Name: "HRBP", | ||
169 | + Type: domain.RoleTypeSystem, | ||
170 | + Description: "拥有全部权限,预置角色不可删除", | ||
171 | + CompanyId: in.CompanyId, | ||
172 | + } | ||
173 | + role, err = roleRepository.Insert(role) | ||
174 | + if err != nil { | ||
175 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
176 | + } | ||
177 | + | ||
178 | + // 创建HRBP角色 | ||
179 | + roleUser := &adapter.RoleUserAdapter{} | ||
180 | + roleUser.Role = role | ||
181 | + roleUser.Users = make([]*domain.RoleContainUser, 0) | ||
182 | + adapterList = append(adapterList, roleUser) | ||
183 | + } | ||
184 | + | ||
158 | for i := range roles { | 185 | for i := range roles { |
159 | v := roles[i] | 186 | v := roles[i] |
160 | tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) | 187 | tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) |
@@ -162,13 +189,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -162,13 +189,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
162 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 189 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
163 | } | 190 | } |
164 | roleUser := &adapter.RoleUserAdapter{} | 191 | roleUser := &adapter.RoleUserAdapter{} |
165 | - roleUser.Id = v.Id | ||
166 | - roleUser.Name = v.Name | ||
167 | - roleUser.Type = v.Type | ||
168 | - roleUser.Description = v.Description | ||
169 | - roleUser.CompanyId = v.CompanyId | 192 | + roleUser.Role = v |
170 | roleUser.Users = tempList | 193 | roleUser.Users = tempList |
171 | adapterList = append(adapterList, roleUser) | 194 | adapterList = append(adapterList, roleUser) |
172 | } | 195 | } |
196 | + | ||
197 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
198 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
199 | + } | ||
200 | + | ||
173 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil | 201 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
174 | } | 202 | } |
@@ -10,7 +10,7 @@ const ( | @@ -10,7 +10,7 @@ const ( | ||
10 | type Role struct { | 10 | type Role struct { |
11 | Id int64 `json:"id,string"` | 11 | Id int64 `json:"id,string"` |
12 | Name string `json:"name"` | 12 | Name string `json:"name"` |
13 | - Type int `json:"type"` | 13 | + Type int `json:"type" pg:",use_zero"` |
14 | Description string `json:"description"` | 14 | Description string `json:"description"` |
15 | CompanyId int64 `json:"companyId,string"` | 15 | CompanyId int64 `json:"companyId,string"` |
16 | CreatedAt time.Time `json:"createdAt"` | 16 | CreatedAt time.Time `json:"createdAt"` |
@@ -3,13 +3,13 @@ package models | @@ -3,13 +3,13 @@ package models | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | type Role struct { | 5 | type Role struct { |
6 | - tableName struct{} `pg:"role" comment:"角色"` | ||
7 | - Id int64 `pg:"pk:id" comment:"ID"` | 6 | + tableName struct{} `comment:"角色" pg:"role"` |
7 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
8 | Name string `comment:"角色名称"` | 8 | Name string `comment:"角色名称"` |
9 | Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)" pg:",use_zero"` | 9 | Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)" pg:",use_zero"` |
10 | Description string `comment:"角色描述"` | 10 | Description string `comment:"角色描述"` |
11 | CompanyId int64 `comment:"公司ID"` | 11 | CompanyId int64 `comment:"公司ID"` |
12 | CreatedAt time.Time `comment:"创建时间"` | 12 | CreatedAt time.Time `comment:"创建时间"` |
13 | UpdatedAt time.Time `comment:"更新时间"` | 13 | UpdatedAt time.Time `comment:"更新时间"` |
14 | - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | 14 | + DeletedAt *time.Time `comment:"删除时间"` |
15 | } | 15 | } |
-
请 注册 或 登录 后发表评论