作者 郑周

1. 增加评估提交项 填写内容数据缓存

2. 获取【通用评估详情】和【自评详情】请求增加参数标记是否优先获取缓存
3. 通用评估数据提交后,删除缓存
4. 优化评估数据排序
@@ -168,3 +168,11 @@ func CreateStaffAssessContentTempRepository(options map[string]interface{}) doma @@ -168,3 +168,11 @@ func CreateStaffAssessContentTempRepository(options map[string]interface{}) doma
168 } 168 }
169 return repository.NewStaffAssessContentTempRepository(transactionContext) 169 return repository.NewStaffAssessContentTempRepository(transactionContext)
170 } 170 }
  171 +
  172 +func CreateStaffAssessCacheRepository(options map[string]interface{}) domain.StaffAssessCacheRepository {
  173 + var transactionContext *pg.TransactionContext
  174 + if value, ok := options["transactionContext"]; ok {
  175 + transactionContext = value.(*pg.TransactionContext)
  176 + }
  177 + return repository.NewStaffAssessCacheRepository(transactionContext)
  178 +}
  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 +// SaveAssessCacheCommand 保存待提交的评估数据(缓存)
  9 +type SaveAssessCacheCommand struct {
  10 + AssessId int64 `cname:"评估项ID" json:"assessId,string"`
  11 + AssessContent []domain.AssessContent `cname:"评估数据" json:"assessContent"`
  12 +}
  13 +
  14 +func (in *SaveAssessCacheCommand) Valid(validation *validation.Validation) {
  15 + if in.AssessId == 0 {
  16 + validation.SetError("assessId", "ID无效")
  17 + return
  18 + }
  19 +}
1 -package command  
2 -  
3 -//保存员工填写评估内容  
4 -type SaveAssessInfoCommand struct {  
5 - AssessId int `json:"assessId"` //  
6 - ExecutorId int `json:"executorId"` //填写人的id  
7 - CompanyId int `json:"companyId"` //公司id  
8 - AssessContent []AssesssContent `json:"assessContent"`  
9 -}  
10 -  
11 -type AssesssContent struct {  
12 - Category string `json:"category"`  
13 - Name string `json:"name"`  
14 - Value string `json:"value"`  
15 - Remark []RemarkText `json:"remark"`  
16 -}  
17 -  
18 -type RemarkText struct {  
19 - Title string `json:"title"`  
20 - RemarkText string `json:"remarkText"`  
21 -} 1 +package command
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  4 +
  5 +//保存员工填写评估内容
  6 +type SaveAssessInfoCommand struct {
  7 + AssessId int `json:"assessId"` //
  8 + ExecutorId int `json:"executorId"` //填写人的id
  9 + CompanyId int `json:"companyId"` //公司id
  10 + AssessContent []domain.AssessContent `json:"assessContent"`
  11 +}
  12 +
  13 +//type AssessContent struct {
  14 +// Category string `json:"category"`
  15 +// Name string `json:"name"`
  16 +// Value string `json:"value"`
  17 +// Remark []RemarkText `json:"remark"`
  18 +//}
  19 +//
  20 +//type RemarkText struct {
  21 +// Title string `json:"title"`
  22 +// RemarkText string `json:"remarkText"`
  23 +//}
1 -package query  
2 -  
3 -//获取评估任务详情  
4 -type AssessInfoQuery struct {  
5 - AssessId int `json:"assessId"` //  
6 - CompanyId int `json:"companyId"` //  
7 -} 1 +package query
  2 +
  3 +//获取评估任务详情
  4 +type AssessInfoQuery struct {
  5 + AssessId int `json:"assessId"` // 评估项ID
  6 + CompanyId int `json:"companyId"` // 公司ID
  7 + AcquireCache int `json:"acquireCache"` // 0不获取缓存数据,1获取缓存数据
  8 +}
1 -package query  
2 -  
3 -//获取员工自评填写详情  
4 -type AssessSelfInfoQuery struct {  
5 - AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id  
6 - TargetUserId int `json:"targetUserId,string"` //被评估的人id  
7 - CompanyId int `json:"companyId"` //公司id  
8 -  
9 -} 1 +package query
  2 +
  3 +//获取员工自评填写详情
  4 +type AssessSelfInfoQuery struct {
  5 + AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id
  6 + TargetUserId int `json:"targetUserId,string"` //被评估的人id
  7 + CompanyId int `json:"companyId"` //公司id
  8 + AcquireCache int `json:"acquireCache"` // 0不获取缓存数据,1获取缓存数据
  9 +}
@@ -6,4 +6,5 @@ type GetExecutorSelfAssessQuery struct { @@ -6,4 +6,5 @@ type GetExecutorSelfAssessQuery struct {
6 TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填 6 TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
7 CycleId int `json:"cycleId"` //评估周期id 必填 7 CycleId int `json:"cycleId"` //评估周期id 必填
8 BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02 8 BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
  9 + AcquireCache int `json:"acquireCache"` // 0不获取缓存数据,1获取缓存数据
9 } 10 }
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  8 +)
  9 +
  10 +// StaffAssessCacheService 保存待提交的评估数据(缓存)
  11 +type StaffAssessCacheService struct{}
  12 +
  13 +func NewStaffAssessCacheService() *StaffAssessCacheService {
  14 + newService := &StaffAssessCacheService{}
  15 + return newService
  16 +}
  17 +
  18 +func (srv StaffAssessCacheService) SaveAssessCache(in *command.SaveAssessCacheCommand) (map[string]interface{}, error) {
  19 + transactionContext, err := factory.ValidateStartTransaction(in)
  20 + if err != nil {
  21 + return nil, err
  22 + }
  23 + defer func() {
  24 + transactionContext.RollbackTransaction()
  25 + }()
  26 + cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": transactionContext})
  27 + _, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": in.AssessId, "limit": 1})
  28 + if err != nil {
  29 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  30 + }
  31 + var cache *domain.StaffAssessCache
  32 + if len(caches) == 0 {
  33 + cache = &domain.StaffAssessCache{}
  34 + cache.Id = 0
  35 + cache.AssessId = in.AssessId
  36 + cache.AssessContent = in.AssessContent
  37 + } else {
  38 + cache = caches[0]
  39 + cache.AssessContent = in.AssessContent
  40 + }
  41 + if _, err = cacheRepository.Save(cache); err != nil {
  42 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  43 + }
  44 + if err := transactionContext.CommitTransaction(); err != nil {
  45 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  46 + }
  47 + return map[string]interface{}{"assessId": cache.Id}, nil
  48 +}
@@ -971,6 +971,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer @@ -971,6 +971,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer
971 } 971 }
972 } 972 }
973 973
  974 + // 恢复缓存数据
  975 + if param.AcquireCache != 0 {
  976 + srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
  977 + }
  978 +
