Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
20 个修改的文件
包含
133 行增加
和
112 行删除
| @@ -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) { |
| @@ -8,7 +8,6 @@ import ( | @@ -8,7 +8,6 @@ import ( | ||
| 8 | type UpdateRuleCommand struct { | 8 | type UpdateRuleCommand struct { |
| 9 | Id int64 `cname:"规则ID" json:"id,string" valid:"Required"` | 9 | Id int64 `cname:"规则ID" json:"id,string" valid:"Required"` |
| 10 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 10 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| 11 | - CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
| 12 | Name string `cname:"规则名称" json:"name" valid:"Required"` | 11 | Name string `cname:"规则名称" json:"name" valid:"Required"` |
| 13 | Remark string `cname:"规则备注" json:"remark"` | 12 | Remark string `cname:"规则备注" json:"remark"` |
| 14 | Type int `cname:"评估方式" json:"type"` | 13 | Type int `cname:"评估方式" json:"type"` |
| @@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | @@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | ||
| 21 | validation.SetError("companyId", "公司ID无效") | 20 | validation.SetError("companyId", "公司ID无效") |
| 22 | return | 21 | return |
| 23 | } | 22 | } |
| 24 | - if in.CreatorId == 0 { | ||
| 25 | - validation.SetError("creatorId", "创建人ID无效") | ||
| 26 | - return | ||
| 27 | - } | ||
| 28 | 23 | ||
| 29 | if len(in.Name) > 40 { | 24 | if len(in.Name) > 40 { |
| 30 | validation.SetError("name", "名称最大长度40个字符") | 25 | validation.SetError("name", "名称最大长度40个字符") |
| @@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | @@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | ||
| 35 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 35 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 36 | } | 36 | } |
| 37 | if count > 0 { | 37 | if count > 0 { |
| 38 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 38 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则") |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 | 41 | if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 |
| @@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac | @@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac | ||
| 82 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 82 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 83 | } | 83 | } |
| 84 | if count > 0 { | 84 | if count > 0 { |
| 85 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 85 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则") |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id}) | 88 | rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id}) |
| @@ -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 | -//} |
| @@ -34,7 +34,7 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( | @@ -34,7 +34,7 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( | ||
| 34 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 34 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 35 | } | 35 | } |
| 36 | if count > 0 { | 36 | if count > 0 { |
| 37 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 37 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估模板") |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | linkNodes := make([]*domain.LinkNode, 0) | 40 | linkNodes := make([]*domain.LinkNode, 0) |
| @@ -44,30 +44,35 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( | @@ -44,30 +44,35 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( | ||
| 44 | Id: sid + 1, | 44 | Id: sid + 1, |
| 45 | Type: domain.LinkNodeSelfAssessment, | 45 | Type: domain.LinkNodeSelfAssessment, |
| 46 | Name: "填写自评反馈", | 46 | Name: "填写自评反馈", |
| 47 | + NodeContents: make([]*domain.NodeContent, 0), | ||
| 47 | KpiCycle: domain.KpiCycleDay, | 48 | KpiCycle: domain.KpiCycleDay, |
| 48 | }) | 49 | }) |
| 49 | linkNodes = append(linkNodes, &domain.LinkNode{ | 50 | linkNodes = append(linkNodes, &domain.LinkNode{ |
| 50 | Id: sid + 2, | 51 | Id: sid + 2, |
| 51 | Type: domain.LinkNodeAllInvite, | 52 | Type: domain.LinkNodeAllInvite, |
| 52 | Name: "360°邀请", | 53 | Name: "360°邀请", |
| 54 | + NodeContents: make([]*domain.NodeContent, 0), | ||
| 53 | KpiCycle: domain.KpiCycleDay, | 55 | KpiCycle: domain.KpiCycleDay, |
| 54 | }) | 56 | }) |
| 55 | linkNodes = append(linkNodes, &domain.LinkNode{ | 57 | linkNodes = append(linkNodes, &domain.LinkNode{ |
| 56 | Id: sid + 3, | 58 | Id: sid + 3, |
| 57 | Type: domain.LinkNodeAllAssessment, | 59 | Type: domain.LinkNodeAllAssessment, |
| 58 | Name: "360°评估", | 60 | Name: "360°评估", |
| 61 | + NodeContents: make([]*domain.NodeContent, 0), | ||
| 59 | KpiCycle: domain.KpiCycleDay, | 62 | KpiCycle: domain.KpiCycleDay, |
| 60 | }) | 63 | }) |
| 61 | linkNodes = append(linkNodes, &domain.LinkNode{ | 64 | linkNodes = append(linkNodes, &domain.LinkNode{ |
| 62 | Id: sid + 4, | 65 | Id: sid + 4, |
| 63 | Type: domain.LinkNodeSuperiorAssessment, | 66 | Type: domain.LinkNodeSuperiorAssessment, |
| 64 | Name: "上级评估", | 67 | Name: "上级评估", |
| 68 | + NodeContents: make([]*domain.NodeContent, 0), | ||
| 65 | KpiCycle: domain.KpiCycleDay, | 69 | KpiCycle: domain.KpiCycleDay, |
| 66 | }) | 70 | }) |
| 67 | linkNodes = append(linkNodes, &domain.LinkNode{ | 71 | linkNodes = append(linkNodes, &domain.LinkNode{ |
| 68 | Id: sid + 5, | 72 | Id: sid + 5, |
| 69 | Type: domain.LinkNodeViewResult, | 73 | Type: domain.LinkNodeViewResult, |
| 70 | Name: "绩效结果查看", | 74 | Name: "绩效结果查看", |
| 75 | + NodeContents: make([]*domain.NodeContent, 0), | ||
| 71 | KpiCycle: domain.KpiCycleDay, | 76 | KpiCycle: domain.KpiCycleDay, |
| 72 | }) | 77 | }) |
| 73 | 78 |
| @@ -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 { |
| @@ -91,47 +92,53 @@ func NewRoleService() *RoleService { | @@ -91,47 +92,53 @@ func NewRoleService() *RoleService { | ||
| 91 | // return role, nil | 92 | // return role, nil |
| 92 | //} | 93 | //} |
| 93 | // | 94 | // |
| 94 | -//func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) { | ||
| 95 | -// transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 96 | -// if err != nil { | ||
| 97 | -// return nil, err | ||
| 98 | -// } | ||
| 99 | -// defer func() { | ||
| 100 | -// transactionContext.RollbackTransaction() | ||
| 101 | -// }() | ||
| 102 | -// | ||
| 103 | -// roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 104 | -// roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 105 | -// | ||
| 106 | -// role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 107 | -// if err != nil { | ||
| 108 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 109 | -// } | ||
| 110 | -// if _, err := roleRepository.Remove(role); err != nil { | ||
| 111 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 112 | -// } | ||
| 113 | -// | ||
| 114 | -// // 获取角色所有关联的用户,并删除 | ||
| 115 | -// _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId}) | ||
| 116 | -// if err != nil { | ||
| 117 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 118 | -// } | ||
| 119 | -// ids := make([]int64, 0) | ||
| 120 | -// for i := range roleUsers { | ||
| 121 | -// ids = append(ids, roleUsers[i].Id) | ||
| 122 | -// } | ||
| 123 | -// if len(ids) > 0 { | ||
| 124 | -// err := roleUserRepository.BatchDeleteById(ids) | ||
| 125 | -// if err != nil { | ||
| 126 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 127 | -// } | ||
| 128 | -// } | ||
| 129 | -// | ||
| 130 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 131 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 132 | -// } | ||
| 133 | -// return role, nil | ||
| 134 | -//} | 95 | + |
| 96 | +func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) { | ||
| 97 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 98 | + if err != nil { | ||
| 99 | + return nil, err | ||
| 100 | + } | ||
| 101 | + defer func() { | ||
| 102 | + transactionContext.RollbackTransaction() | ||
| 103 | + }() | ||
| 104 | + | ||
| 105 | + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 106 | + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 107 | + | ||
| 108 | + role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 109 | + if err != nil { | ||
| 110 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + if role.Type == domain.RoleTypeSystem { | ||
| 114 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除") | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + if _, err := roleRepository.Remove(role); err != nil { | ||
| 118 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + // 获取角色所有关联的用户,并删除 | ||
| 122 | + _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId}) | ||
| 123 | + if err != nil { | ||
| 124 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 125 | + } | ||
| 126 | + ids := make([]int64, 0) | ||
| 127 | + for i := range roleUsers { | ||
| 128 | + ids = append(ids, roleUsers[i].Id) | ||
| 129 | + } | ||
| 130 | + if len(ids) > 0 { | ||
| 131 | + err := roleUserRepository.BatchDeleteById(ids) | ||
| 132 | + if err != nil { | ||
| 133 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 138 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 139 | + } | ||
| 140 | + return role, nil | ||
| 141 | +} | ||
| 135 | 142 | ||
| 136 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { | 143 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { |
| 137 | transactionContext, err := factory.StartTransaction() | 144 | transactionContext, err := factory.StartTransaction() |
| @@ -150,11 +157,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -150,11 +157,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
| 150 | if err != nil { | 157 | if err != nil { |
| 151 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 158 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 152 | } | 159 | } |
| 153 | - if len(roles) == 0 { | ||
| 154 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据") | ||
| 155 | - } | ||
| 156 | 160 | ||
| 157 | adapterList := make([]*adapter.RoleUserAdapter, 0) | 161 | adapterList := make([]*adapter.RoleUserAdapter, 0) |
| 162 | + | ||
| 163 | + // 如果不存在系统预支hrbp角色时,插入一条数据 | ||
| 164 | + var havaSystemType = false | ||
| 165 | + for i := range roles { | ||
| 166 | + if roles[i].Type == domain.RoleTypeSystem { | ||
| 167 | + havaSystemType = true | ||
| 168 | + break | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + if !havaSystemType { | ||
| 172 | + role := &domain.Role{ | ||
| 173 | + Id: 0, | ||
| 174 | + Name: "HRBP", | ||
| 175 | + Type: domain.RoleTypeSystem, | ||
| 176 | + Description: "拥有全部权限,预置角色不可删除", | ||
| 177 | + CompanyId: in.CompanyId, | ||
| 178 | + } | ||
| 179 | + role, err = roleRepository.Insert(role) | ||
| 180 | + if err != nil { | ||
| 181 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + // 创建HRBP角色 | ||
| 185 | + roleUser := &adapter.RoleUserAdapter{} | ||
| 186 | + roleUser.Role = role | ||
| 187 | + roleUser.Users = make([]*domain.RoleContainUser, 0) | ||
| 188 | + adapterList = append(adapterList, roleUser) | ||
| 189 | + } | ||
| 190 | + | ||
| 158 | for i := range roles { | 191 | for i := range roles { |
| 159 | v := roles[i] | 192 | v := roles[i] |
| 160 | tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) | 193 | tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) |
| @@ -162,13 +195,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -162,13 +195,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
| 162 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 195 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 163 | } | 196 | } |
| 164 | roleUser := &adapter.RoleUserAdapter{} | 197 | 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 | 198 | + roleUser.Role = v |
| 170 | roleUser.Users = tempList | 199 | roleUser.Users = tempList |
| 171 | adapterList = append(adapterList, roleUser) | 200 | adapterList = append(adapterList, roleUser) |
| 172 | } | 201 | } |
| 202 | + | ||
| 203 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 204 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 205 | + } | ||
| 206 | + | ||
| 173 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil | 207 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
| 174 | } | 208 | } |
| @@ -28,6 +28,11 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | @@ -28,6 +28,11 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | ||
| 28 | }() | 28 | }() |
| 29 | roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 29 | roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 30 | 30 | ||
| 31 | + //int64Array := make([]int64, 0) | ||
| 32 | + //for i := range in.UserIds { | ||
| 33 | + // int64Num, _ := strconv.ParseInt(in.UserIds[i], 10, 64) | ||
| 34 | + // int64Array = append(int64Array, int64Num) | ||
| 35 | + //} | ||
| 31 | // 检测已存在的关联用户 | 36 | // 检测已存在的关联用户 |
| 32 | _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999}) | 37 | _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999}) |
| 33 | if err != nil { | 38 | if err != nil { |
| @@ -33,7 +33,7 @@ type EntryItem struct { | @@ -33,7 +33,7 @@ type EntryItem struct { | ||
| 33 | type NodeContent struct { | 33 | type NodeContent struct { |
| 34 | Category string `json:"category" comment:"类别"` | 34 | Category string `json:"category" comment:"类别"` |
| 35 | Name string `json:"name" comment:"名称"` | 35 | Name string `json:"name" comment:"名称"` |
| 36 | - RuleId int64 `json:"ruleId" comment:"评估规则ID"` | 36 | + RuleId int64 `json:"ruleId,string" comment:"评估规则ID"` |
| 37 | Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` | 37 | Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` |
| 38 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` | 38 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` |
| 39 | PromptText string `json:"promptText" comment:"提示项正文"` | 39 | PromptText string `json:"promptText" comment:"提示项正文"` |
| @@ -59,7 +59,7 @@ type LinkNode struct { | @@ -59,7 +59,7 @@ type LinkNode struct { | ||
| 59 | NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` | 59 | NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` |
| 60 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` | 60 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` |
| 61 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 61 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
| 62 | - KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` | 62 | + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
| 63 | //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` | 63 | //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` |
| 64 | 64 | ||
| 65 | } | 65 | } |
| @@ -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"` |
| @@ -17,5 +17,5 @@ type EvaluationRule struct { | @@ -17,5 +17,5 @@ type EvaluationRule struct { | ||
| 17 | Score domain.Score `comment:"评分"` | 17 | Score domain.Score `comment:"评分"` |
| 18 | CreatedAt time.Time `comment:"创建时间"` | 18 | CreatedAt time.Time `comment:"创建时间"` |
| 19 | UpdatedAt time.Time `comment:"更新时间"` | 19 | UpdatedAt time.Time `comment:"更新时间"` |
| 20 | - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | 20 | + DeletedAt *time.Time `comment:"删除时间"` |
| 21 | } | 21 | } |
| @@ -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 | } |
| @@ -10,5 +10,5 @@ type RoleUser struct { | @@ -10,5 +10,5 @@ type RoleUser struct { | ||
| 10 | CompanyId int64 `comment:"公司ID"` | 10 | CompanyId int64 `comment:"公司ID"` |
| 11 | CreatedAt time.Time `comment:"创建时间"` | 11 | CreatedAt time.Time `comment:"创建时间"` |
| 12 | UpdatedAt time.Time `comment:"更新时间"` | 12 | UpdatedAt time.Time `comment:"更新时间"` |
| 13 | - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | 13 | + DeletedAt *time.Time `comment:"删除时间"` |
| 14 | } | 14 | } |
| @@ -125,7 +125,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 | @@ -125,7 +125,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 | ||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | if userIds, ok := queryOptions["userIds"]; ok { | 127 | if userIds, ok := queryOptions["userIds"]; ok { |
| 128 | - query.Where("user_id in (?)", userIds) | 128 | + query.Where("user_id in (?)", pg.In(userIds)) |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | if v, ok := queryOptions["limit"].(int); ok { | 131 | if v, ok := queryOptions["limit"].(int); ok { |
| @@ -182,7 +182,7 @@ func (repo *RoleUserRepository) BatchDeleteById(ids []int64) error { | @@ -182,7 +182,7 @@ func (repo *RoleUserRepository) BatchDeleteById(ids []int64) error { | ||
| 182 | return err | 182 | return err |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | -func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int, companyId int64, roleId int64) ([]*domain.RoleContainUser, error) { | 185 | +func (repo *RoleUserRepository) FindAllContainUser(pageNumber int, pageSize int, companyId int64, roleId int64) ([]*domain.RoleContainUser, error) { |
| 186 | limit := pageSize | 186 | limit := pageSize |
| 187 | offset := limit * (pageNumber - 1) | 187 | offset := limit * (pageNumber - 1) |
| 188 | if offset < 0 { | 188 | if offset < 0 { |
| @@ -192,7 +192,7 @@ func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int, | @@ -192,7 +192,7 @@ func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int, | ||
| 192 | "role_user".role_id, | 192 | "role_user".role_id, |
| 193 | "role_user".user_id, | 193 | "role_user".user_id, |
| 194 | "user".name as user_name, | 194 | "user".name as user_name, |
| 195 | - "user".email as user_email, | 195 | + "user".email as user_email |
| 196 | ` | 196 | ` |
| 197 | whereFrom := ` | 197 | whereFrom := ` |
| 198 | FROM "role_user" | 198 | FROM "role_user" |
| @@ -21,8 +21,6 @@ func (controller *RuleController) CreateRule() { | @@ -21,8 +21,6 @@ func (controller *RuleController) CreateRule() { | ||
| 21 | ua := middlewares.GetUser(controller.Ctx) | 21 | ua := middlewares.GetUser(controller.Ctx) |
| 22 | in.CompanyId = ua.CompanyId | 22 | in.CompanyId = ua.CompanyId |
| 23 | in.CreatorId = ua.UserId | 23 | in.CreatorId = ua.UserId |
| 24 | - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 25 | - //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 26 | controller.Response(ruService.Create(in)) | 24 | controller.Response(ruService.Create(in)) |
| 27 | } | 25 | } |
| 28 | } | 26 | } |
| @@ -35,9 +33,6 @@ func (controller *RuleController) UpdateRule() { | @@ -35,9 +33,6 @@ func (controller *RuleController) UpdateRule() { | ||
| 35 | } else { | 33 | } else { |
| 36 | ua := middlewares.GetUser(controller.Ctx) | 34 | ua := middlewares.GetUser(controller.Ctx) |
| 37 | in.CompanyId = ua.CompanyId | 35 | in.CompanyId = ua.CompanyId |
| 38 | - in.CreatorId = ua.UserId | ||
| 39 | - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 40 | - //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 41 | controller.Response(ruService.Update(in)) | 36 | controller.Response(ruService.Update(in)) |
| 42 | } | 37 | } |
| 43 | } | 38 | } |
| @@ -12,7 +12,7 @@ type RoleController struct { | @@ -12,7 +12,7 @@ type RoleController struct { | ||
| 12 | beego.BaseController | 12 | beego.BaseController |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -//func (controller *RoleController) CreateRole() { | 15 | +// func (controller *RoleController) CreateRole() { |
| 16 | // ruService := service.NewRoleService() | 16 | // ruService := service.NewRoleService() |
| 17 | // in := &command.CreateRoleCommand{} | 17 | // in := &command.CreateRoleCommand{} |
| 18 | // if err := controller.Unmarshal(in); err != nil { | 18 | // if err := controller.Unmarshal(in); err != nil { |
| @@ -21,9 +21,9 @@ type RoleController struct { | @@ -21,9 +21,9 @@ type RoleController struct { | ||
| 21 | // in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 21 | // in.CompanyId = middlewares.GetCompanyId(controller.Ctx) |
| 22 | // controller.Response(ruService.Create(in)) | 22 | // controller.Response(ruService.Create(in)) |
| 23 | // } | 23 | // } |
| 24 | -//} | 24 | +// } |
| 25 | // | 25 | // |
| 26 | -//func (controller *RoleController) UpdateRole() { | 26 | +// func (controller *RoleController) UpdateRole() { |
| 27 | // ruService := service.NewRoleService() | 27 | // ruService := service.NewRoleService() |
| 28 | // in := &command.UpdateRoleCommand{} | 28 | // in := &command.UpdateRoleCommand{} |
| 29 | // if err := controller.Unmarshal(in); err != nil { | 29 | // if err := controller.Unmarshal(in); err != nil { |
| @@ -32,18 +32,18 @@ type RoleController struct { | @@ -32,18 +32,18 @@ type RoleController struct { | ||
| 32 | // in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 32 | // in.CompanyId = middlewares.GetCompanyId(controller.Ctx) |
| 33 | // controller.Response(ruService.Update(in)) | 33 | // controller.Response(ruService.Update(in)) |
| 34 | // } | 34 | // } |
| 35 | -//} | ||
| 36 | -// | ||
| 37 | -//func (controller *RoleController) RemoveRole() { | ||
| 38 | -// ruService := service.NewRoleService() | ||
| 39 | -// in := &command.DeleteRoleCommand{} | ||
| 40 | -// if err := controller.Unmarshal(in); err != nil { | ||
| 41 | -// controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 42 | -// } else { | ||
| 43 | -// in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 44 | -// controller.Response(ruService.Remove(in)) | ||
| 45 | // } | 35 | // } |
| 46 | -//} | 36 | +func (controller *RoleController) RemoveRole() { |
| 37 | + ruService := service.NewRoleService() | ||
| 38 | + in := &command.DeleteRoleCommand{} | ||
| 39 | + if err := controller.Unmarshal(in); err != nil { | ||
| 40 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 41 | + } else { | ||
| 42 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 43 | + in.CompanyId = ua.CompanyId | ||
| 44 | + controller.Response(ruService.Remove(in)) | ||
| 45 | + } | ||
| 46 | +} | ||
| 47 | 47 | ||
| 48 | func (controller *RoleController) ListForUserRole() { | 48 | func (controller *RoleController) ListForUserRole() { |
| 49 | ruService := service.NewRoleService() | 49 | ruService := service.NewRoleService() |
| @@ -53,7 +53,6 @@ func (controller *RoleController) ListForUserRole() { | @@ -53,7 +53,6 @@ func (controller *RoleController) ListForUserRole() { | ||
| 53 | } else { | 53 | } else { |
| 54 | ua := middlewares.GetUser(controller.Ctx) | 54 | ua := middlewares.GetUser(controller.Ctx) |
| 55 | in.CompanyId = ua.CompanyId | 55 | in.CompanyId = ua.CompanyId |
| 56 | - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 57 | controller.Response(ruService.ListForUser(in)) | 56 | controller.Response(ruService.ListForUser(in)) |
| 58 | } | 57 | } |
| 59 | } | 58 | } |
| @@ -12,7 +12,7 @@ func init() { | @@ -12,7 +12,7 @@ func init() { | ||
| 12 | web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | 12 | web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
| 13 | //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), | 13 | //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), |
| 14 | //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), | 14 | //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), |
| 15 | - //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), | 15 | + web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), |
| 16 | //web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"), | 16 | //web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"), |
| 17 | web.NSRouter("/all", &controllers.RoleController{}, "Post:ListForUserRole"), | 17 | web.NSRouter("/all", &controllers.RoleController{}, "Post:ListForUserRole"), |
| 18 | ) | 18 | ) |
-
请 注册 或 登录 后发表评论