作者 郑周

增加项目模型数据!~

  1 +package adapter
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  5 + "strconv"
  6 +)
  7 +
  8 +type UserAdapter struct {
  9 + Id int64 `json:"id,string" comment:"用户Id"`
  10 + Name string `json:"name" comment:"用户名称"`
  11 +}
  12 +
  13 +type EvaluationProjectAdapter struct {
  14 + *domain.EvaluationProject
  15 + RecipientList []*UserAdapter `json:"recipientList" comment:"被评估人"`
  16 + PmpList []*UserAdapter `json:"pmpList" comment:"项目管理员"`
  17 +}
  18 +
  19 +func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User) {
  20 + for i := range recipients {
  21 + adapter.RecipientList = append(adapter.RecipientList, &UserAdapter{
  22 + Id: recipients[i].Id,
  23 + Name: recipients[i].Name,
  24 + })
  25 + }
  26 +}
  27 +
  28 +func (adapter *EvaluationProjectAdapter) TransformPmpAdapter(pms []*domain.User) {
  29 + for i := range pms {
  30 + adapter.PmpList = append(adapter.PmpList, &UserAdapter{
  31 + Id: pms[i].Id,
  32 + Name: pms[i].Name,
  33 + })
  34 + }
  35 +}
  36 +
  37 +func TransformProjectListAdapter(projects []*domain.EvaluationProject, users []*domain.User) []*EvaluationProjectAdapter {
  38 + pmpUserMap := map[int64]*domain.User{}
  39 + for i := range users {
  40 + pmpUserMap[users[i].Id] = users[i]
  41 + }
  42 +
  43 + projectAdapters := make([]*EvaluationProjectAdapter, 0)
  44 + for i := range projects {
  45 + project := projects[i]
  46 +
  47 + epa := &EvaluationProjectAdapter{}
  48 + epa.EvaluationProject = project
  49 + projectAdapters = append(projectAdapters, epa)
  50 +
  51 + for j := range project.PmpIds {
  52 + userId, _ := strconv.ParseInt(project.PmpIds[j], 10, 64)
  53 + if v, ok := pmpUserMap[userId]; ok {
  54 + epa.PmpList = append(epa.PmpList, &UserAdapter{
  55 + Id: v.Id,
  56 + Name: v.Name,
  57 + })
  58 + }
  59 + }
  60 + }
  61 + return projectAdapters
  62 +}
  1 +package command
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/core/validation"
  5 +)
  6 +
  7 +type CreateProjectCommand struct {
  8 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  9 + CreatorId int64 `cname:"创建人ID" json:"creatorId"`
  10 + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  11 + Name string `cname:"项目名称" json:"name" valid:"Required"`
  12 + Describe string `cname:"项目描述" json:"describe" valid:"Required"`
  13 + HrBp int `cname:"HR角色权限" json:"hrBp"`
  14 + Pmp int `cname:"PM角色权限" json:"pmp"`
  15 + PmpIds []string `cname:"项目管理员ID" json:"pms"`
  16 +}
  17 +
  18 +func (in *CreateProjectCommand) Valid(validation *validation.Validation) {
  19 + if in.CompanyId == 0 {
  20 + validation.SetError("companyId", "公司ID无效")
  21 + return
  22 + }
  23 + if in.CreatorId == 0 {
  24 + validation.SetError("creatorId", "创建人ID无效")
  25 + return
  26 + }
  27 + if len(in.Name) > 40 {
  28 + validation.SetError("name", "角色名称最大长度40个字符")
  29 + return
  30 + }
  31 +}
  1 +package command
  2 +
  3 +import "github.com/beego/beego/v2/core/validation"
  4 +
  5 +type DeleteProjectCommand struct {
  6 + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
  7 +}
  8 +
  9 +func (in *DeleteProjectCommand) Valid(*validation.Validation) {
  10 +
  11 +}
  1 +package command
  2 +
  3 +import "github.com/beego/beego/v2/core/validation"
  4 +
  5 +type GetProjectCommand struct {
  6 + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
  7 +}
  8 +
  9 +func (in *GetProjectCommand) Valid(*validation.Validation) {
  10 +
  11 +}
  1 +package command
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/core/validation"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  6 +)
  7 +
  8 +type StateProjectCommand struct {
  9 + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"`
  10 + State int `cname:"模板状态" json:"state"`
  11 +}
  12 +
  13 +type CopyProjectCommand struct {
  14 + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"`
  15 +}
  16 +
  17 +func (in *StateProjectCommand) Valid(validation *validation.Validation) {
  18 + switch in.State {
  19 + case domain.ProjectStateWaitConfig, domain.ProjectStateWaitActive, domain.ProjectStateEnable, domain.ProjectStateDisable:
  20 + default:
  21 + validation.SetError("state", "状态设置错误")
  22 + return
  23 + }
  24 +}
  25 +
  26 +func (in *CopyProjectCommand) Valid(*validation.Validation) {
  27 +
  28 +}
  1 +package command
  2 +
  3 +import "github.com/beego/beego/v2/core/validation"
  4 +
  5 +type QueryProjectCommand struct {
  6 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  7 + CycleId int64 `cname:"周期ID" json:"cycleId,string"`
  8 + Name string `cname:"项目名称" json:"name"`
  9 + State int `cname:"项目状态" json:"state"`
  10 + PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
  11 + PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
  12 +}
  13 +
  14 +func (in *QueryProjectCommand) Valid(validation *validation.Validation) {
  15 + if in.CompanyId == 0 {
  16 + validation.SetError("companyId", "公司ID无效")
  17 + return
  18 + }
  19 +}
  1 +package command
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/core/validation"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  6 +)
  7 +
  8 +type UpdateProjectCommand struct {
  9 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  10 + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  11 + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
  12 + Name string `cname:"项目名称" json:"name" valid:"Required"`
  13 + Describe string `cname:"项目描述" json:"describe" valid:"Required"`
  14 + HrBp int `cname:"HR角色权限" json:"hrBp"`
  15 + Pmp int `cname:"PM角色权限" json:"pmp"`
  16 + PmpIds []string `cname:"项目管理员ID" json:"pms"`
  17 +}
  18 +
  19 +type UpdateProjectTemplateCommand struct {
  20 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  21 + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  22 + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
  23 + TemplateId int64 `cname:"评估模板ID" json:"templateId,string"`
  24 + Recipients []string `cname:"被评估人ID" json:"recipients"`
  25 +}
  26 +
  27 +type UpdateProjectTemplateNodeCommand struct {
  28 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  29 + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  30 + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
  31 + TemplateId int64 `cname:"评估模板ID" json:"templateId,string"`
  32 + LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"`
  33 + Activate int `cname:"启动项目" json:"activate"`
  34 +}
  35 +
  36 +func (in *UpdateProjectCommand) Valid(validation *validation.Validation) {
  37 + if len(in.Name) > 40 {
  38 + validation.SetError("name", "角色名称最大长度40个字符")
  39 + return
  40 + }
  41 +}
  42 +
  43 +func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) {
  44 + if len(in.Recipients) == 0 {
  45 + validation.SetError("recipients", "请选择被评估人")
  46 + return
  47 + }
  48 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/utils/tool_funs"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
  11 + "strconv"
  12 +)
  13 +
  14 +type EvaluationProjectService struct {
  15 +}
  16 +
  17 +func NewEvaluationProjectService() *EvaluationProjectService {
  18 + newRoleService := &EvaluationProjectService{}
  19 + return newRoleService
  20 +}
  21 +
  22 +// Create 创建
  23 +func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (interface{}, error) {
  24 + transactionContext, err := factory.ValidateStartTransaction(in)
  25 + if err != nil {
  26 + return nil, err
  27 + }
  28 + defer func() {
  29 + transactionContext.RollbackTransaction()
  30 + }()
  31 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  32 +
  33 + // 检测名称重复
  34 + count, err := projectRepository.Count(map[string]interface{}{"name": in.Name, "cycleId": in.CycleId, "companyId": in.CompanyId})
  35 + if err != nil {
  36 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  37 + }
  38 + if count > 0 {
  39 + return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在")
  40 + }
  41 +
  42 + newProject := &domain.EvaluationProject{
  43 + Id: 0,
  44 + Name: in.Name,
  45 + Describe: in.Describe,
  46 + CompanyId: in.CompanyId,
  47 + CreatorId: in.CreatorId,
  48 + State: domain.ProjectStateWaitConfig,
  49 + HrBp: in.HrBp,
  50 + Pmp: in.Pmp,
  51 + PmpIds: in.PmpIds,
  52 + }
  53 + project, err := projectRepository.Insert(newProject)
  54 + if err != nil {
  55 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  56 + }
  57 + if err := transactionContext.CommitTransaction(); err != nil {
  58 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  59 + }
  60 + return project, nil
  61 +
  62 +}
  63 +
  64 +func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (interface{}, error) {
  65 + transactionContext, err := factory.ValidateStartTransaction(in)
  66 + if err != nil {
  67 + return nil, err
  68 + }
  69 + defer func() {
  70 + transactionContext.RollbackTransaction()
  71 + }()
  72 +
  73 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  74 +
  75 + // 检测名称重复(排除自己)
  76 + count, err := projectRepository.Count(map[string]interface{}{"name": in.Name, "cycleId": in.CycleId, "companyId": in.CompanyId, "notId": in.Id})
  77 + if err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + }
  80 + if count > 0 {
  81 + return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在")
  82 + }
  83 +
  84 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  85 + if err != nil {
  86 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  87 + }
  88 + project.Name = in.Name
  89 + project.Describe = in.Describe
  90 + project.HrBp = in.HrBp
  91 + project.Pmp = in.Pmp
  92 + project.PmpIds = in.PmpIds
  93 +
  94 + project, err = projectRepository.Insert(project)
  95 + if err != nil {
  96 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  97 + }
  98 + if err := transactionContext.CommitTransaction(); err != nil {
  99 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  100 + }
  101 + return project, nil
  102 +}
  103 +
  104 +func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) {
  105 + transactionContext, err := factory.ValidateStartTransaction(in)
  106 + if err != nil {
  107 + return nil, err
  108 + }
  109 + defer func() {
  110 + transactionContext.RollbackTransaction()
  111 + }()
  112 +
  113 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  114 + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
  115 +
  116 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  117 + if err != nil {
  118 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  119 + }
  120 + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true})
  121 + if err != nil {
  122 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  123 + }
  124 +
  125 + project.Recipients = in.Recipients
  126 + project.Template = cycleTemplate.Template
  127 +
  128 + project, err = projectRepository.Insert(project)
  129 + if err != nil {
  130 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  131 + }
  132 + if err := transactionContext.CommitTransaction(); err != nil {
  133 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  134 + }
  135 + return project, nil
  136 +}
  137 +
  138 +func (rs *EvaluationProjectService) UpdateTemplateNode(in *command.UpdateProjectTemplateNodeCommand) (interface{}, error) {
  139 + transactionContext, err := factory.ValidateStartTransaction(in)
  140 + if err != nil {
  141 + return nil, err
  142 + }
  143 + defer func() {
  144 + transactionContext.RollbackTransaction()
  145 + }()
  146 +
  147 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  148 +
  149 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  150 + if err != nil {
  151 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  152 + }
  153 +
  154 + // FIXME 启动时,需要激活定时任务
  155 + if in.Activate == 1 {
  156 + project.State = domain.ProjectStateEnable
  157 + }
  158 + for i := range in.LinkNodes {
  159 + project.Template.LinkNodes[i].TimeStart = in.LinkNodes[i].TimeStart
  160 + project.Template.LinkNodes[i].TimeEnd = in.LinkNodes[i].TimeEnd
  161 + project.Template.LinkNodes[i].KpiCycle = in.LinkNodes[i].KpiCycle
  162 + }
  163 +
  164 + project, err = projectRepository.Insert(project)
  165 + if err != nil {
  166 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  167 + }
  168 + if err := transactionContext.CommitTransaction(); err != nil {
  169 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  170 + }
  171 + return project, nil
  172 +}
  173 +
  174 +func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interface{}, error) {
  175 + // Get 不需要事务
  176 + if err := utils.ValidateCommand(in); err != nil {
  177 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  178 + }
  179 + transactionContext, err := factory.CreateTransactionContext(nil)
  180 + if err != nil {
  181 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  182 + }
  183 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  184 +
  185 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  186 + if err != nil {
  187 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  188 + }
  189 +
  190 + projectAdapter := &adapter.EvaluationProjectAdapter{}
  191 + projectAdapter.EvaluationProject = project
  192 +
  193 + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  194 + if len(project.PmpIds) > 0 {
  195 + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)})
  196 + projectAdapter.TransformPmpAdapter(users)
  197 + }
  198 +
  199 + if len(project.Recipients) > 0 {
  200 + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.Recipients, "limit": len(project.Recipients)})
  201 + projectAdapter.TransformRecipientAdapter(users)
  202 + }
  203 +
  204 + return projectAdapter, nil
  205 +}
  206 +
  207 +func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (interface{}, error) {
  208 + transactionContext, err := factory.ValidateStartTransaction(in)
  209 + if err != nil {
  210 + return nil, err
  211 + }
  212 + defer func() {
  213 + transactionContext.RollbackTransaction()
  214 + }()
  215 +
  216 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  217 +
  218 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  219 + if err != nil {
  220 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  221 + }
  222 + if _, err := projectRepository.Remove(project); err != nil {
  223 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  224 + }
  225 +
  226 + if err := transactionContext.CommitTransaction(); err != nil {
  227 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  228 + }
  229 + return project, nil
  230 +}
  231 +
  232 +func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (interface{}, error) {
  233 + transactionContext, err := factory.StartTransaction()
  234 + if err != nil {
  235 + return nil, err
  236 + }
  237 + defer func() {
  238 + transactionContext.RollbackTransaction()
  239 + }()
  240 +
  241 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  242 + // FIXME 总数量是否使用Count获取一个总数量
  243 + count, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
  244 + if err != nil {
  245 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  246 + }
  247 + pmpUsers := make([]*domain.User, 0)
  248 + pmpUserIds := make([]int64, 0)
  249 + for i := range projects {
  250 + project := projects[i]
  251 + for j := range project.PmpIds {
  252 + userId, _ := strconv.ParseInt(project.PmpIds[j], 10, 64)
  253 + pmpUserIds = append(pmpUserIds, userId)
  254 + }
  255 + }
  256 + if len(pmpUserIds) > 0 {
  257 + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  258 + _, users, _ := userRepository.Find(map[string]interface{}{"ids": pmpUserIds, "limit": len(pmpUserIds)})
  259 + pmpUsers = users
  260 + }
  261 + projectAdapters := adapter.TransformProjectListAdapter(projects, pmpUsers)
  262 + return tool_funs.SimpleWrapGridMap(count, projectAdapters), nil
  263 +}
  264 +
  265 +func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (interface{}, error) {
  266 + transactionContext, err := factory.ValidateStartTransaction(in)
  267 + if err != nil {
  268 + return nil, err
  269 + }
  270 + defer func() {
  271 + transactionContext.RollbackTransaction()
  272 + }()
  273 +
  274 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  275 +
  276 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  277 + if err != nil {
  278 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  279 + }
  280 +
  281 + project.State = in.State
  282 + project, err = projectRepository.Insert(project)
  283 + if err != nil {
  284 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  285 + }
  286 + if err := transactionContext.CommitTransaction(); err != nil {
  287 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  288 + }
  289 + return project, nil
  290 +}
  291 +
  292 +func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) {
  293 + transactionContext, err := factory.ValidateStartTransaction(in)
  294 + if err != nil {
  295 + return nil, err
  296 + }
  297 + defer func() {
  298 + transactionContext.RollbackTransaction()
  299 + }()
  300 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  301 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  302 + if err != nil {
  303 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  304 + }
  305 + // ID重置
  306 + project.Id = 0
  307 + // 如果拷贝已经启用的模板,默认先设置为待启用
  308 + if project.State == domain.ProjectStateEnable {
  309 + project.State = domain.ProjectStateWaitActive
  310 + }
  311 + project, err = projectRepository.Insert(project)
  312 + if err != nil {
  313 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  314 + }
  315 + if err := transactionContext.CommitTransaction(); err != nil {
  316 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  317 + }
  318 + return project, nil
  319 +}
