作者 yangfu

选择器修改

package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// 共创项目用户查询
type CooperationProjectUsersQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目ID - 获取项目申请人列表
CooperationProjectId int `json:"cooperationProjectId,string"`
}
func (departmentsUsersQuery *CooperationProjectUsersQuery) Valid(validation *validation.Validation) {
}
func (departmentsUsersQuery *CooperationProjectUsersQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(departmentsUsersQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -3,6 +3,7 @@ package service
import (
"crypto/sha1"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
"strconv"
"time"
... ... @@ -570,3 +571,46 @@ func (usersService *UsersService) GetInitPassword(operator domain.Operator) (str
password = fmt.Sprintf("%x", sha1.Sum([]byte(reqResult.Value)))
return password, reqResult.Value, err
}
// SelectorCooperationProjectUsers 共创项目用户下拉列表
func (usersService *UsersService) SelectorCooperationProjectUsers(q *query.CooperationProjectUsersQuery) (interface{}, error) {
applications := make([]interface{}, 0)
// 项目申请人
if q.CooperationProjectId != 0 {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(q.Operator)
resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
CooperationProjectId: q.CooperationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
resultApplication, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
CooperationProjectNumber: resultProject.CooperationProject.CooperationProjectNumber,
PageNumber: 0,
PageSize: 1000,
CompanyId: resultProject.Company.CompanyId,
OrgId: int64(resultProject.Org.OrgId),
CooperationApplicationStatus: 2, //审核通过的
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
for i := range resultApplication.Grid.List {
item := resultApplication.Grid.List[i]
user := map[string]interface{}{
"userId": item.CooperationApplicationApplicant.UserID,
"userCode": item.CooperationApplicationApplicant.UserInfo.UserCode,
"userInfo": map[string]interface{}{
"userName": item.CooperationApplicationApplicant.UserInfo.UserName,
"phone": item.CooperationApplicationApplicant.UserInfo.UserPhone,
},
"department": item.CooperationApplicationApplicant.Department,
}
applications = append(applications, user)
}
}
return map[string]interface{}{
"applicants": applications,
}, nil
}
... ...
... ... @@ -157,3 +157,13 @@ func (controller *UsersController) SelectorCompanyOrgAll() {
_, data, err := usersService.SelectorCompanyOrgAll(selectorQuery)
controller.Response(data, err)
}
//CompanyOrgSelector 全组织部门选择表
func (controller *UsersController) SelectorCooperationProjectUsers() {
usersService := service.NewUsersService(nil)
selectorQuery := &query.CooperationProjectUsersQuery{}
controller.Unmarshal(selectorQuery)
selectorQuery.Operator = controller.GetOperator()
data, err := usersService.SelectorCooperationProjectUsers(selectorQuery)
controller.Response(data, err)
}
... ...
... ... @@ -21,4 +21,6 @@ func init() {
web.Router("/v1/web/users/selector/org", &web_client.UsersController{}, "Post:SelectorCompanyOrg")
web.Router("/v1/web/users/selector/role", &web_client.UsersController{}, "Post:SelectorCompanyRole")
web.Router("/v1/web/users/selector/org/all", &web_client.UsersController{}, "Post:SelectorCompanyOrgAll")
web.Router("/v1/web/users/selector/cooperation-project-users", &web_client.UsersController{}, "Post:SelectorCooperationProjectUsers")
}
... ...