974 //获取员工描述 979 //获取员工描述
975 staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId)) 980 staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
976 if err := transactionContext.CommitTransaction(); err != nil { 981 if err := transactionContext.CommitTransaction(); err != nil {
@@ -1551,6 +1556,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada @@ -1551,6 +1556,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
1551 } 1556 }
1552 } 1557 }
1553 1558
  1559 + // 恢复缓存数据
  1560 + if param.AcquireCache != 0 {
  1561 + srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
  1562 + }
  1563 +
1554 targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId)) 1564 targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
1555 if err != nil { 1565 if err != nil {
1556 log.Logger.Error("获取员工描述" + err.Error()) 1566 log.Logger.Error("获取员工描述" + err.Error())
@@ -1713,7 +1723,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1713,7 +1723,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1713 } 1723 }
1714 } 1724 }
1715 //处理提交上来的数据 1725 //处理提交上来的数据
1716 - paramContentMap := map[string]command.AssesssContent{} 1726 + paramContentMap := map[string]domain.AssessContent{}
1717 for i, v := range param.AssessContent { 1727 for i, v := range param.AssessContent {
1718 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1728 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1719 paramContentMap[key] = param.AssessContent[i] 1729 paramContentMap[key] = param.AssessContent[i]
@@ -1726,7 +1736,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1726,7 +1736,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1726 continue 1736 continue
1727 } 1737 }
1728 v.Value = item.Value 1738 v.Value = item.Value
1729 - if v.Required == 1 { 1739 + if v.Required == domain.NodeRequiredYes {
1730 //转换填入的评估值 1740 //转换填入的评估值
1731 err = v.TransformValue() 1741 err = v.TransformValue()
1732 if err != nil { 1742 if err != nil {
@@ -1755,6 +1765,19 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1755,6 +1765,19 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1755 if err != nil { 1765 if err != nil {
1756 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) 1766 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
1757 } 1767 }
  1768 +
  1769 + // 删除缓存
  1770 + cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": transactionContext})
  1771 + if _, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessData.Id, "limit": 1}); err != nil {
  1772 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1773 + } else {
  1774 + for i := range caches {
  1775 + if err = cacheRepository.Remove(caches[i].Id); err != nil {
  1776 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1777 + }
  1778 + }
  1779 + }
  1780 +
1758 if err := transactionContext.CommitTransaction(); err != nil { 1781 if err := transactionContext.CommitTransaction(); err != nil {
1759 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1782 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1760 } 1783 }
@@ -1884,3 +1907,29 @@ loop: @@ -1884,3 +1907,29 @@ loop:
1884 } 1907 }
1885 return chargeUserList, nil 1908 return chargeUserList, nil
1886 } 1909 }
  1910 +
  1911 +func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) {
  1912 + cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": context})
  1913 + _, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessId, "limit": 1})
  1914 + if err != nil || len(caches) == 0 {
  1915 + return
  1916 + }
  1917 + cacheArray := caches[0].AssessContent
  1918 + cacheLen := len(cacheArray)
  1919 +
  1920 + for i := range dataArray {
  1921 + if cacheLen > i { // 避免数组越界
  1922 + data := dataArray[i]
  1923 + cache := cacheArray[i]
  1924 +
  1925 + data.Value = cache.Value // 评估填写的值
  1926 + cacheRemarkLen := len(cache.Remark)
  1927 +
  1928 + for j := range data.Remark {
  1929 + if cacheRemarkLen > j {
  1930 + data.Remark[j].RemarkText = cache.Remark[j].RemarkText // 评估填写文本内容
  1931 + }
  1932 + }
  1933 + }
  1934 + }
  1935 +}
@@ -661,6 +661,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA @@ -661,6 +661,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
661 } 661 }
662 } 662 }
663 663
  664 + // 恢复缓存数据
  665 + if param.AcquireCache != 0 {
  666 + srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
  667 + }
  668 +
