作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !13
... ... @@ -5,6 +5,7 @@ go 1.16
require (
github.com/Andrew-M-C/go.timeconv v0.4.0
github.com/Shopify/sarama v1.25.0
github.com/beego/beego v1.12.11
github.com/beego/beego/v2 v2.0.5
github.com/bwmarrin/snowflake v0.3.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
... ...
... ... @@ -61,6 +61,8 @@ github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6l
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beego/beego v1.12.11 h1:MWKcnpavb7iAIS0m6uuEq6pHKkYvGNw/5umIUKqL7jM=
github.com/beego/beego v1.12.11/go.mod h1:QURFL1HldOcCZAxnc1cZ7wrplsYR5dKPHFjmk6WkLAs=
github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
github.com/beego/beego/v2 v2.0.5 h1:fa2TBWfKGDs35Ck9an9SVnpS0zM8sRTXlW8rFjpeYlE=
github.com/beego/beego/v2 v2.0.5/go.mod h1:CH2/JIaB4ceGYVQlYqTAFft4pVk/ol1ZkakUrUvAyns=
... ... @@ -102,10 +104,13 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
github.com/couchbase/go-couchbase v0.1.0/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/gomemcached v0.1.2-0.20201224031647-c432ccf49f32/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
github.com/couchbase/gomemcached v0.1.3/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/couchbase/goutils v0.0.0-20210118111533-e33d3ffb5401/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/couchbase/goutils v0.1.0/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
... ... @@ -505,6 +510,7 @@ github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgq
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
github.com/wendal/errors v0.0.0-20181209125328-7f31f4b264ec/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
... ... @@ -566,6 +572,7 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
... ...
... ... @@ -2,5 +2,5 @@ package command
type LoginCommand struct {
Code string `json:"code" valid:"Required"` //授权code
PlatformId int `json:"platformId" valid:"Required"` //登录平台ID,28-绩效管理后台 29-员工绩效
PlatformId int `json:"platformId" valid:"Required"` //登录平台ID,constant.IdPlatformAdmin=28 绩效管理后台 constant.IdPlatformUser=29 员工绩效
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/validation"
)
type MobileLoginCommand struct {
Credentials string `json:"credentials" valid:"Required;"` //登录凭证
Cuid int `json:"cuid,string" valid:"Required;"` //统一用户中心用户 UID
Cid int `json:"cid,string" valid:"Required;"` //统一用户中心公司 ID
Muid int `json:"muid,string" valid:"Required;"` //企业平台中的用户 UID
//ClientId string `json:"clientId"` //客户端密钥
}
func (authorizeCommand *MobileLoginCommand) Valid(validation *validation.Validation) {
}
func (authorizeCommand *MobileLoginCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(authorizeCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(authorizeCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -53,18 +54,19 @@ func (service *AuthService) Login(loginCommand *command.LoginCommand) (interface
"companyId": company.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败")
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户数据失败")
}
if user.Status != domain.UserStatusEnable {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用")
}
userAuth := &domain.UserAuth{
UserId: user.Id,
CompanyId: user.CompanyId,
Phone: user.Account,
PlatformId: loginCommand.PlatformId,
Name: user.Name,
AdminType: user.AdminType,
UserId: user.Id,
CompanyId: user.CompanyId,
CompanyName: company.Name,
Phone: user.Account,
PlatformId: loginCommand.PlatformId,
Name: user.Name,
AdminType: user.AdminType,
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
... ... @@ -80,3 +82,77 @@ func (service *AuthService) Login(loginCommand *command.LoginCommand) (interface
},
}, nil
}
// 员工绩效 手机端登录,来源于能力展示app
func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 统一用户中心登录
authCodeReply, err := factory.UCenterApi().AppAuthCode(param.Credentials, param.Cuid, param.Cid)
if err != nil || !authCodeReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统一用户中心认证失败")
}
// 用户权限校验
// 登录平台ID,28-绩效管理后台 29-员工绩效
userAuthReply, err := factory.BusinessAdminApi().GetUserAuth(int64(param.Muid), constant.IdPlatformUser)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户鉴权失败")
}
if !userAuthReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, userAuthReply.Message())
}
//获取公司数据
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
company, err := companyRepository.FindOne(map[string]interface{}{
"id": param.Cid,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败")
}
userRepository := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
user, err := userRepository.FindOne(map[string]interface{}{
"id": param.Muid,
"companyId": company.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户数据失败")
}
if user.Status != domain.UserStatusEnable {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用")
}
userAuth := &domain.UserAuth{
UserId: user.Id,
CompanyId: user.CompanyId,
CompanyName: company.Name,
Phone: user.Account,
PlatformId: constant.IdPlatformUser,
Name: user.Name,
AdminType: user.AdminType,
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := map[string]interface{}{
"access": map[string]interface{}{
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
},
}
return result, nil
}
... ...
... ... @@ -9,16 +9,17 @@ type AssessInfoResp struct {
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"`
LinkNodeName string `json:"linkNodeName"`
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUserId,string"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
LinkNodeName string `json:"linkNodeName"` //评估环节名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUserId,string"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //公司id
CompanyLogo string `json:"companyLogo,string,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
}
... ...
... ... @@ -12,6 +12,7 @@ type AssessSelfList struct {
type StaffInfo struct {
UserName string `json:"userName"` //员工名称
CompanyLogo string `json:"companyLogo"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUserName string `json:"supperUserName"` //上级名称
DutyTime string `json:"dutyTime"` //上岗时间
... ...
package adapter
type ListSupperAssessResp struct {
StaffAssessTaskId int `json:"staffAssessTaskId"`
AssessId int `json:"assessId"` //
CycleId int `json:"cycleId"` //周期id
BeginDay string `json:"beginDay"` //开始的日期
UserId int `json:"userId,string"` //用户id
UserName string `json:"userName"` //用户名称
EndTime string `json:"endTime"` //截止时间
InviteTotal int `json:"inviteTota"` //邀请总数
InviteCompleted int `json:"inviteCompleted"` //邀请未完成
Status string `json:"status"` //评估任务是否填写完成
Department string `json:"department"` //部门
Position string `json:"position"` //职位
DutyTime string `json:"dutyTime"` //入职时间
StaffAssessTaskId int `json:"staffAssessTaskId"`
AssessId int `json:"assessId"` //
CycleId int `json:"cycleId"` //周期id
BeginDay string `json:"beginDay"` //开始的日期
UserId int `json:"userId,string"` //用户id
UserName string `json:"userName"` //用户名称
EndTime string `json:"endTime"` //截止时间
InviteTotal int `json:"inviteTota"` //邀请总数
InviteCompleted int `json:"inviteCompleted"` //邀请未完成
Status string `json:"status"` //评估任务是否填写完成
Department string `json:"department"` //部门
Position string `json:"position"` //职位
CompanyName string `json:"companyName"` //公司名称
DutyTime string `json:"dutyTime"` //入职时间
ContentValue []string `json:"contentValue"` //评估填写的结果
}
... ...
package adapter
type SelectInviteUser struct {
UserId int `json:"userId,string"`
UserName string `json:"userName"` //
IsSupper bool `json:"isSupper"` // 是否,是直属上级
Types int `json:"types"` // 1:相同上级的同事 2:不相同上级的同事
UserId int `json:"userId,string"`
UserName string `json:"userName"` //
CompanyName string `json:"companyName"` //
IsSupper bool `json:"isSupper"` // 是否,是直属上级
Types int `json:"types"` // 1:相同上级的同事 2:不相同上级的同事
}
... ...
... ... @@ -121,7 +121,7 @@ func (e *exportData) setData(param []*dao.ExportData2) {
e.data[key] = &strings.Builder{}
e.data[key].WriteString(v.Value + "\n") //填写的等级
for _, vv := range v.Remark {
e.data[key].WriteString(vv.Definition + "\n")
e.data[key].WriteString(vv.Title + "\n")
e.data[key].WriteString(vv.RemarkText + "\n")
}
if _, ok := userDay[userName+v.BeginDay]; !ok {
... ... @@ -203,7 +203,7 @@ func (e *exportData2) setData(param []dao.ExportData1) {
e.data[key] = &strings.Builder{}
e.data[key].WriteString(v.Value + "\n")
for _, v2 := range v.Remark {
e.data[key].WriteString(v2.Definition + "\n")
e.data[key].WriteString(v2.Title + "\n")
e.data[key].WriteString(v2.RemarkText + "\n")
}
}
... ...
... ... @@ -1121,6 +1121,13 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
userRepo := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取公司信息
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
targetUser, err := userRepo.FindOne(map[string]interface{}{
"id": param.TargetUserId,
})
... ... @@ -1174,12 +1181,17 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
listData := []adapter.SelectInviteUser{}
companyName := ""
if companyInfo != nil {
companyName = companyInfo.Name
}
for _, v := range userList {
item := adapter.SelectInviteUser{
UserId: int(v.Id),
UserName: v.Name,
IsSupper: false,
Types: 2, //默认是不同上级
UserId: int(v.Id),
UserName: v.Name,
CompanyName: companyName,
IsSupper: false,
Types: 2, //默认是不同上级
}
if _, ok := targetUserCharge[v.Id]; ok {
item.IsSupper = true
... ... @@ -1598,6 +1610,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
if targetUserDesc != nil {
result.CompanyName = targetUserDesc.CompanyName
result.SupperUser = targetUserDesc.SupperUserName
result.CompanyLogo = targetUserDesc.CompanyLogo
result.DutyTime = targetUserDesc.DutyTime
}
return &result, nil
... ... @@ -1628,40 +1641,11 @@ func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.T
log.Logger.Error("获取公司信息," + err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
}
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //查找员工的部门
// var departmentList []*domain.Department
// if len(userData.DepartmentId) > 0 {
// }
// var supperUserList []*domain.User
// if len(userData.DepartmentId) > 0 {
// _, departmentList, err := departmentRepo.Find(map[string]interface{}{
// "ids": userData.DepartmentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
// }
// var chargeUserIds []int64
// for _, v := range departmentList {
// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
// }
// if len(chargeUserIds) > 0 {
// _, supperUserList, err = userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
// }
// }
// }
supperUserList, _ := srv.getStaffSuper(transactionContext, *userData)
userInfo := adapter.StaffInfo{
UserName: userData.Name,
CompanyName: companyData.Name,
CompanyLogo: companyData.Logo,
SupperUserName: "",
DutyTime: userData.EntryTime,
}
... ... @@ -1739,9 +1723,12 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
if !ok {
continue
}
if v.Required == domain.NodeRequiredYes && len(item.Value) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":必填项")
}
v.Value = item.Value
if v.Required == domain.NodeRequiredYes {
//转换填入的评估值
if len(item.Value) > 0 {
// 转换填入的评估值
err = v.TransformValue()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error())
... ... @@ -1822,7 +1809,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
// return tool_funs.SimpleWrapGridMap(int64(cnt), assessList), nil
// }
// 获取员工的上级是谁 ,TODO
// 获取员工的上级是谁
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -14,7 +14,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
//获取我的项目周期列表
// 获取我的项目周期列表
func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -63,7 +63,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
}
//获取我的项目周期进度描述
// 获取我的项目周期进度描述
func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Query) (*adapter.AssessCycleDescResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -218,7 +218,7 @@ func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Que
return &result, nil
}
//根据周期获取,我的自评任务添加的邀请人
// 根据周期获取,我的自评任务添加的邀请人
func (srv StaffAssessServeice) ListAssessInviteUserV2(param *query.ListInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -234,7 +234,12 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param *query.ListInviteUse
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyReps := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyInfo, _ := companyReps.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -281,11 +286,17 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param *query.ListInviteUse
result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
break
}
companyName := ""
if companyInfo != nil {
companyName = companyInfo.Name
}
for _, v := range assessList {
if v.Types == domain.AssessInviteDiffSuper {
v.Executor.CompanyName = companyName
result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
}
if v.Types == domain.AssessInviteSameSuper {
v.Executor.CompanyName = companyName
result.InviteSameSuper = append(result.InviteSameSuper, v.Executor)
}
}
... ... @@ -309,7 +320,12 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecu
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
//获取 executorId 对应的360评估任务 用户
condition := map[string]interface{}{
"beginDay": param.BeginDay,
... ... @@ -412,6 +428,10 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecu
}
tableHeader = append(tableHeader, changeableHeader...)
listData := []map[string]interface{}{}
companyName := ""
if companyInfo != nil {
companyName = companyInfo.Name
}
for _, v := range assessList {
m := map[string]interface{}{
"staffAssessTaskId": v.StaffAssessTaskId,
... ... @@ -423,6 +443,7 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecu
"types": string(v.Types),
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
"assessId": strconv.Itoa(v.Id),
"companyName": companyName,
}
switch v.Status {
case domain.StaffAssessCompleted:
... ... @@ -478,6 +499,14 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//公司存储
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
limit := 20
if param.PageSize > 0 {
... ... @@ -502,6 +531,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//获取目标用户
userIds := []int{}
for _, v := range assessList {
... ... @@ -556,10 +586,20 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
var allAssessId []int
for _, v := range assessList {
allAssessId = append(allAssessId, v.Id)
}
assessValueMap := d.SearchContentValueByAssessId(allAssessId)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
companyName := ""
if companyInfo != nil {
companyName = companyInfo.Name
}
resultList := []adapter.ListSupperAssessResp{}
for _, v := range assessList {
item := adapter.ListSupperAssessResp{
... ... @@ -575,7 +615,12 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
InviteTotal: 5,
Department: "",
Position: "",
CompanyName: companyName,
DutyTime: "",
ContentValue: []string{},
}
if values, ok := assessValueMap[v.Id]; ok {
item.ContentValue = values
}
//填入部门
for _, vv := range v.TargetDepartment {
... ... @@ -690,19 +735,21 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
TargetUserName: assessData.TargetUser.UserName,
CompanyId: assessData.CompanyId,
CompanyName: "",
CompanyLogo: "",
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
}
if staffDesc != nil {
result.CompanyName = staffDesc.CompanyName
result.CompanyLogo = staffDesc.CompanyLogo
result.SupperUser = staffDesc.SupperUserName
result.DutyTime = staffDesc.DutyTime
}
return &result, nil
}
//根据周期和日期。获取360评估的列表,员工的被其他人评估
// 根据周期和日期。获取360评估的列表,员工的被其他人评估
func (srv StaffAssessServeice) ListTargetUserInviteAssess(param *query.ListTargetAssessQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -744,7 +791,7 @@ func (srv StaffAssessServeice) ListTargetUserInviteAssess(param *query.ListTarge
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
}
//根据周期和日期。获取上级评估的列表,员工的被其他人评估
// 根据周期和日期。获取上级评估的列表,员工的被其他人评估
func (srv StaffAssessServeice) ListTargetUserSuperAssess(param *query.ListTargetAssessQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -774,7 +821,7 @@ func (srv StaffAssessServeice) ListTargetUserSuperAssess(param *query.ListTarget
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var resultList []map[string]interface{}
resultList := []map[string]interface{}{}
for _, v := range assessList {
item := map[string]interface{}{
"id": v.Id,
... ...
... ... @@ -4,9 +4,15 @@ import "os"
const SERVICE_NAME = "performance"
// 登录平台ID,28-绩效管理后台 29-员工绩效
const (
IdPlatformAdmin int = 28
IdPlatformUser int = 29
)
var LOG_LEVEL = "debug"
//过期时间 7天时间
// 过期时间 7天时间
var AdminJwtExpiresIn = int64(3600 * 24 * 7)
var AdminJWTSecretKey = "sg-storage"
... ...
... ... @@ -4,7 +4,10 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/se
// UCenterApi 统一用户中心
type UCenterApi interface {
// pc 端
AuthCode(code string) (*reply.UCenterAuthCode, error)
//手机app端
AppAuthCode(tokenCode string, uid int, companyId int) (*reply.UCenterAuthCode, error)
}
// BusinessAdminApi 企业平台
... ...
... ... @@ -2,9 +2,10 @@ package domain
//员工基本信息描述
type StaffDesc struct {
UserId int `json:"userId,string"` //用户id
Account string `json:"account"` //用户的账号
UserName string `json:"userName"` //用户的名称
UserId int `json:"userId,string"` //用户id
CompanyName string `json:"companyName"` //公司名称
Account string `json:"account"` //用户的账号
UserName string `json:"userName"` //用户的名称
}
//员工的部门
... ...
... ... @@ -2,14 +2,16 @@ package domain
import (
"errors"
"github.com/dgrijalva/jwt-go"
"time"
"github.com/dgrijalva/jwt-go"
)
type UserAuth struct {
jwt.StandardClaims `json:"-"`
UserId int64 `json:"userId"`
CompanyId int64 `json:"companyId"`
CompanyName string `json:"companyName"`
Phone string `json:"phone"`
PlatformId int `json:"platformId"`
Name string `json:"name"`
... ...
... ... @@ -1096,14 +1096,15 @@ func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int,
// 评估的指标
type ContentCategoryName struct {
Category string //指标分类
Name string //指标名称
Weight float64 //指标权重
CycleId string //周期id
CycleName string //周期名称
TargetUserId string //评估的目标员工id
TargetUserName string //评估的目标员工名称
Cnt int //排序
Category string `pg:"category"` //指标分类
Name string `pg:"name"` //指标名称
Weight float64 `pg:"weight"` //指标权重
CycleId string `pg:"cycle_id"` //周期id
CycleName string `pg:"cycle_name"` //周期名称
SortBy int `pg:"sort_by"` //
TargetUserId string `pg:"target_user_id"` //评估的目标员工id
TargetUserName string `pg:"target_user_name"` //评估的目标员工名称
//Cnt int `pg:"cnt"` //排序
}
// 员工绩效-综合管理-导出绩效指标
... ... @@ -1114,16 +1115,11 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
staff_assess_content.category,
staff_assess_content."name" ,
staff_assess_content.weight ,
staff_assess_content.sort_by ,
t_staff_assess_1.cycle_id ,
t_staff_assess_1.cycle_name,
t_staff_assess_1.target_user_id,
t_staff_assess_1.target_user_name,
sum(
case
when staff_assess_content.value isnull then 0
when staff_assess_content.value='' then 0
ELSE 1
END) as cnt
t_staff_assess_1.target_user_name
from staff_assess_content
join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.assess_id
where 1=1
... ... @@ -1133,13 +1129,9 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
condition = append(condition, pg.In(exportUserIds))
sqlStr += ` and t_staff_assess_1.target_user_id in(?) `
}
sqlStr += ` group by staff_assess_content.category,
staff_assess_content."name" ,
t_staff_assess_1.cycle_id ,
t_staff_assess_1.cycle_name,
staff_assess_content.weight ,
target_user_id,target_user_name
order by cnt desc,target_user_id `
sqlStr += ` group by category,"name" ,cycle_id ,cycle_name,weight ,
target_user_id,target_user_name,sort_by
order by target_user_id,sort_by `
sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 5000, 0, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
... ... @@ -1200,3 +1192,37 @@ func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, opera
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
type ContentValue struct {
StaffAssessId int `pg:"staff_assess_id"`
Value string `pg:"value"`
}
func (d *StaffAssessDao) SearchContentValueByAssessId(assessId []int) map[int][]string {
if len(assessId) == 0 {
return map[int][]string{}
}
sqlStr := `select
staff_assess_content.staff_assess_id ,
staff_assess_content.value
from staff_assess_content
where staff_assess_content.staff_assess_id in (?)`
tx := d.transactionContext.PgTx
result := []ContentValue{}
condition := []interface{}{pg.In(assessId)}
_, err := tx.Query(&result, sqlStr, condition...)
if err != nil {
return map[int][]string{}
}
valueMap := map[int][]string{}
for _, v := range result {
if _, ok := valueMap[v.StaffAssessId]; !ok {
valueMap[v.StaffAssessId] = []string{}
}
if len(v.Value) > 0 {
valueMap[v.StaffAssessId] = append(valueMap[v.StaffAssessId], v.Value)
}
}
return valueMap
}
... ...
... ... @@ -161,7 +161,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["beginDay"]; ok {
query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v)
}
query.Order("staff_assess.id")
query.Order("staff_assess.id DESC")
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -3,11 +3,14 @@ package serviceGateway
import (
"crypto/sha1"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway/reply"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway/reply"
)
type HttpLibUCenterApiServiceGateway struct {
... ... @@ -27,7 +30,7 @@ func (serviceGateway *HttpLibUCenterApiServiceGateway) buildHeaders() map[string
}
}
// AuthCode PC端登录
// AuthCode PC端登录, 为后台单点登录
func (serviceGateway *HttpLibUCenterApiServiceGateway) AuthCode(code string) (*reply.UCenterAuthCode, error) {
authCodeReply := &reply.UCenterAuthCode{}
serviceGateway.CreateRequest(http.MethodPost, "/auth/serverLogin")
... ... @@ -40,6 +43,21 @@ func (serviceGateway *HttpLibUCenterApiServiceGateway) AuthCode(code string) (*r
return authCodeReply, err
}
// AuthCode 手机应用端登录, 为token登录,app登录
func (serviceGateway *HttpLibUCenterApiServiceGateway) AppAuthCode(tokenCode string, uid int, companyId int) (*reply.UCenterAuthCode, error) {
authCodeReply := &reply.UCenterAuthCode{}
serviceGateway.CreateRequest(http.MethodPost, "/auth/serverLogin")
serviceGateway.SetBody(map[string]interface{}{
"type": 2,
"token": strings.TrimSpace(tokenCode),
"uid": strconv.Itoa(uid),
"companyId": strconv.Itoa(companyId),
})
serviceGateway.SetHeaders(serviceGateway.buildHeaders())
err := serviceGateway.ToJson(authCodeReply)
return authCodeReply, err
}
func NewHttpLibUCenterApiServiceGateway() *HttpLibUCenterApiServiceGateway {
return &HttpLibUCenterApiServiceGateway{
httpLibBaseServiceGateway{baseURL: constant.UCENTER_SERVICE_HOST},
... ...
... ... @@ -21,9 +21,17 @@ func (controller *AuthController) Login() {
}
func (controller *AuthController) User() {
userAuth := controller.Ctx.Input.GetData(domain.UserAuth{}).(*domain.UserAuth)
controller.Response(map[string]interface{}{
"user": userAuth,
}, nil)
}
// Login PC端登录
func (controller *AuthController) MobileLogin() {
authService := &service.AuthService{}
loginCommand := &command.MobileLoginCommand{}
_ = controller.Unmarshal(loginCommand)
resp, err := authService.MobileLogin(loginCommand)
controller.Response(resp, err)
}
... ...
... ... @@ -47,7 +47,7 @@ func (c *StaffAssessControllerV2) AssessTaskMeDesc() {
c.Response(data, err)
}
// 获取我要执行360评估,用户列表和评估填写的值
// 获取我要执行360评估,用户列表和评估填写的值
func (c *StaffAssessControllerV2) ListMeInviteUserAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListExecutorAssessQuery{}
... ...
... ... @@ -9,6 +9,8 @@ import (
func init() {
web.Router("/login", &controllers.AuthController{}, "Post:Login")
web.Router("/login/mobile", &controllers.AuthController{}, "Post:MobileLogin")
//
web.InsertFilter("/auth/admin/*", web.BeforeExec, middlewares.CheckAdminToken())
web.Router("/auth/admin/user", &controllers.AuthController{}, "Get:User")
... ...
-- 数据库 suplus_admin的mysql数据库
-- 更新 platforms 数据 ,让app端能够启用 员工绩效的入口
UPDATE platforms
SET
is_app_use = 1,
updated_at = now()
WHERE id = 29;
\ No newline at end of file
... ...