...
|
...
|
@@ -7,7 +7,6 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
|
|
|
"opp/internal/repository"
|
|
|
"opp/internal/utils"
|
|
|
"opp/models"
|
|
|
"opp/protocol"
|
...
|
...
|
@@ -22,7 +21,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
|
chance *protocol.ChanceDetail
|
|
|
)
|
|
|
rsp = &protocol.FavoriteResponse{}
|
|
|
favorites, rsp.Total, err = repository.ChanceFavorite.GetChanceFavorites(
|
|
|
favorites, rsp.Total, err = models.GetChanceFavorites(
|
|
|
header.Uid,
|
|
|
header.CompanyId,
|
|
|
request.ObjectType,
|
...
|
...
|
@@ -46,8 +45,8 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
|
|
|
chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
|
|
|
chance.IsZan = (f.MarkFlag & protocol.MarkFlagZan) == protocol.MarkFlagZan
|
|
|
chance.IsCollect = (f.MarkFlag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
|
|
|
item.Favorite = chance
|
|
|
case protocol.SourceTypeComment:
|
|
|
}
|
...
|
...
|
@@ -67,12 +66,12 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
table string = "comment"
|
|
|
)
|
|
|
rsp = &protocol.SympathyActionResponse{}
|
|
|
if chanceFavoirte, err = repository.ChanceFavorite.GetChanceFavorite(header.Uid, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
|
|
|
if chanceFavoirte, err = models.GetChanceFavorite(header.Uid, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if request.SourceType == protocol.SourceTypeChance {
|
|
|
if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
|
|
|
if chance, err = models.GetChanceById(request.Id); err != nil {
|
|
|
log.Error("机会不存在", err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -81,28 +80,28 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
}
|
|
|
if chanceFavoirte != nil {
|
|
|
exists = true
|
|
|
if request.MarkType == protocol.MarkFlag_Zan {
|
|
|
if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Zan) == 0 {
|
|
|
if request.MarkType == protocol.MarkFlagZan {
|
|
|
if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagZan) == 0 {
|
|
|
err = protocol.NewSuccessWithMessage("已经取消赞,不能重复取消赞")
|
|
|
return
|
|
|
}
|
|
|
if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Zan) > 0 {
|
|
|
if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagZan) > 0 {
|
|
|
err = protocol.NewSuccessWithMessage("已经赞,不能重复点赞")
|
|
|
return
|
|
|
}
|
|
|
} else if request.MarkType == protocol.MarkFlag_Collect {
|
|
|
if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Collect) == 0 {
|
|
|
} else if request.MarkType == protocol.MarkFlagCollect {
|
|
|
if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagCollect) == 0 {
|
|
|
err = protocol.NewSuccessWithMessage("已经取消收藏,不能重复取消收藏")
|
|
|
return
|
|
|
}
|
|
|
if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Collect) > 0 {
|
|
|
if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagCollect) > 0 {
|
|
|
err = protocol.NewSuccessWithMessage("已经收藏,不能重复收藏")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if exists {
|
|
|
if err = repository.ChanceFavorite.UpdateChanceFavorite(header.Uid, header.CompanyId, request.Id, 1<<(uint(request.MarkType-1))); err != nil {
|
|
|
if err = models.UpdateChanceFavorite(header.Uid, header.CompanyId, request.Id, 1<<(uint(request.MarkType-1))); err != nil {
|
|
|
log.Error(request.MarkType, err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -120,7 +119,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
CreateAt: time.Now(),
|
|
|
EnableStatus: 1,
|
|
|
}
|
|
|
if _, err = repository.ChanceFavorite.AddChanceFavorite(chanceFavoirte); err != nil {
|
|
|
if _, err = models.AddChanceFavorite(chanceFavoirte); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
} else {
|
...
|
...
|
@@ -129,7 +128,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
}
|
|
|
END:
|
|
|
{
|
|
|
if request.MarkType != protocol.MarkFlag_Zan {
|
|
|
if request.MarkType != protocol.MarkFlagZan {
|
|
|
return
|
|
|
}
|
|
|
if request.SympathyType == protocol.UnMarkFlag {
|
...
|
...
|
@@ -394,7 +393,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat |
|
|
//1.检查是否是特殊审核人
|
|
|
for i := range configs {
|
|
|
config := configs[i]
|
|
|
if groupId == 0 && config.FlowType == protocol.FlowType_Normal {
|
|
|
if groupId == 0 && config.FlowType == protocol.FlowTypeNormal {
|
|
|
groupId = config.AuditGroupId
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -428,7 +427,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat |
|
|
return
|
|
|
}
|
|
|
|
|
|
if company, err = repository.Company.GetCompanyById(header.CompanyId); err != nil {
|
|
|
if company, err = models.GetCompanyById(header.CompanyId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -443,17 +442,17 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat |
|
|
config := configs[i]
|
|
|
var userIds []int64
|
|
|
switch config.AuditFlowType {
|
|
|
case protocol.AuditFlowType_Departmentor:
|
|
|
case protocol.AuditByDepartmentor:
|
|
|
if userIds, err = getDepartmentors(header); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
case protocol.AuditFlowType_User:
|
|
|
case protocol.AuditByUser:
|
|
|
if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
case protocol.AuditFlowType_Role:
|
|
|
case protocol.AuditByRole:
|
|
|
|
|
|
}
|
|
|
if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人
|
...
|
...
|
@@ -461,7 +460,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat |
|
|
}
|
|
|
for j := 0; j < len(userIds); j++ {
|
|
|
uid := userIds[j]
|
|
|
if uid == 0 && auditConfig.NoApprover == protocol.NoApprover_ToAdmin { //审批人为空 转交给管理员
|
|
|
if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员
|
|
|
uid = company.AdminId
|
|
|
}
|
|
|
if uid == header.Uid { //审核人自己 转交给管理员
|
...
|
...
|
@@ -508,7 +507,7 @@ func getDepartmentors(header *protocol.RequestHeader) (ids []int64, err error) { |
|
|
var (
|
|
|
departments []*protocol.Department
|
|
|
)
|
|
|
if err = repository.UserDepartment.GetUserDepartment(header.Uid, header.CompanyId, &departments); err != nil {
|
|
|
if err = models.GetUserDepartments(header.Uid, header.CompanyId, &departments); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -543,7 +542,7 @@ func getParentDepartmentors(pid int) (ids []int64) { |
|
|
if department.ParentId == 0 {
|
|
|
return
|
|
|
}
|
|
|
if department, err = repository.Department.GetDepartmentById(pid); err != nil {
|
|
|
if department, err = models.GetDepartmentById(pid); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
|