664 //获取员工描述 669 //获取员工描述
665 staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId)) 670 staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
666 if err := transactionContext.CommitTransaction(); err != nil { 671 if err := transactionContext.CommitTransaction(); err != nil {
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// StaffAssessCache 填写评估数据(缓存暂未提交)
  6 +type StaffAssessCache struct {
  7 + Id int64 `json:"id,string" comment:"ID"`
  8 + AssessId int64 `json:"assessId,string" comment:"评估项ID"`
  9 + AssessContent []AssessContent `json:"assessContent" comment:"评估项提交数据"`
  10 + CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
  11 + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
  12 + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
  13 +}
  14 +
  15 +type AssessContent struct {
  16 + Category string `json:"category"`
  17 + Name string `json:"name"`
  18 + Value string `json:"value"`
  19 + Remark []RemarkText `json:"remark"`
  20 +}
  21 +
  22 +type RemarkText struct {
  23 + Title string `json:"title"`
  24 + RemarkText string `json:"remarkText"`
  25 +}
  26 +
  27 +type StaffAssessCacheRepository interface {
  28 + Save(param *StaffAssessCache) (*StaffAssessCache, error)
  29 + Remove(id int64) error
  30 + FindOne(queryOptions map[string]interface{}) (*StaffAssessCache, error)
  31 + Find(queryOptions map[string]interface{}) (int, []*StaffAssessCache, error)
  32 +}
@@ -93,6 +93,12 @@ func (content *StaffAssessContent) scoreValue() error { @@ -93,6 +93,12 @@ func (content *StaffAssessContent) scoreValue() error {
93 return errors.New("评分填写的值错误") 93 return errors.New("评分填写的值错误")
94 } 94 }
95 95
  96 +//type StaffAssessContentSort []*StaffAssessContent
  97 +//
  98 +//func (a StaffAssessContentSort) Len() int { return len(a) }
  99 +//func (a StaffAssessContentSort) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
  100 +//func (a StaffAssessContentSort) Less(i, j int) bool { return a[i].SortBy < a[j].SortBy }
  101 +
96 type StaffAssessContentRepository interface { 102 type StaffAssessContentRepository interface {
97 Save(param *StaffAssessContent) (*StaffAssessContent, error) 103 Save(param *StaffAssessContent) (*StaffAssessContent, error)
98 Remove(id int) error 104 Remove(id int) error
@@ -45,6 +45,7 @@ func init() { @@ -45,6 +45,7 @@ func init() {
45 &models.StaffAssess{}, 45 &models.StaffAssess{},
46 &models.StaffAssessTask{}, 46 &models.StaffAssessTask{},
47 &models.StaffAssessContent{}, 47 &models.StaffAssessContent{},
  48 + &models.StaffAssessCache{},
48 } 49 }
49 for _, model := range tables { 50 for _, model := range tables {
50 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 51 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
  1 +package models
  2 +
  3 +import (
  4 + "time"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +)
  8 +
  9 +// StaffAssessCache 提交评估项内容缓存
  10 +type StaffAssessCache struct {
  11 + tableName struct{} `comment:"评估项填写内容缓存" pg:"staff_assess_cache"`
  12 + Id int64 `comment:"ID" pg:",pk"`
  13 + AssessId int64 `comment:"评估项ID"`
  14 + AssessContent []domain.AssessContent `comment:"评估项提交数据"`
  15 + CreatedAt time.Time `comment:"创建时间"`
  16 + UpdatedAt time.Time `comment:"更新时间"`
  17 + DeletedAt *time.Time `comment:"删除时间"`
  18 +}
  1 +package repository
  2 +
  3 +import (
  4 + "errors"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
  7 + "time"
  8 +
  9 + "github.com/go-pg/pg/v10"
  10 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
  13 +)
  14 +
  15 +type StaffAssessCacheRepository struct {
  16 + transactionContext *pgTransaction.TransactionContext
  17 +}
  18 +
  19 +//var _ domain.StaffAssessCacheRepository = (*StaffAssessCacheRepository)(nil)
  20 +
  21 +func NewStaffAssessCacheRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessCacheRepository {
  22 + return &StaffAssessCacheRepository{transactionContext: transactionContext}
  23 +}
  24 +
  25 +func (repo *StaffAssessCacheRepository) TransformToDomain(m *models.StaffAssessCache) domain.StaffAssessCache {
  26 + return domain.StaffAssessCache{
  27 + Id: m.Id,
  28 + AssessId: m.AssessId,
  29 + AssessContent: m.AssessContent,
  30 + CreatedAt: m.CreatedAt,
  31 + UpdatedAt: m.UpdatedAt,
  32 + DeletedAt: m.DeletedAt,
  33 + }
  34 +}
  35 +
  36 +func (repo *StaffAssessCacheRepository) TransformToModel(d *domain.StaffAssessCache) models.StaffAssessCache {
  37 + return models.StaffAssessCache{
  38 + Id: d.Id,
  39 + AssessId: d.AssessId,
  40 + AssessContent: d.AssessContent,
  41 + CreatedAt: d.CreatedAt,
  42 + UpdatedAt: d.UpdatedAt,
  43 + DeletedAt: d.DeletedAt,
  44 + }
  45 +}
  46 +
  47 +func (repo *StaffAssessCacheRepository) nextIdentify() (int64, error) {
  48 + return utils.NewSnowflakeId()
  49 +}
  50 +
  51 +func (repo *StaffAssessCacheRepository) Save(d *domain.StaffAssessCache) (*domain.StaffAssessCache, error) {
  52 + var isCreate = d.Id == 0
  53 + if isCreate {
  54 + id, err := repo.nextIdentify()
  55 + if err != nil {
  56 + return d, err
  57 + }
  58 + d.Id = id
  59 + d.CreatedAt = time.Now()
  60 + d.UpdatedAt = d.CreatedAt
  61 + } else {
  62 + d.UpdatedAt = time.Now()
  63 + }
  64 + m := repo.TransformToModel(d)
  65 + tx := repo.transactionContext.PgTx
  66 + var err error
  67 + if isCreate {
  68 + _, err = tx.Model(&m).Returning("id").Insert()
  69 + } else {
  70 + _, err = tx.Model(&m).Returning("id").WherePK().Update() // 更新和删除必须增加条件
  71 + }
  72 + if err != nil {
  73 + return nil, err
  74 + }
  75 + d.Id = m.Id
  76 + return d, nil
  77 +}
  78 +
  79 +func (repo *StaffAssessCacheRepository) Remove(id int64) error {
  80 + tx := repo.transactionContext.PgTx
  81 + nowTime := time.Now()
  82 + _, err := tx.Model(&models.StaffAssessCache{}).Where("id=?", id).Set("deleted_at=?", nowTime).Update()
  83 + return err
  84 +}
  85 +
  86 +func (repo *StaffAssessCacheRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessCache, error) {
  87 + tx := repo.transactionContext.PgTx
  88 + m := new(models.StaffAssessCache)
  89 + query := tx.Model(m)
  90 + query.Where("deleted_at isnull")
  91 + if id, ok := queryOptions["id"]; ok {
  92 + query.Where("id=?", id)
  93 + }
  94 + if err := query.First(); err != nil {
  95 + if errors.Is(err, pg.ErrNoRows) {
  96 + return nil, fmt.Errorf("没有此资源")
  97 + } else {
  98 + return nil, err
  99 + }
  100 + }
  101 + u := repo.TransformToDomain(m)
  102 + return &u, nil
  103 +}
  104 +
  105 +func (repo *StaffAssessCacheRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessCache, error) {
  106 + tx := repo.transactionContext.PgTx
  107 + var m []*models.StaffAssessCache
  108 + query := tx.Model(&m).Where("deleted_at isnull")
  109 +
  110 + if v, ok := queryOptions["assessId"]; ok {
  111 + query.Where("assess_id=?", v)
  112 + }
  113 +
  114 + if v, ok := queryOptions["limit"].(int); ok {
  115 + query.Limit(v)
  116 + }
  117 +
  118 + if v, ok := queryOptions["offset"].(int); ok {
  119 + query.Offset(v)
  120 + }
  121 +
  122 + count, err := query.SelectAndCount()
  123 + if err != nil {
  124 + return 0, nil, err
  125 + }
  126 + var arrays []*domain.StaffAssessCache
  127 + for _, v := range m {
  128 + d := repo.TransformToDomain(v)
  129 + arrays = append(arrays, &d)
  130 + }
  131 + return count, arrays, nil
  132 +}
@@ -128,6 +128,8 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface @@ -128,6 +128,8 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
128 if v, ok := queryOptions["staffAssessId"]; ok { 128 if v, ok := queryOptions["staffAssessId"]; ok {
129 query.Where("staff_assess_id=?", v) 129 query.Where("staff_assess_id=?", v)
130 } 130 }
  131 +
  132 + query.Order("sort_by ASC")
131 count, err := query.SelectAndCount() 133 count, err := query.SelectAndCount()
132 if err != nil { 134 if err != nil {
133 return 0, nil, err 135 return 0, nil, err
1 -package controllers  
2 -  
3 -import (  
4 - "fmt"  
5 -  
6 - "github.com/linmadan/egglib-go/core/application"  
7 - "github.com/linmadan/egglib-go/web/beego"  
8 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"  
9 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"  
10 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"  
11 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
12 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"  
13 -)  
14 -  
15 -type StaffAssessController struct {  
16 - beego.BaseController  
17 -}  
18 -  
19 -// 获取我的绩效任务列表  
20 -func (c *StaffAssessController) SearchAssessTaskMe() {  
21 - srv := service.NewStaffAssessServeice()  
22 - paramReq := &query.SearchAssessMeQuery{}  
23 - err := c.BindJSON(paramReq)  
24 - if err != nil {  
25 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
26 - c.Response(nil, e)  
27 - return  
28 - }  
29 - userReq := middlewares.GetUser(c.Ctx)  
30 - paramReq.CompanyId = int(userReq.CompanyId)  
31 - paramReq.UserId = int(userReq.UserId)  
32 -  
33 - data, err := srv.SearchAssessTaskMe(paramReq)  
34 - c.Response(data, err)  
35 -}  
36 -  
37 -// 获取我的绩效任务各环节完成情况  
38 -func (c *StaffAssessController) AssessTaskMeDesc() {  
39 - srv := service.NewStaffAssessServeice()  
40 - paramReq := &query.AssessTaskDescQuery{}  
41 - err := c.BindJSON(paramReq)  
42 - if err != nil {  
43 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
44 - c.Response(nil, e)  
45 - return  
46 - }  
47 - userReq := middlewares.GetUser(c.Ctx)  
48 - paramReq.CompanyId = int(userReq.CompanyId)  
49 - paramReq.UserId = int(userReq.UserId)  
50 - data, err := srv.AssessTaskDesc(paramReq)  
51 - c.Response(data, err)  
52 -}  
53 -  
54 -// 获取个人的自评反馈历史记录列表  
55 -func (c *StaffAssessController) AssessSelfMeList() {  
56 - srv := service.NewStaffAssessServeice()  
57 - paramReq := &query.AssessSelfListQuery{}  
58 - err := c.BindJSON(paramReq)  
59 - if err != nil {  
60 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
61 - c.Response(nil, e)  
62 - return  
63 - }  
64 - userReq := middlewares.GetUser(c.Ctx)  
65 - paramReq.CompanyId = int(userReq.CompanyId)  
66 - paramReq.UserId = int(userReq.UserId)  
67 - data, err := srv.AssessSelfList(paramReq)  
68 - c.Response(data, err)  
69 -}  
70 -  
71 -// 更具项目评估的配置,创建员工的评估任务,(调试用)  
72 -func (c *StaffAssessController) CreateStaffAssessTask() {  
73 - srv := service.NewStaffAssessServeice()  
74 - paramReq := &command.CreateStaffAssessTask{}  
75 - err := c.BindJSON(paramReq)  
76 - if err != nil {  
77 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
78 - c.Response(nil, e)  
79 - return  
80 - }  
81 - //服务调用,实际由定时任务触发  
82 - data, err := srv.InvokCreateStaffAssessTask(paramReq)  
83 - c.Response(data, err)  
84 -}  
85 -  
86 -// 获取当前登录员工自评详情  
87 -func (c *StaffAssessController) GetAssessSelfMeInfo() {  
88 - srv := service.NewStaffAssessServeice()  
89 - paramReq := &query.AssessSelfInfoQuery{}  
90 - err := c.BindJSON(paramReq)  
91 - if err != nil {  
92 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
93 - c.Response(nil, e)  
94 - return  
95 - }  
96 - userReq := middlewares.GetUser(c.Ctx)  
97 - paramReq.CompanyId = int(userReq.CompanyId)  
98 - paramReq.TargetUserId = int(userReq.UserId)  
99 - data, err := srv.GetAssessSelfInfo(paramReq)  
100 - c.Response(data, err)  
101 -}  
102 -  
103 -// 获取我邀请的人  
104 -func (c *StaffAssessController) GetAssessMeInviteUser() {  
105 - srv := service.NewStaffAssessServeice()  
106 - paramReq := &query.GetAssessInviteUserQuery{}  
107 - err := c.BindJSON(paramReq)  
108 - if err != nil {  
109 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
110 - c.Response(nil, e)  
111 - return  
112 - }  
113 - userReq := middlewares.GetUser(c.Ctx)  
114 - paramReq.CompanyId = int(userReq.CompanyId)  
115 - paramReq.UserId = int(userReq.UserId)  
116 - data, err := srv.GetAssessInviteUser(paramReq)  
117 - c.Response(data, err)  
118 -}  
119 -  
120 -// 保存我邀请的员工  
121 -func (c *StaffAssessController) SaveAssessMeInviteUser() {  
122 - srv := service.NewStaffAssessServeice()  
123 - paramReq := &command.SaveAssessInvite{}  
124 - err := c.BindJSON(paramReq)  
125 - if err != nil {  
126 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
127 - c.Response(nil, e)  
128 - return  
129 - }  
130 - //TODO 获取当前用户信息  
131 - // paramReq.CompanyId = 1  
132 - // paramReq.UserId = 1  
133 - userReq := middlewares.GetUser(c.Ctx)  
134 - paramReq.TargetUserId = int(userReq.UserId)  
135 - data, err := srv.SaveAssessInviteUser(paramReq)  
136 - c.Response(data, err)  
137 -}  
138 -  
139 -// 员工邀请的人选择列表  
140 -func (c *StaffAssessController) SelectAssessInviteUser() {  
141 - srv := service.NewStaffAssessServeice()  
142 - paramReq := &query.SelectAssessInviteUser{}  
143 - err := c.BindJSON(paramReq)  
144 - if err != nil {  
145 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
146 - c.Response(nil, e)  
147 - return  
148 - }  
149 - // paramReq.CompanyId = 1  
150 - // paramReq.TargetUserId = 1  
151 - userReq := middlewares.GetUser(c.Ctx)  
152 - paramReq.CompanyId = int(userReq.CompanyId)  
153 - paramReq.TargetUserId = int(userReq.UserId)  
154 - data, err := srv.SelectAssessInviteUser(paramReq)  
155 - c.Response(data, err)  
156 -}  
157 -  
158 -// 获取我要执行360评估,用户列表和评估填写的值  
159 -func (c *StaffAssessController) ListMeInviteUserAssess() {  
160 - srv := service.NewStaffAssessServeice()  
161 - paramReq := &query.ListInviteUserAssessQuery{}  
162 - err := c.BindJSON(paramReq)  
163 - if err != nil {  
164 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
165 - c.Response(nil, e)  
166 - return  
167 - }  
168 - //获取当前用户信息  
169 - // paramReq.CompanyId = 1  
170 - // paramReq.ExecutorId = 1  
171 - userReq := middlewares.GetUser(c.Ctx)  
172 - paramReq.CompanyId = int(userReq.CompanyId)  
173 - paramReq.ExecutorId = int(userReq.UserId)  
174 - data, err := srv.ListExecutorInviteAssess(paramReq)  
175 - c.Response(data, err)  
176 -}  
177 -  
178 -// 获取我要执行的上级评估成员列表  
179 -func (c *StaffAssessController) ListMeSupperAssess() {  
180 - srv := service.NewStaffAssessServeice()  
181 - paramReq := &query.ListSupperAssessQuery{}  
182 - err := c.BindJSON(paramReq)  
183 - if err != nil {  
184 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
185 - c.Response(nil, e)  
186 - return  
187 - }  
188 - //TODO 获取当前用户信息  
189 - // paramReq.CompanyId = 1  
190 - // paramReq.ExecutorId = 1  
191 - userReq := middlewares.GetUser(c.Ctx)  
192 - paramReq.CompanyId = int(userReq.CompanyId)  
193 - paramReq.ExecutorId = int(userReq.UserId)  
194 - data, err := srv.ListExecutorSupperAssess(paramReq)  
195 - c.Response(data, err)  
196 -}  
197 -  
198 -// 获取员工自评详情  
199 -func (c *StaffAssessController) GetAssessTargetUserSelfInfo() {  
200 - srv := service.NewStaffAssessServeice()  
201 - paramReq := &query.AssessSelfInfoQuery{}  
202 - err := c.BindJSON(paramReq)  
203 - if err != nil {  
204 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
205 - c.Response(nil, e)  
206 - return  
207 - }  
208 - // paramReq.CompanyId = 1  
209 - userReq := middlewares.GetUser(c.Ctx)  
210 - paramReq.CompanyId = int(userReq.CompanyId)  
211 - data, err := srv.GetAssessSelfInfo(paramReq)  
212 - c.Response(data, err)  
213 -}  
214 -  
215 -// 获取评估内容详情  
216 -func (c *StaffAssessController) GetAssessInfo() {  
217 - srv := service.NewStaffAssessServeice()  
218 - paramReq := &query.AssessInfoQuery{}  
219 - err := c.BindJSON(paramReq)  
220 - if err != nil {  
221 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
222 - c.Response(nil, e)  
223 - return  
224 - }  
225 - // paramReq.CompanyId = 1  
226 - userReq := middlewares.GetUser(c.Ctx)  
227 - paramReq.CompanyId = int(userReq.CompanyId)  
228 - data, err := srv.GetAssessInfo(paramReq)  
229 - c.Response(data, err)  
230 -}  
231 -  
232 -// 保存评估内容详情  
233 -func (c *StaffAssessController) SaveAssessInfo() {  
234 - srv := service.NewStaffAssessServeice()  
235 - paramReq := &command.SaveAssessInfoCommand{}  
236 - err := c.BindJSON(paramReq)  
237 - if err != nil {  
238 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
239 - c.Response(nil, e)  
240 - return  
241 - }  
242 - userReq := middlewares.GetUser(c.Ctx)  
243 - paramReq.ExecutorId = int(userReq.UserId)  
244 - paramReq.CompanyId = int(userReq.CompanyId)  
245 - data, err := srv.SaveAssessInfo(paramReq)  
246 - c.Response(data, err)  
247 -}  
248 -  
249 -// 被评估的员工的评估列表-360评估  
250 -func (c *StaffAssessController) ListTargetUserInviteAssess() {  
251 - srv := service.NewStaffAssessServeice()  
252 - paramReq := &query.ListTargetUserAssessQuery{}  
253 - err := c.BindJSON(paramReq)  
254 - if err != nil {  
255 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
256 - c.Response(nil, e)  
257 - return  
258 - }  
259 - // paramReq.CompanyId = 1  
260 - userReq := middlewares.GetUser(c.Ctx)  
261 - paramReq.CompanyId = int(userReq.CompanyId)  
262 - paramReq.Types = []string{string(domain.AssessInviteSameSuper), string(domain.AssessInviteDiffSuper)}  
263 - data, err := srv.ListTargetUserAssess(paramReq)  
264 - c.Response(data, err)  
265 -}  
266 -  
267 -func (c *StaffAssessController) ListTargetUserMeSupperAssess() {  
268 - srv := service.NewStaffAssessServeice()  
269 - paramReq := &query.ListTargetUserAssessQuery{}  
270 - err := c.BindJSON(paramReq)  
271 - if err != nil {  
272 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
273 - c.Response(nil, e)  
274 - return  
275 - }  
276 - // paramReq.CompanyId = 1  
277 - userReq := middlewares.GetUser(c.Ctx)  
278 - paramReq.CompanyId = int(userReq.CompanyId)  
279 - paramReq.Types = []string{string(domain.AssessSuper)}  
280 - paramReq.TargetUserId = int(userReq.UserId)  
281 - data, err := srv.ListTargetUserAssess(paramReq)  
282 - c.Response(data, err)  
283 -}  
284 -  
285 -//获取周期列表  
286 -func (c *StaffAssessController) ListAssessCycle() {  
287 - srv := service.NewStaffAssessServeice()  
288 - userReq := middlewares.GetUser(c.Ctx)  
289 - data, err := srv.ListAllAssessCycle(int(userReq.CompanyId))  
290 - c.Response(data, err)  
291 -}  
292 -  
293 -//获取周期里的考核日期  
294 -func (c *StaffAssessController) ListAssessCycleDay() {  
295 - srv := service.NewStaffAssessServeice()  
296 - paramReq := &query.ListAssessCycleDay{}  
297 - err := c.BindJSON(paramReq)  
298 - if err != nil {  
299 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
300 - c.Response(nil, e)  
301 - return  
302 - }  
303 - userReq := middlewares.GetUser(c.Ctx)  
304 - paramReq.CompanyId = int(userReq.CompanyId)  
305 - data, err := srv.ListAllAssessCycleDay(paramReq)  
306 - c.Response(data, err)  
307 -}  
308 -  
309 -//根据周期里的考核日期,获取员工填写评估内容列表  
310 -func (c *StaffAssessController) ListAssessContentCycleDay() {  
311 - srv := service.NewStaffAssessServeice()  
312 - paramReq := &query.ListAssessContentCycleDay{}  
313 - err := c.BindJSON(paramReq)  
314 - if err != nil {  
315 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
316 - c.Response(nil, e)  
317 - return  
318 - }  
319 - userReq := middlewares.GetUser(c.Ctx)  
320 - paramReq.CompanyId = int(userReq.CompanyId)  
321 - paramReq.OperaterId = int(userReq.UserId)  
322 - data, err := srv.ListUserAssessContentCycleDay(paramReq)  
323 - c.Response(data, err)  
324 -}  
325 -  
326 -//根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件  
327 -func (c *StaffAssessController) ExportAssessContentCycleDay() {  
328 - srv := service.NewStaffAssessServeice()  
329 - paramReq := &query.ListAssessContentCycleDay{}  
330 - err := c.BindJSON(paramReq)  
331 - if err != nil {  
332 - e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())  
333 - c.Response(nil, e)  
334 - return  
335 - }  
336 - userReq := middlewares.GetUser(c.Ctx)  
337 - paramReq.CompanyId = int(userReq.CompanyId)  
338 - paramReq.OperaterId = int(userReq.UserId)  
339 - data, err := srv.ExportUserAssess(paramReq)  
340 - if err != nil {  
341 - c.Response(nil, err)  
342 - }  
343 - fileName := fmt.Sprintf("每日绩效汇总%s", paramReq.BeginDay)  
344 - c.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName)  
345 - c.Ctx.Output.Header("Content-Description", "FileTransfer")  
346 - c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")  
347 - c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")  
348 - c.Ctx.Output.Header("Expires", "0")  
349 - data.Write(c.Ctx.ResponseWriter)  
350 -} 1 +package controllers
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/linmadan/egglib-go/core/application"
  7 + "github.com/linmadan/egglib-go/web/beego"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  13 +)
  14 +
  15 +type StaffAssessController struct {
  16 + beego.BaseController
  17 +}
  18 +
  19 +// 获取我的绩效任务列表
  20 +func (c *StaffAssessController) SearchAssessTaskMe() {
  21 + srv := service.NewStaffAssessServeice()
  22 + paramReq := &query.SearchAssessMeQuery{}
  23 + err := c.BindJSON(paramReq)
  24 + if err != nil {
  25 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  26 + c.Response(nil, e)
  27 + return
  28 + }
  29 + userReq := middlewares.GetUser(c.Ctx)
  30 + paramReq.CompanyId = int(userReq.CompanyId)
  31 + paramReq.UserId = int(userReq.UserId)
  32 +
  33 + data, err := srv.SearchAssessTaskMe(paramReq)
  34 + c.Response(data, err)
  35 +}
  36 +
  37 +// 获取我的绩效任务各环节完成情况
  38 +func (c *StaffAssessController) AssessTaskMeDesc() {
  39 + srv := service.NewStaffAssessServeice()
  40 + paramReq := &query.AssessTaskDescQuery{}
  41 + err := c.BindJSON(paramReq)
  42 + if err != nil {
  43 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  44 + c.Response(nil, e)
  45 + return
  46 + }
  47 + userReq := middlewares.GetUser(c.Ctx)
  48 + paramReq.CompanyId = int(userReq.CompanyId)
  49 + paramReq.UserId = int(userReq.UserId)
  50 + data, err := srv.AssessTaskDesc(paramReq)
  51 + c.Response(data, err)
  52 +}
  53 +
  54 +// 获取个人的自评反馈历史记录列表
  55 +func (c *StaffAssessController) AssessSelfMeList() {
  56 + srv := service.NewStaffAssessServeice()
  57 + paramReq := &query.AssessSelfListQuery{}
  58 + err := c.BindJSON(paramReq)
  59 + if err != nil {
  60 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  61 + c.Response(nil, e)
  62 + return
  63 + }
  64 + userReq := middlewares.GetUser(c.Ctx)
  65 + paramReq.CompanyId = int(userReq.CompanyId)
  66 + paramReq.UserId = int(userReq.UserId)
  67 + data, err := srv.AssessSelfList(paramReq)
  68 + c.Response(data, err)
  69 +}
  70 +
  71 +// 更具项目评估的配置,创建员工的评估任务,(调试用)
  72 +func (c *StaffAssessController) CreateStaffAssessTask() {
  73 + srv := service.NewStaffAssessServeice()
  74 + paramReq := &command.CreateStaffAssessTask{}
  75 + err := c.BindJSON(paramReq)
  76 + if err != nil {
  77 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  78 + c.Response(nil, e)
  79 + return
  80 + }
  81 + //服务调用,实际由定时任务触发
  82 + data, err := srv.InvokCreateStaffAssessTask(paramReq)
  83 + c.Response(data, err)
  84 +}
  85 +
  86 +// 获取当前登录员工自评详情
  87 +func (c *StaffAssessController) GetAssessSelfMeInfo() {
  88 + srv := service.NewStaffAssessServeice()
  89 + paramReq := &query.AssessSelfInfoQuery{}
  90 + err := c.BindJSON(paramReq)
  91 + if err != nil {
  92 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  93 + c.Response(nil, e)
  94 + return
  95 + }
  96 + userReq := middlewares.GetUser(c.Ctx)
  97 + paramReq.CompanyId = int(userReq.CompanyId)
  98 + paramReq.TargetUserId = int(userReq.UserId)
  99 + data, err := srv.GetAssessSelfInfo(paramReq)
  100 + c.Response(data, err)
  101 +}
  102 +
  103 +// 获取我邀请的人
  104 +func (c *StaffAssessController) GetAssessMeInviteUser() {
  105 + srv := service.NewStaffAssessServeice()
  106 + paramReq := &query.GetAssessInviteUserQuery{}
  107 + err := c.BindJSON(paramReq)
  108 + if err != nil {
  109 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  110 + c.Response(nil, e)
  111 + return
  112 + }
  113 + userReq := middlewares.GetUser(c.Ctx)
  114 + paramReq.CompanyId = int(userReq.CompanyId)
  115 + paramReq.UserId = int(userReq.UserId)
  116 + data, err := srv.GetAssessInviteUser(paramReq)
  117 + c.Response(data, err)
  118 +}
  119 +
  120 +// 保存我邀请的员工
  121 +func (c *StaffAssessController) SaveAssessMeInviteUser() {
  122 + srv := service.NewStaffAssessServeice()
  123 + paramReq := &command.SaveAssessInvite{}
  124 + err := c.BindJSON(paramReq)
  125 + if err != nil {
  126 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  127 + c.Response(nil, e)
  128 + return
  129 + }
  130 + //TODO 获取当前用户信息
  131 + // paramReq.CompanyId = 1
  132 + // paramReq.UserId = 1
  133 + userReq := middlewares.GetUser(c.Ctx)
  134 + paramReq.TargetUserId = int(userReq.UserId)
  135 + data, err := srv.SaveAssessInviteUser(paramReq)
  136 + c.Response(data, err)
  137 +}
  138 +
  139 +// 员工邀请的人选择列表
  140 +func (c *StaffAssessController) SelectAssessInviteUser() {
  141 + srv := service.NewStaffAssessServeice()
  142 + paramReq := &query.SelectAssessInviteUser{}
  143 + err := c.BindJSON(paramReq)
  144 + if err != nil {
  145 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  146 + c.Response(nil, e)
  147 + return
  148 + }
  149 + // paramReq.CompanyId = 1
  150 + // paramReq.TargetUserId = 1
  151 + userReq := middlewares.GetUser(c.Ctx)
  152 + paramReq.CompanyId = int(userReq.CompanyId)
  153 + paramReq.TargetUserId = int(userReq.UserId)
  154 + data, err := srv.SelectAssessInviteUser(paramReq)
  155 + c.Response(data, err)
  156 +}
  157 +
  158 +// 获取我要执行360评估,用户列表和评估填写的值
  159 +func (c *StaffAssessController) ListMeInviteUserAssess() {
  160 + srv := service.NewStaffAssessServeice()
  161 + paramReq := &query.ListInviteUserAssessQuery{}
  162 + err := c.BindJSON(paramReq)
  163 + if err != nil {
  164 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  165 + c.Response(nil, e)
  166 + return
  167 + }
  168 + //获取当前用户信息
  169 + // paramReq.CompanyId = 1
  170 + // paramReq.ExecutorId = 1
  171 + userReq := middlewares.GetUser(c.Ctx)
  172 + paramReq.CompanyId = int(userReq.CompanyId)
  173 + paramReq.ExecutorId = int(userReq.UserId)
  174 + data, err := srv.ListExecutorInviteAssess(paramReq)
  175 + c.Response(data, err)
  176 +}
  177 +
  178 +// 获取我要执行的上级评估成员列表
  179 +func (c *StaffAssessController) ListMeSupperAssess() {
  180 + srv := service.NewStaffAssessServeice()
  181 + paramReq := &query.ListSupperAssessQuery{}
  182 + err := c.BindJSON(paramReq)
  183 + if err != nil {
  184 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  185 + c.Response(nil, e)
  186 + return
  187 + }
  188 + //TODO 获取当前用户信息
  189 + // paramReq.CompanyId = 1
  190 + // paramReq.ExecutorId = 1
  191 + userReq := middlewares.GetUser(c.Ctx)
  192 + paramReq.CompanyId = int(userReq.CompanyId)
  193 + paramReq.ExecutorId = int(userReq.UserId)
  194 + data, err := srv.ListExecutorSupperAssess(paramReq)
  195 + c.Response(data, err)
  196 +}
  197 +
  198 +// 获取员工自评详情
  199 +func (c *StaffAssessController) GetAssessTargetUserSelfInfo() {
  200 + srv := service.NewStaffAssessServeice()
  201 + paramReq := &query.AssessSelfInfoQuery{}
  202 + err := c.BindJSON(paramReq)
  203 + if err != nil {
  204 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  205 + c.Response(nil, e)
  206 + return
  207 + }
  208 + // paramReq.CompanyId = 1
  209 + userReq := middlewares.GetUser(c.Ctx)
  210 + paramReq.CompanyId = int(userReq.CompanyId)
  211 + data, err := srv.GetAssessSelfInfo(paramReq)
  212 + c.Response(data, err)
  213 +}
  214 +
  215 +// 获取评估内容详情
  216 +func (c *StaffAssessController) GetAssessInfo() {
  217 + srv := service.NewStaffAssessServeice()
  218 + paramReq := &query.AssessInfoQuery{}
  219 + err := c.BindJSON(paramReq)
  220 + if err != nil {
  221 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  222 + c.Response(nil, e)
  223 + return
  224 + }
  225 + // paramReq.CompanyId = 1
  226 + userReq := middlewares.GetUser(c.Ctx)
  227 + paramReq.CompanyId = int(userReq.CompanyId)
  228 + data, err := srv.GetAssessInfo(paramReq)
  229 + c.Response(data, err)
  230 +}
  231 +
  232 +// 保存评估内容详情
  233 +func (c *StaffAssessController) SaveAssessInfo() {
  234 + srv := service.NewStaffAssessServeice()
  235 + paramReq := &command.SaveAssessInfoCommand{}
  236 + err := c.BindJSON(paramReq)
  237 + if err != nil {
  238 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  239 + c.Response(nil, e)
  240 + return
  241 + }
  242 + userReq := middlewares.GetUser(c.Ctx)
  243 + paramReq.ExecutorId = int(userReq.UserId)
  244 + paramReq.CompanyId = int(userReq.CompanyId)
  245 + data, err := srv.SaveAssessInfo(paramReq)
  246 + c.Response(data, err)
  247 +}
  248 +
  249 +// 被评估的员工的评估列表-360评估
  250 +func (c *StaffAssessController) ListTargetUserInviteAssess() {
  251 + srv := service.NewStaffAssessServeice()
  252 + paramReq := &query.ListTargetUserAssessQuery{}
  253 + err := c.BindJSON(paramReq)
  254 + if err != nil {
  255 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  256 + c.Response(nil, e)
  257 + return
  258 + }
  259 + // paramReq.CompanyId = 1
  260 + userReq := middlewares.GetUser(c.Ctx)
  261 + paramReq.CompanyId = int(userReq.CompanyId)
  262 + paramReq.Types = []string{string(domain.AssessInviteSameSuper), string(domain.AssessInviteDiffSuper)}
  263 + data, err := srv.ListTargetUserAssess(paramReq)
  264 + c.Response(data, err)
  265 +}
  266 +
  267 +func (c *StaffAssessController) ListTargetUserMeSupperAssess() {
  268 + srv := service.NewStaffAssessServeice()
  269 + paramReq := &query.ListTargetUserAssessQuery{}
  270 + err := c.BindJSON(paramReq)
  271 + if err != nil {
  272 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  273 + c.Response(nil, e)
  274 + return
  275 + }
  276 + // paramReq.CompanyId = 1
  277 + userReq := middlewares.GetUser(c.Ctx)
  278 + paramReq.CompanyId = int(userReq.CompanyId)
  279 + paramReq.Types = []string{string(domain.AssessSuper)}
  280 + paramReq.TargetUserId = int(userReq.UserId)
  281 + data, err := srv.ListTargetUserAssess(paramReq)
  282 + c.Response(data, err)
  283 +}
  284 +
  285 +//获取周期列表
  286 +func (c *StaffAssessController) ListAssessCycle() {
  287 + srv := service.NewStaffAssessServeice()
  288 + userReq := middlewares.GetUser(c.Ctx)
  289 + data, err := srv.ListAllAssessCycle(int(userReq.CompanyId))
  290 + c.Response(data, err)
  291 +}
  292 +
  293 +//获取周期里的考核日期
  294 +func (c *StaffAssessController) ListAssessCycleDay() {
  295 + srv := service.NewStaffAssessServeice()
  296 + paramReq := &query.ListAssessCycleDay{}
  297 + err := c.BindJSON(paramReq)
  298 + if err != nil {
  299 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  300 + c.Response(nil, e)
  301 + return
  302 + }
  303 + userReq := middlewares.GetUser(c.Ctx)
  304 + paramReq.CompanyId = int(userReq.CompanyId)
  305 + data, err := srv.ListAllAssessCycleDay(paramReq)
  306 + c.Response(data, err)
  307 +}
  308 +
  309 +//根据周期里的考核日期,获取员工填写评估内容列表
  310 +func (c *StaffAssessController) ListAssessContentCycleDay() {
  311 + srv := service.NewStaffAssessServeice()
  312 + paramReq := &query.ListAssessContentCycleDay{}
  313 + err := c.BindJSON(paramReq)
  314 + if err != nil {
  315 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  316 + c.Response(nil, e)
  317 + return
  318 + }
  319 + userReq := middlewares.GetUser(c.Ctx)
  320 + paramReq.CompanyId = int(userReq.CompanyId)
  321 + paramReq.OperaterId = int(userReq.UserId)
  322 + data, err := srv.ListUserAssessContentCycleDay(paramReq)
  323 + c.Response(data, err)
  324 +}
  325 +
  326 +//根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
  327 +func (c *StaffAssessController) ExportAssessContentCycleDay() {
  328 + srv := service.NewStaffAssessServeice()
  329 + paramReq := &query.ListAssessContentCycleDay{}
  330 + err := c.BindJSON(paramReq)
  331 + if err != nil {
  332 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  333 + c.Response(nil, e)
  334 + return
  335 + }
  336 + userReq := middlewares.GetUser(c.Ctx)
  337 + paramReq.CompanyId = int(userReq.CompanyId)
  338 + paramReq.OperaterId = int(userReq.UserId)
  339 + data, err := srv.ExportUserAssess(paramReq)
  340 + if err != nil {
  341 + c.Response(nil, err)
  342 + }
  343 + fileName := fmt.Sprintf("每日绩效汇总%s", paramReq.BeginDay)
  344 + c.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName)
  345 + c.Ctx.Output.Header("Content-Description", "FileTransfer")
  346 + c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
  347 + c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
  348 + c.Ctx.Output.Header("Expires", "0")
  349 + data.Write(c.Ctx.ResponseWriter)
  350 +}
  351 +
  352 +// SaveAssessCache 保存评估内容(缓存)
  353 +func (c *StaffAssessController) SaveAssessCache() {
  354 + cacheService := service.NewStaffAssessCacheService()
  355 + in := &command.SaveAssessCacheCommand{}
  356 + if err := c.Unmarshal(in); err != nil {
  357 + c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  358 + } else {
  359 + c.Response(cacheService.SaveAssessCache(in))
  360 + }
  361 +}
1 -package routers  
2 -  
3 -import (  
4 - "github.com/beego/beego/v2/server/web"  
5 - "github.com/linmadan/egglib-go/web/beego/filters"  
6 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"  
7 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"  
8 -)  
9 -  
10 -func init() {  
11 - assessTaskNS := web.NewNamespace("/v1/staff-assess-task",  
12 - web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),  
13 - web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表  
14 - web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述  
15 - //web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务  
16 - web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表  
17 - web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期  
18 - web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表  
19 - web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表  
20 - )  
21 - // /v1/staff-assess/self/me/list  
22 - assessNS := web.NewNamespace("/v1/staff-assess",  
23 - web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),  
24 - web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表  
25 - web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情  
26 - web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工  
27 - web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工  
28 - web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工  
29 - web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表  
30 - web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表  
31 - web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情  
32 - web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情  
33 - web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表  
34 - web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表  
35 - web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情  
36 - )  
37 - //v2 改版  
38 - assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",  
39 - web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),  
40 - web.NSCtrlPost("/search/me", (*controllers.StaffAssessControllerV2).SearchAssessTaskMe), //获取我参与过的评估项目列表  
41 - web.NSCtrlPost("/desc/me", (*controllers.StaffAssessControllerV2).AssessTaskMeDesc),  
42 - )  
43 -  
44 - assessV2NS := web.NewNamespace("/v2/staff-assess",  
45 - web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),  
46 - web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessControllerV2).ListMeInviteUserAssess), //我要执行的360评估的用户列表  
47 - web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessControllerV2).ListMeSupperAssess), //我要执行的360评估的用户列表  
48 - web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessControllerV2).GetAssessMeInviteUser), //获取邀请的员工  
49 - web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessControllerV2).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情  
50 - )  
51 -  
52 - web.AddNamespace(assessTaskNS)  
53 - web.AddNamespace(assessNS)  
54 - web.AddNamespace(assessTaskV2NS)  
55 - web.AddNamespace(assessV2NS)  
56 -} 1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "github.com/linmadan/egglib-go/web/beego/filters"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  8 +)
  9 +
  10 +func init() {
  11 + assessTaskNS := web.NewNamespace("/v1/staff-assess-task",
  12 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  13 + web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
  14 + web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
  15 + //web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
  16 + web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
  17 + web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
  18 + web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
  19 + web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表
  20 + )
  21 + // /v1/staff-assess/self/me/list
  22 + assessNS := web.NewNamespace("/v1/staff-assess",
  23 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  24 + web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
  25 + web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
  26 + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工
  27 + web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工
  28 + web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
  29 + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表
  30 + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表
  31 + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
  32 + web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
  33 + web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存)
  34 + web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
  35 + web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表
  36 + web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
  37 + )
  38 + //v2 改版
  39 + assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
  40 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  41 + web.NSCtrlPost("/search/me", (*controllers.StaffAssessControllerV2).SearchAssessTaskMe), //获取我参与过的评估项目列表
  42 + web.NSCtrlPost("/desc/me", (*controllers.StaffAssessControllerV2).AssessTaskMeDesc),
  43 + )
  44 +
  45 + assessV2NS := web.NewNamespace("/v2/staff-assess",
  46 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  47 + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessControllerV2).ListMeInviteUserAssess), //我要执行的360评估的用户列表
  48 + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessControllerV2).ListMeSupperAssess), //我要执行的360评估的用户列表
  49 + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessControllerV2).GetAssessMeInviteUser), //获取邀请的员工
  50 + web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessControllerV2).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
  51 + )
  52 +
  53 + web.AddNamespace(assessTaskNS)
  54 + web.AddNamespace(assessNS)
  55 + web.AddNamespace(assessTaskV2NS)
  56 + web.AddNamespace(assessV2NS)
  57 +}