作者 yangfu

共创申请修改

... ... @@ -72,11 +72,11 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var dataList []dto.CooperationApplicationItem
for i := range result.Gride.List {
item := dto.ToCooperationApplicationItem(&result.Gride.List[i])
for i := range result.Grid.List {
item := dto.ToCooperationApplicationItem(&result.Grid.List[i])
dataList = append(dataList, *item)
}
return int64(result.Gride.Total), dataList, nil
return int64(result.Grid.Total), dataList, nil
}
func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
... ...
... ... @@ -30,7 +30,7 @@ type CooperationProjectInfo struct {
CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
CreatedAt time.Time `json:"createdAt"`
CooperationProjectSponsor struct {
UsersId int `json:"userId"`
UserId int `json:"userId,string"`
UsersName string `json:"userName"`
UsersCode string `json:"userCode"`
UserInfo struct {
... ... @@ -68,7 +68,7 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj
data.CooperationProjectSponsor.UsersCode = param.CooperationProjectSponsor.UserInfo.UsersCode
data.CooperationProjectSponsor.UsersName = param.CooperationProjectSponsor.UserInfo.UsersName
data.CooperationProjectSponsor.UsersId = param.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserId = param.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo = param.CooperationProjectSponsor.UserInfo
return &data
}
... ...
... ... @@ -89,8 +89,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
var (
applications []dto.CooperationApplicationItem
)
for i := range resultApplication.Gride.List {
item := dto.ToCooperationApplicationItem(&resultApplication.Gride.List[i])
for i := range resultApplication.Grid.List {
item := dto.ToCooperationApplicationItem(&resultApplication.Grid.List[i])
applications = append(applications, *item)
}
data := map[string]interface{}{
... ...
package dto
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
type DepartmentUsersDto struct {
Departments []*Department `json:"departments"`
}
type Department struct {
DepartmentID int64 `json:"departmentId,string"`
DepartmentName string `json:"departmentName"`
Users []User `json:"users"`
}
type User struct {
UserID int `json:"userId,string"`
UserInfo map[string]interface{} `json:"userInfo"`
}
func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
var mapDepartment = make(map[int64]*Department)
for i := range subDepartment.Orgs {
org := subDepartment.Orgs[i]
dep := &Department{
DepartmentID: int64(org.OrgID),
DepartmentName: org.OrgName,
Users: make([]User, 0),
}
dto.Departments = append(dto.Departments, dep)
mapDepartment[dep.DepartmentID] = dep
}
for i := range userSearch.Users {
user := userSearch.Users[i]
if user.Department == nil {
continue
}
if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
v.Users = append(v.Users, User{
UserID: user.UserId,
UserInfo: map[string]interface{}{
"userName": user.UserInfo.UserName,
},
})
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
//获取自定义菜单列表
type DepartmentsUsersQuery struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
}
func (departmentsUsersQuery *DepartmentsUsersQuery) 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
}
... ...
... ... @@ -147,6 +147,33 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub
}, nil
}
//DepartmentsUsers 部门用户列表
func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsUsersQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
departmentsUsersQuery.Operator)
orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{
OrgId: departmentsUsersQuery.Operator.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
//Offset: 0,
//Limit: 999,
CompanyId: departmentsUsersQuery.Operator.CompanyId,
OrganizationId: departmentsUsersQuery.Operator.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
departmentUsersDto := &dto.DepartmentUsersDto{}
if err := departmentUsersDto.LoadDto(orgs, users); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return departmentUsersDto, nil
}
func NewOrgsService(options map[string]interface{}) *OrgsService {
newOrgsService := &OrgsService{}
return newOrgsService
... ...
... ... @@ -227,10 +227,10 @@ type (
}
DataCooperationApplicationSearch struct {
Gride struct {
Grid struct {
Total int `json:"total"`
List []CooperationApplication `json:"list"`
} `json:"gride"`
} `json:"grid"`
}
)
... ...
... ... @@ -52,7 +52,7 @@ type CooperationProject struct {
UsersId int `json:"userId,string"`
} `json:"userInfo"`
} `json:"cooperationProjectSponsor"` //项目发起人
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerTypes"` //共创合约承接对象,1员工,2共创用户,3公开
Department struct {
DepartmentNumber string `json:"departmentNumber"`
DepartmentId int `json:"departmentId,string,"`
... ... @@ -95,7 +95,7 @@ type (
}
DataCooperationProjectGet struct {
CooperationProject CooperationProject `json:"cooperationProject"`
CooperationProject
}
)
... ... @@ -108,7 +108,7 @@ type (
CooperationProjectName string `json:"cooperationProjectName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
// 承接对象,1员工,2共创用户,3公开,可以多选
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"`
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerTypes"`
// 共创项目发起人uid
SponsorUid string `json:"sponsorUid"`
// 共创项目发布人uid
... ...
... ... @@ -82,3 +82,16 @@ func (controller *OrgsController) OrgGetSubDepartment() {
data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery)
controller.Response(data, err)
}
func (controller *OrgsController) DepartmentUsers() {
orgService := service.OrgsService{}
departmentsUsersQuery := &query.DepartmentsUsersQuery{}
err := controller.Unmarshal(departmentsUsersQuery)
if err != nil {
controller.Response(nil, err)
return
}
departmentsUsersQuery.Operator = controller.GetOperator()
data, err := orgService.DepartmentsUsers(departmentsUsersQuery)
controller.Response(data, err)
}
... ...
... ... @@ -2,7 +2,6 @@ package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
)
... ... @@ -13,5 +12,5 @@ func init() {
web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet")
web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable")
web.Router("/v1/web/orgs/departments", &web_client.OrgsController{}, "Post:OrgGetSubDepartment")
web.Router("/v1/web/orgs/department-users", &mobile_client.OrgController{}, "Post:DepartmentUsers")
web.Router("/v1/web/orgs/department-users", &web_client.OrgsController{}, "Post:DepartmentUsers")
}
... ...