@@ -150,12 +150,8 @@ func (rs *EvaluationRuleService) List(in *command.QueryRuleCommand) (interface{} @@ -150,12 +150,8 @@ func (rs *EvaluationRuleService) List(in *command.QueryRuleCommand) (interface{}
150 transactionContext.RollbackTransaction() 150 transactionContext.RollbackTransaction()
151 }() 151 }()
152 ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) 152 ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
153 - inMap := tool_funs.SimpleStructToMap(in)  
154 - if len(in.NameOrRemark) > 0 {  
155 - inMap["nameOrRemark"] = "%" + in.NameOrRemark + "%"  
156 - }  
157 // FIXME 总数量是否使用Count获取一个总数量 153 // FIXME 总数量是否使用Count获取一个总数量
158 - count, rules, err := ruleRepository.Find(inMap) 154 + count, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))
159 if err != nil { 155 if err != nil {
160 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 156 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
161 } 157 }
@@ -8,7 +8,6 @@ import ( @@ -8,7 +8,6 @@ import (
8 type UpdateTemplateCommand struct { 8 type UpdateTemplateCommand 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 Describe string `cname:"模板描述" json:"remark"` 12 Describe string `cname:"模板描述" json:"remark"`
14 LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` 13 LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"`
@@ -19,10 +18,6 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { @@ -19,10 +18,6 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) {
19 validation.SetError("companyId", "公司ID无效") 18 validation.SetError("companyId", "公司ID无效")
20 return 19 return
21 } 20 }
22 - if in.CreatorId == 0 {  
23 - validation.SetError("creatorId", "创建人ID无效")  
24 - return  
25 - }  
26 21
27 if len(in.Name) > 40 { 22 if len(in.Name) > 40 {
28 validation.SetError("name", "模板名称最大长度40个字符") 23 validation.SetError("name", "模板名称最大长度40个字符")
@@ -26,10 +26,10 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( @@ -26,10 +26,10 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) (
26 defer func() { 26 defer func() {
27 transactionContext.RollbackTransaction() 27 transactionContext.RollbackTransaction()
28 }() 28 }()
29 - ruleRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) 29 + templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
30 30
31 // 检测名称重复 31 // 检测名称重复
32 - count, err := ruleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) 32 + count, err := templateRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId})
33 if err != nil { 33 if err != nil {
34 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 34 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
35 } 35 }
@@ -73,14 +73,14 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( @@ -73,14 +73,14 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) (
73 State: domain.TemplateStateWaitConfig, 73 State: domain.TemplateStateWaitConfig,
74 LinkNodes: linkNodes, 74 LinkNodes: linkNodes,
75 } 75 }
76 - rule, err := ruleRepository.Insert(newTemplate) 76 + template, err := templateRepository.Insert(newTemplate)
77 if err != nil { 77 if err != nil {
78 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 78 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
79 } 79 }
80 if err := transactionContext.CommitTransaction(); err != nil { 80 if err := transactionContext.CommitTransaction(); err != nil {
81 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 81 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
82 } 82 }
83 - return rule, nil 83 + return template, nil
84 84
85 } 85 }
86 86
@@ -175,12 +175,8 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int @@ -175,12 +175,8 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
175 }() 175 }()
176 templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) 176 templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
177 177
178 - inMap := tool_funs.SimpleStructToMap(in)  
179 - if len(in.Name) > 0 {  
180 - inMap["name"] = "%" + in.Name + "%"  
181 - }  
182 // FIXME 总数量是否使用Count获取一个总数量 178 // FIXME 总数量是否使用Count获取一个总数量
183 - count, templates, err := templateRepository.Find(inMap, "linkNodes") 179 + count, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
184 if err != nil { 180 if err != nil {
185 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 181 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
186 } 182 }
@@ -4,14 +4,23 @@ import ( @@ -4,14 +4,23 @@ import (
4 "time" 4 "time"
5 ) 5 )
6 6
  7 +const (
  8 + ProjectStateWaitConfig int = 0 // 项目状态-待完成配置
  9 + ProjectStateWaitActive int = 1 // 项目状态-待启用
  10 + ProjectStateEnable int = 2 // 项目状态-启用
  11 + ProjectStateDisable int = 3 // 项目状态-停用
  12 +)
  13 +
