作者 tangxuhui

列表数据添加 权限标识

... ... @@ -8,53 +8,20 @@ import (
)
type CooperationApplicationItem struct {
CooperationProject struct {
CooperationProjectID string `json:"cooperationProjectId"` //共创项目
CooperationProjectName string `json:"cooperationProjectName"` //共创名称
CooperationProjectNumber string `json:"cooperationProjectNumber"` //共创编号
} `json:"cooperationProject"`
CooperationApplicationApplicant struct {
UserId int
UserInfo struct {
UserAvatar string
UserEmail string
UserName string
UserPhone string
UserAccount string
}
} `json:"cooperationApplicationApplicant"`
CooperationApplicationAttachment []domain.Attachment `json:"cooperationApplicationAttachment"` //附件
CooperationApplicationDescription string `json:"cooperationApplicationDescription"` //描述
CooperationApplicationID string `json:"cooperationApplicationId"` //id
IsCanceled bool `json:"isCanceled"` //是否取消
CooperationApplicationVerifyDescription string `json:"cooperationApplicationVerifyDescription"` //审核描述
CooperationApplicationVerifyTime time.Time `json:"cooperationApplicationVerifyTime"` //审核时间
CooperationApplicationStatus int `json:"cooperationApplicationStatus"` //
Org struct {
OrgID string `json:"orgId"`
OrgName string `json:"orgName"`
} `json:"org"` //组织
allied_creation_cooperation.CooperationApplication
AuthFlag bool `json:"authFlag"`
}
func ToCooperationApplicationItem(param *allied_creation_cooperation.CooperationApplication) *CooperationApplicationItem {
//data := CooperationApplicationItem{
// CooperationApplicationAttachment: param.CooperationApplicationAttachment,
// CooperationApplicationDescription: param.CooperationApplicationDescription,
// CooperationApplicationID: param.CooperationApplicationID,
// IsCanceled: param.IsCanceled,
// CooperationApplicationVerifyDescription: param.CooperationApplicationVerifyDescription,
// CooperationApplicationStatus: param.CooperationApplicationStatus,
// Org: param.Org,
//}
//data.CooperationApplicationApplicant.UserName = param.CooperationApplicationApplicant.UserInfo.UserName
//data.CooperationApplicationApplicant.Phone = param.CooperationApplicationApplicant.UserInfo.UserPhone
//data.CooperationApplicationApplicant.UserCode = param.CooperationApplicationApplicant.UserInfo.UserPhone
//data.CooperationApplicationApplicant.DepartmentName = param.CooperationApplicationApplicant.Department.DepartmentName
//data.CooperationProject.CooperationProjectID = param.CooperationProject.CooperationProjectID
//data.CooperationProject.CooperationProjectName = param.CooperationProject.CooperationProjectName
//data.CooperationProject.CooperationProjectNumber = param.CooperationProject.CooperationProjectNumber
//return &data
return nil
func ToCooperationApplicationItem(param []allied_creation_cooperation.CooperationApplication, operatorOrgId int64) []CooperationApplicationItem {
listData := []CooperationApplicationItem{}
for i := range param {
item := CooperationApplicationItem{
CooperationApplication: param[i],
AuthFlag: param[i].Org.OrgID == int(operatorOrgId),
}
listData = append(listData, item)
}
return listData
}
type CooperationApplicationInfo struct {
... ...
... ... @@ -3,6 +3,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationApplication/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationApplication/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationApplication/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
... ... @@ -73,15 +74,12 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//var dataList []dto.CooperationApplicationItem
//for i := range result.Grid.List {
// item := dto.ToCooperationApplicationItem(&result.Grid.List[i])
// dataList = append(dataList, *item)
//}
if len(result.Grid.List) == 0 {
result.Grid.List = []allied_creation_cooperation.CooperationApplication{}
}
return int64(result.Grid.Total), result.Grid.List, nil
listData := dto.ToCooperationApplicationItem(result.Grid.List, listCooperationApplicationQuery.Operator.OrgId)
return int64(result.Grid.Total), listData, nil
}
func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
... ...
... ... @@ -22,9 +22,10 @@ type CooperationContractItem struct {
Org domain.Org `json:"org"` //组织结构
CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
CooperationContractDescription string `json:"cooperationContractDescription"` //合约描述
AuthFlag bool `json:"authFlag"`
}
func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract) *CooperationContractItem {
func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract, operatorOrgId int64) *CooperationContractItem {
cooperationContractUndertakerType := param.CooperationContractUndertakerTypes
if len(cooperationContractUndertakerType) == 0 {
cooperationContractUndertakerType = []int{}
... ... @@ -38,6 +39,7 @@ func ToCooperationContractItem(param *allied_creation_cooperation.CooperationCon
CooperationContractNumber: param.CooperationContractNumber,
Status: param.Status,
CreateTime: int(param.CreatedAt.UnixNano() / 1e6),
AuthFlag: param.Org.OrgId == operatorOrgId,
}
data.CooperationContractSponsor.UserId = param.CooperationContractSponsor.UserId
data.CooperationContractSponsor.UserName = param.CooperationContractSponsor.UserInfo.UserName
... ... @@ -112,7 +114,7 @@ type CooperationContractInfo struct {
UndertakerTypesUncheckedAvailable []int `json:"undertakerTypesUncheckedAvailable"` // 可以去除勾选的共创项目承接对象列表
}
func ToCooperationContractInfo(param *allied_creation_cooperation.CooperationContract) *CooperationContractInfo {
func ToCooperationContractInfo(param *allied_creation_cooperation.CooperationContract, operatorOrgId int64) *CooperationContractInfo {
relevants := []Relevant{}
dividendsIncentivesRules := []DividendsIncentivesRule{}
... ... @@ -202,7 +204,7 @@ func ToCooperationContractInfo(param *allied_creation_cooperation.CooperationCon
undertakerTypesUncheckedAvailable = []int{}
}
data := CooperationContractInfo{
CooperationContract: *ToCooperationContractItem(param),
CooperationContract: *ToCooperationContractItem(param, operatorOrgId),
Relevant: relevants,
DividendsIncentivesRules: dividendsIncentivesRules,
MoneyIncentivesRules: moneyIncentivesRules,
... ...
... ... @@ -77,7 +77,8 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return dto.ToCooperationContractInfo(&result.CooperationContract), err
return dto.ToCooperationContractInfo(&result.CooperationContract, createCooperationContractCommand.Operator.OrgId), err
}
// 暂停恢复共创合约
... ... @@ -105,13 +106,12 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return dto.ToCooperationContractInfo(&result.CooperationContract), nil
return dto.ToCooperationContractInfo(&result.CooperationContract, getCooperationContractQuery.Operator.OrgId), nil
}
// 返回共创合约管理列表
func (cooperationContractService *CooperationContractService) ListCooperationContract(
listCooperationContractQuery *query.ListCooperationContractQuery) (int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listCooperationContractQuery.Operator)
result, err := creationCooperationGateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
PageNumber: listCooperationContractQuery.PageNumber,
... ... @@ -124,7 +124,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
}
data := []dto.CooperationContractItem{}
for i := range result.Grid.List {
item := dto.ToCooperationContractItem(&result.Grid.List[i])
item := dto.ToCooperationContractItem(&result.Grid.List[i], listCooperationContractQuery.Operator.OrgId)
data = append(data, *item)
}
... ... @@ -194,7 +194,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return dto.ToCooperationContractInfo(&result.CooperationContract), nil
return dto.ToCooperationContractInfo(&result.CooperationContract, updateCooperationContractCommand.Operator.OrgId), nil
}
func NewCooperationContractService(options map[string]interface{}) *CooperationContractService {
... ...
... ... @@ -17,4 +17,5 @@ type CooperationModeItem struct {
// 组织名称
OrgName string `json:"orgName"`
} `json:"org"`
AuthFlag bool `json:"authFlag"`
}
... ...
... ... @@ -51,6 +51,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
Status: result.Status,
CooperationModeNumber: result.CooperationModeNumber,
Org: result.Org,
AuthFlag: result.Org.OrgId == int(getCooperationModeQuery.Operator.OrgId),
}
return data, nil
}
... ... @@ -85,6 +86,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo
Status: v.Status,
CooperationModeNumber: v.CooperationModeNumber,
Org: v.Org,
AuthFlag: v.Org.OrgId == int(listCooperationModeQuery.Operator.OrgId),
}
listData = append(listData, item)
}
... ... @@ -169,6 +171,7 @@ func (cooperationModeService *CooperationModeService) CooperationModeSelector(li
Status: v.Status,
CooperationModeNumber: v.CooperationModeNumber,
Org: v.Org,
AuthFlag: v.Org.OrgId == int(listCooperationModeQuery.Operator.OrgId),
}
listData = append(listData, item)
}
... ...
... ... @@ -124,3 +124,22 @@ func ToCooperationApplicationItem(param *allied_creation_cooperation.Cooperation
return &data
//return nil
}
type CooperationProjectSearchItem struct {
allied_creation_cooperation.DataCooperationProjectSearchItem
AuthFlag bool `json:"authFlag"` //当前用户是否可以编辑
}
func ToCooperationProjectSearchItem(items []allied_creation_cooperation.DataCooperationProjectSearchItem, operatorOrgId int) []CooperationProjectSearchItem {
listData := []CooperationProjectSearchItem{}
operatorOrgIdStr := strconv.Itoa(operatorOrgId)
for i := range items {
listItem := CooperationProjectSearchItem{
DataCooperationProjectSearchItem: items[i],
AuthFlag: operatorOrgIdStr == items[i].Org.OrgID,
}
listData = append(listData, listItem)
}
return listData
}
... ...
... ... @@ -118,7 +118,8 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
if len(result.List) == 0 {
result.List = []allied_creation_cooperation.DataCooperationProjectSearchItem{}
}
return int64(result.Total), result.List, nil
listData := dto.ToCooperationProjectSearchItem(result.List, int(listCooperationProjectQuery.Operator.OrgId))
return int64(result.Total), listData, nil
}
// 更新共创项目管理
... ...
... ... @@ -182,10 +182,6 @@ type (
UserPhone string `json:"userPhone"`
UserAccount string `json:"userAccount"`
} `json:"userInfo"`
//UserType int `json:"userType"`
//UserName string `json:"userName"`
//UserPhone string `json:"userPhone"`
//Status int `json:"status"`
} `json:"cooperationProjectPublisher"`
CooperationProjectSponsor struct {
UserID string `json:"userId"`
... ...