7 type EvaluationProject struct { 14 type EvaluationProject struct {
8 Id int64 `json:"id,string" comment:"ID"` 15 Id int64 `json:"id,string" comment:"ID"`
9 Name string `json:"name" comment:"名称"` 16 Name string `json:"name" comment:"名称"`
10 Describe string `json:"describe" comment:"描述"` 17 Describe string `json:"describe" comment:"描述"`
11 CompanyId int64 `json:"companyId,string" comment:"公司ID"` 18 CompanyId int64 `json:"companyId,string" comment:"公司ID"`
12 CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` 19 CreatorId int64 `json:"creatorId,string" comment:"创建人ID"`
  20 + State int `json:"state" comment:"状态(0待完成配置、1待启用、2启用、3结束)"`
13 HrBp int `json:"hrBp" comment:"HR角色权限"` 21 HrBp int `json:"hrBp" comment:"HR角色权限"`
14 - Pms []string `json:"pms" comment:"项目管理员ID"` 22 + Pmp int `json:"pmp" comment:"PM角色权限"`
  23 + PmpIds []string `json:"pmpIds" comment:"项目管理员ID"`
15 Recipients []string `json:"recipients" comment:"被评估人ID"` 24 Recipients []string `json:"recipients" comment:"被评估人ID"`
16 Template *EvaluationTemplate `json:"template" comment:"评估模板"` 25 Template *EvaluationTemplate `json:"template" comment:"评估模板"`
17 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 26 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
@@ -23,6 +32,6 @@ type EvaluationProjectRepository interface { @@ -23,6 +32,6 @@ type EvaluationProjectRepository interface {
23 Insert(project *EvaluationProject) (*EvaluationProject, error) 32 Insert(project *EvaluationProject) (*EvaluationProject, error)
24 Remove(project *EvaluationProject) (*EvaluationProject, error) 33 Remove(project *EvaluationProject) (*EvaluationProject, error)
25 FindOne(queryOptions map[string]interface{}) (*EvaluationProject, error) 34 FindOne(queryOptions map[string]interface{}) (*EvaluationProject, error)
26 - Find(queryOptions map[string]interface{}) (int64, []*EvaluationProject, error) 35 + Find(queryOptions map[string]interface{}, excludeColumns ...string) (int64, []*EvaluationProject, error)
27 Count(queryOptions map[string]interface{}) (int64, error) 36 Count(queryOptions map[string]interface{}) (int64, error)
28 } 37 }
@@ -37,12 +37,12 @@ type EntryItem struct { @@ -37,12 +37,12 @@ type EntryItem struct {
37 37
38 // NodeContent 评估内容 38 // NodeContent 评估内容
39 type NodeContent struct { 39 type NodeContent struct {
40 - Category string `json:"category" comment:"类别"`  
41 - Name string `json:"name" comment:"名称"`  
42 - RuleId int64 `json:"ruleId" comment:"评估规则ID"`  
43 - PromptTitle string `json:"promptTitle" comment:"提示项标题"`  
44 - PromptText string `json:"promptText" comment:"提示项正文"`  
45 - EntryItems []EntryItem `json:"entryItems" comment:"填写项"` 40 + Category string `json:"category" comment:"类别"`
  41 + Name string `json:"name" comment:"名称"`
  42 + RuleId int64 `json:"ruleId" comment:"评估规则ID"`
  43 + PromptTitle string `json:"promptTitle" comment:"提示项标题"`
  44 + PromptText string `json:"promptText" comment:"提示项正文"`
  45 + EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`
46 } 46 }
47 47
48 // NodeAllInvite 360°邀请 48 // NodeAllInvite 360°邀请
@@ -57,7 +57,7 @@ type LinkNode struct { @@ -57,7 +57,7 @@ type LinkNode struct {
57 Type int `json:"type" comment:"环节类型(1评估、2邀请、3绩效结果)"` 57 Type int `json:"type" comment:"环节类型(1评估、2邀请、3绩效结果)"`
58 Name string `json:"name" comment:"环节名称"` 58 Name string `json:"name" comment:"环节名称"`
59 Describe string `json:"describe" comment:"环节描述"` 59 Describe string `json:"describe" comment:"环节描述"`
60 - NodeContents []NodeContent `json:"nodeContents" comment:"环节-评估内容"` 60 + NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"`
61 NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"环节-360°邀请"` 61 NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"环节-360°邀请"`
62 NodeKpiResult *NodeKpiResult `json:"nodeKpiResult" comment:"环节-绩效结果"` 62 NodeKpiResult *NodeKpiResult `json:"nodeKpiResult" comment:"环节-绩效结果"`
63 TimeStart *time.Time `json:"timeStart" comment:"起始时间"` 63 TimeStart *time.Time `json:"timeStart" comment:"起始时间"`
@@ -12,8 +12,10 @@ type EvaluationProject struct { @@ -12,8 +12,10 @@ type EvaluationProject struct {
12 Describe string `comment:"描述"` 12 Describe string `comment:"描述"`
13 CompanyId int64 `comment:"公司ID"` 13 CompanyId int64 `comment:"公司ID"`
14 CreatorId int64 `comment:"创建人ID"` 14 CreatorId int64 `comment:"创建人ID"`
  15 + State int `comment:"状态(0待完成配置、1待启用、2启用、3停用)"`
15 HrBp int `comment:"HR角色权限"` 16 HrBp int `comment:"HR角色权限"`
16 - Pms []string `comment:"项目管理员ID"` 17 + Pmp int `comment:"PM角色权限"`
  18 + PmpIds []string `comment:"项目管理员ID"`
17 Recipients []string `comment:"被评估人ID"` 19 Recipients []string `comment:"被评估人ID"`
18 Template *domain.EvaluationTemplate `comment:"评估模板"` 20 Template *domain.EvaluationTemplate `comment:"评估模板"`
19 CreatedAt time.Time `comment:"创建时间"` 21 CreatedAt time.Time `comment:"创建时间"`
@@ -27,8 +27,10 @@ func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationP @@ -27,8 +27,10 @@ func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationP
27 Describe: m.Describe, 27 Describe: m.Describe,
28 CompanyId: m.CompanyId, 28 CompanyId: m.CompanyId,
29 CreatorId: m.CreatorId, 29 CreatorId: m.CreatorId,
  30 + State: m.State,
30 HrBp: m.HrBp, 31 HrBp: m.HrBp,
31 - Pms: m.Pms, 32 + Pmp: m.Pmp,
  33 + PmpIds: m.PmpIds,
32 Recipients: m.Recipients, 34 Recipients: m.Recipients,
33 Template: m.Template, 35 Template: m.Template,
34 CreatedAt: m.CreatedAt, 36 CreatedAt: m.CreatedAt,
@@ -44,8 +46,10 @@ func (repo *EvaluationProjectRepository) TransformToModel(d *domain.EvaluationPr @@ -44,8 +46,10 @@ func (repo *EvaluationProjectRepository) TransformToModel(d *domain.EvaluationPr
44 Describe: d.Describe, 46 Describe: d.Describe,
45 CompanyId: d.CompanyId, 47 CompanyId: d.CompanyId,
46 CreatorId: d.CreatorId, 48 CreatorId: d.CreatorId,
  49 + State: d.State,
47 HrBp: d.HrBp, 50 HrBp: d.HrBp,
48 - Pms: d.Pms, 51 + Pmp: d.Pmp,
  52 + PmpIds: d.PmpIds,
49 Recipients: d.Recipients, 53 Recipients: d.Recipients,
50 Template: d.Template, 54 Template: d.Template,
51 CreatedAt: d.CreatedAt, 55 CreatedAt: d.CreatedAt,
@@ -116,11 +120,15 @@ func (repo *EvaluationProjectRepository) FindOne(queryOptions map[string]interfa @@ -116,11 +120,15 @@ func (repo *EvaluationProjectRepository) FindOne(queryOptions map[string]interfa
116 return &u, nil 120 return &u, nil
117 } 121 }
118 122
119 -func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.EvaluationProject, error) { 123 +func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{}, excludeColumns ...string) (int64, []*domain.EvaluationProject, error) {
120 tx := repo.transactionContext.PgTx 124 tx := repo.transactionContext.PgTx
121 var m []*models.EvaluationProject 125 var m []*models.EvaluationProject
122 query := tx.Model(&m).Where("deleted_at isnull") 126 query := tx.Model(&m).Where("deleted_at isnull")
123 127
  128 + if len(excludeColumns) > 0 {
  129 + query.ExcludeColumn(excludeColumns...)
  130 + }
  131 +
124 if v, ok := queryOptions["name"]; ok { 132 if v, ok := queryOptions["name"]; ok {
125 query.Where("name = ?", v) 133 query.Where("name = ?", v)
126 } 134 }
@@ -129,6 +137,14 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ @@ -129,6 +137,14 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
129 query.Where("company_id = ?", v) 137 query.Where("company_id = ?", v)
130 } 138 }
131 139
  140 + if v, ok := queryOptions["cycleId"]; ok {
  141 + query.Where("cycle_id = ?", v)
  142 + }
  143 +
  144 + if v, ok := queryOptions["state"]; ok && v.(int) >= 0 {
  145 + query.Where("state = ?", v)
  146 + }
  147 +
132 if v, ok := queryOptions["limit"].(int); ok { 148 if v, ok := queryOptions["limit"].(int); ok {
133 query.Limit(v) 149 query.Limit(v)
134 } 150 }
@@ -170,6 +186,10 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface @@ -170,6 +186,10 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface
170 query.Where("company_id = ?", v) 186 query.Where("company_id = ?", v)
171 } 187 }
172 188
  189 + if v, ok := queryOptions["cycleId"]; ok {
  190 + query.Where("cycle_id = ?", v)
  191 + }
  192 +
173 count, err := query.Count() 193 count, err := query.Count()
174 if err != nil { 194 if err != nil {
175 return 0, err 195 return 0, err
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  9 +)
  10 +
  11 +type CycleController struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +func (controller *RoleController) CreateCycle() {
  16 + ruService := service.NewEvaluationCycleService()
  17 + in := &command.CreateCycleCommand{}
  18 + if err := controller.Unmarshal(in); err != nil {
  19 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  20 + } else {
  21 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  22 + in.CreatorId = middlewares.GetUserId(controller.Ctx)
  23 + controller.Response(ruService.Create(in))
  24 + }
  25 +}
  26 +
  27 +func (controller *CycleController) UpdateCycle() {
  28 + ruService := service.NewEvaluationCycleService()
  29 + in := &command.UpdateCycleCommand{}
  30 + if err := controller.Unmarshal(in); err != nil {
  31 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  32 + } else {
  33 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  34 + controller.Response(ruService.Update(in))
  35 + }
  36 +}
  37 +
  38 +func (controller *CycleController) GetCycle() {
  39 + ruService := service.NewEvaluationCycleService()
  40 + in := &command.GetCycleCommand{}
  41 + if id, err := controller.GetInt64(":Id"); err != nil {
  42 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  43 + } else {
  44 + in.Id = id
  45 + controller.Response(ruService.Get(in))
  46 + }
  47 +}
  48 +
  49 +func (controller *CycleController) RemoveCycle() {
  50 + ruService := service.NewEvaluationCycleService()
  51 + in := &command.DeleteCycleCommand{}
  52 + if err := controller.Unmarshal(in); err != nil {
  53 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  54 + } else {
  55 + controller.Response(ruService.Remove(in))
  56 + }
  57 +}
  58 +
  59 +func (controller *CycleController) ListCycle() {
  60 + ruService := service.NewEvaluationCycleService()
  61 + in := &command.QueryCycleCommand{}
  62 + if err := controller.Unmarshal(in); err != nil {
  63 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  64 + } else {
  65 + if len(in.Name) > 0 {
  66 + in.Name = "%" + in.Name + "%"
  67 + }
  68 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  69 + controller.Response(ruService.List(in))
  70 + }
  71 +}
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  9 +)
  10 +
  11 +type ProjectController struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +func (controller *RoleController) CreateProject() {
  16 + ruService := service.NewEvaluationProjectService()
  17 + in := &command.CreateProjectCommand{}
  18 + if err := controller.Unmarshal(in); err != nil {
  19 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  20 + } else {
  21 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  22 + in.CreatorId = middlewares.GetUserId(controller.Ctx)
  23 + controller.Response(ruService.Create(in))
  24 + }
  25 +}
  26 +
  27 +func (controller *ProjectController) UpdateProject() {
  28 + ruService := service.NewEvaluationProjectService()
  29 + in := &command.UpdateProjectCommand{}
  30 + if err := controller.Unmarshal(in); err != nil {
  31 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  32 + } else {
  33 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  34 + controller.Response(ruService.Update(in))
  35 + }
  36 +}
  37 +
  38 +func (controller *ProjectController) UpdateProjectForTemplate() {
  39 + ruService := service.NewEvaluationProjectService()
  40 + in := &command.UpdateProjectTemplateCommand{}
  41 + if err := controller.Unmarshal(in); err != nil {
  42 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  43 + } else {
  44 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  45 + controller.Response(ruService.UpdateTemplate(in))
  46 + }
  47 +}
  48 +
  49 +func (controller *ProjectController) UpdateProjectForTemplateNode() {
  50 + ruService := service.NewEvaluationProjectService()
  51 + in := &command.UpdateProjectTemplateNodeCommand{}
  52 + if err := controller.Unmarshal(in); err != nil {
  53 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  54 + } else {
  55 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  56 + controller.Response(ruService.UpdateTemplateNode(in))
  57 + }
  58 +}
  59 +
  60 +func (controller *ProjectController) GetProject() {
  61 + ruService := service.NewEvaluationProjectService()
  62 + in := &command.GetProjectCommand{}
  63 + if id, err := controller.GetInt64(":Id"); err != nil {
  64 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  65 + } else {
  66 + in.Id = id
  67 + controller.Response(ruService.Get(in))
  68 + }
  69 +}
  70 +
  71 +func (controller *ProjectController) RemoveProject() {
  72 + ruService := service.NewEvaluationProjectService()
  73 + in := &command.DeleteProjectCommand{}
  74 + if err := controller.Unmarshal(in); err != nil {
  75 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  76 + } else {
  77 + controller.Response(ruService.Remove(in))
  78 + }
  79 +}
  80 +
  81 +func (controller *ProjectController) ListProject() {
  82 + ruService := service.NewEvaluationProjectService()
  83 + in := &command.QueryProjectCommand{}
  84 + in.State = -1 // 设置默认状态
  85 + if err := controller.Unmarshal(in); err != nil {
  86 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  87 + } else {
  88 + if len(in.Name) > 0 {
  89 + in.Name = "%" + in.Name + "%"
  90 + }
  91 + in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
  92 + controller.Response(ruService.List(in))
  93 + }
  94 +}
  95 +
  96 +func (controller *ProjectController) StateProject() {
  97 + ruService := service.NewEvaluationProjectService()
  98 + in := &command.StateProjectCommand{}
  99 + if err := controller.Unmarshal(in); err != nil {
  100 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  101 + } else {
  102 + controller.Response(ruService.State(in))
  103 + }
  104 +}
  105 +
  106 +func (controller *ProjectController) CopyProject() {
  107 + ruService := service.NewEvaluationProjectService()
  108 + in := &command.CopyProjectCommand{}
  109 + if err := controller.Unmarshal(in); err != nil {
  110 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  111 + } else {
  112 + controller.Response(ruService.Copy(in))
  113 + }
  114 +}
@@ -63,6 +63,9 @@ func (controller *RuleController) ListRule() { @@ -63,6 +63,9 @@ func (controller *RuleController) ListRule() {
63 if err := controller.Unmarshal(in); err != nil { 63 if err := controller.Unmarshal(in); err != nil {
64 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) 64 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
65 } else { 65 } else {
  66 + if len(in.NameOrRemark) > 0 {
  67 + in.NameOrRemark = "%" + in.NameOrRemark + "%"
  68 + }
66 in.CompanyId = middlewares.GetCompanyId(controller.Ctx) 69 in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
67 controller.Response(ruService.List(in)) 70 controller.Response(ruService.List(in))
68 } 71 }
@@ -31,7 +31,6 @@ func (controller *TemplateController) UpdateTemplate() { @@ -31,7 +31,6 @@ func (controller *TemplateController) UpdateTemplate() {
31 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) 31 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
32 } else { 32 } else {
33 in.CompanyId = middlewares.GetCompanyId(controller.Ctx) 33 in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
34 - in.CreatorId = middlewares.GetUserId(controller.Ctx)  
35 controller.Response(ruService.Update(in)) 34 controller.Response(ruService.Update(in))
36 } 35 }
37 } 36 }
@@ -63,6 +62,9 @@ func (controller *TemplateController) ListTemplate() { @@ -63,6 +62,9 @@ func (controller *TemplateController) ListTemplate() {
63 if err := controller.Unmarshal(in); err != nil { 62 if err := controller.Unmarshal(in); err != nil {
64 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) 63 controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
65 } else { 64 } else {
  65 + if len(in.Name) > 0 {
  66 + in.Name = "%" + in.Name + "%"
  67 + }
66 in.CompanyId = middlewares.GetCompanyId(controller.Ctx) 68 in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
67 controller.Response(ruService.List(in)) 69 controller.Response(ruService.List(in))
68 } 70 }