作者 yangfu

共创统计修改

... ... @@ -11,7 +11,7 @@ type EndCooperationProjectCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目id
CooperationProjectId []int `json:"cooperationProjectId,omitempty"`
CooperationProjectId int `json:"cooperationProjectId,omitempty"`
}
func (endCooperationProjectCommand *EndCooperationProjectCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -9,7 +9,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// CooperationProjectService 共创项目服务 【完成
// CooperationProjectService 共创项目服务 【90%
type CooperationProjectService struct {
}
... ... @@ -69,21 +69,19 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP
return updateCooperationProjectCommand, nil
}
// EndCooperationProject 企业结束共创项目
// EndCooperationProject TODO:企业结束共创项目
func (srv CooperationProjectService) EndCooperationProject(endCooperationProjectCommand *command.EndCooperationProjectCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
//creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
var projectIds []string
for _, v := range endCooperationProjectCommand.CooperationProjectId {
idStr := strconv.Itoa(v)
idStr := strconv.Itoa(endCooperationProjectCommand.CooperationProjectId)
projectIds = append(projectIds, idStr)
}
_, err := creationCooperationGateway.CooperationProjectBatchEnd(allied_creation_cooperation.ReqCooperationProjectBatchEnd{
CooperationProjectIds: projectIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return endCooperationProjectCommand, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//_, err := creationCooperationGateway.CooperationProjectBatchEnd(allied_creation_cooperation.ReqCooperationProjectBatchEnd{
// CooperationProjectIds: projectIds,
//})
//if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//}
return endCooperationProjectCommand, nil
}
// SearchCooperationProject 企业获取共创项目列表
... ...
... ... @@ -31,7 +31,7 @@ func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.Go
return map[string]interface{}{}, nil
}
// CooperationDividendsStatistics TODO:共创分红支出统计
// CooperationDividendsStatistics TODO:公司共创人员列表(分红支出统计)
func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) {
return map[string]interface{}{}, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// 个人端统计 【0%】
... ... @@ -65,7 +67,16 @@ func (srv PersonStatisticsService) CompanyDividendStatistics(userMenusCommand *c
return map[string]interface{}{}, nil
}
// CooperationProjectRecommend 猜你喜欢(共创项目)
func (srv PersonStatisticsService) CooperationProjectRecommend(userMenusCommand *command.GoodsStatisticsCommand) (interface{}, error) {
return map[string]interface{}{}, nil
// CooperationProjectRecommend TODO:其他公司按公开的项目查 猜你喜欢(共创项目)
func (srv PersonStatisticsService) CooperationProjectRecommend(projectQuery *command.ListCooperationProjectQuery) (int64, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
PageNumber: projectQuery.PageNumber,
PageSize: projectQuery.PageSize,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return int64(result.Total), result.List, nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
//标记已读
type MessageMarkReadCommand struct {
Operator domain.Operator `json:"-"`
MsgId int `json:"msgId"`
ReadAll int `json:"readAll"`
}
func (cmd *MessageMarkReadCommand) Valid(validation *validation.Validation) {
}
func (cmd *MessageMarkReadCommand) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -166,10 +166,15 @@ func (srv UserService) DepartmentsUsers(departmentsUsersQuery *query.Departments
}
//MessagesList 消息列表
func (srv UserService) MessagesList(messagesListQuery *query.MessagesListQuery) (int64, interface{}, error) {
func (srv UserService) MessagesList(cmd *query.MessagesListQuery) (int64, interface{}, error) {
var results []*dto.MessageDto
for i := 0; i < 5; i++ {
results = append(results, dto.NewMessageDto())
}
return 2, results, nil
}
//MessagesList 消息列表
func (srv UserService) MessagesMarkRead(cmd *command.MessageMarkReadCommand) (interface{}, error) {
return struct{}{}, nil
}
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
type OrgItem struct {
OrgId string `json:"orgId"`
OrgName string `json:"orgName"`
... ... @@ -9,3 +14,71 @@ type OrgItem struct {
ParentDepName string `json:"parentDepName"`
OrgStatus int `json:"orgStatus"`
}
type DepartmentUsersDto struct {
Departments []*Department `json:"departments,omitempty"`
Users []interface{} `json:"users,omitempty"`
}
type Department struct {
DepartmentID int64 `json:"departmentId,string"`
DepartmentName string `json:"departmentName"`
Users []User `json:"users"`
}
type User struct {
UserID int `json:"userId,string"`
UserCode string `json:"userCode"`
UserInfo map[string]interface{} `json:"userInfo"`
}
func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
if dataType == 1 {
for i := range userSearch.Users {
user := userSearch.Users[i]
dto.Users = append(dto.Users, map[string]interface{}{
"userId": user.UserId,
"userInfo": user.UserInfo,
"department": user.Department,
})
}
return nil
}
var mapDepartment = make(map[int64]*Department)
mapDepartment[-1] = &Department{
DepartmentID: -1,
DepartmentName: "共创部门",
Users: make([]User, 0),
}
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]
u := User{
UserID: user.UserId,
UserCode: user.UserCode,
UserInfo: map[string]interface{}{
"userName": user.UserInfo.UserName,
"phone": user.UserInfo.Phone,
},
}
if (user.UserType & domain.UserTypeCooperation) > 0 {
mapDepartment[-1].Users = append(mapDepartment[-1].Users, u)
continue
}
if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
v.Users = append(v.Users, u)
}
}
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:"-"`
// 类型0:部门用户列表 1:全部用户列表(不包含部门)
Type int `json:"type"`
}
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
}
... ...
... ... @@ -148,6 +148,31 @@ 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{
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(departmentsUsersQuery.Type, 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
... ...
... ... @@ -555,13 +555,13 @@ func (controller *CooperationController) PersonCompanyDividendStatistics() {
func (controller *CooperationController) PersonCooperationProjectRecommend() {
svr := service.PersonStatisticsService{}
cmd := &command.GoodsStatisticsCommand{}
cmd := &command.ListCooperationProjectQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CooperationProjectRecommend(cmd)
controller.Response(data, err)
total, data, err := svr.CooperationProjectRecommend(cmd)
controller.ReturnPageListData(total, data, err, cmd.PageNumber)
}
... ...
... ... @@ -111,3 +111,16 @@ func (controller *UserController) Messages() {
total, data, err := svr.MessagesList(messagesListQuery)
controller.ReturnPageListData(total, data, err, messagesListQuery.PageNumber)
}
func (controller *UserController) MessagesMarkRead() {
svr := service.UserService{}
cmd := &command.MessageMarkReadCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.MessagesMarkRead(cmd)
controller.Response(data, err)
}
... ...
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/service"
)
type OrgController struct {
baseController
}
func (controller *OrgController) 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)
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
"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"
)
func init() {
... ... @@ -19,9 +20,9 @@ func init() {
web.Router("/v1/user/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount")
web.Router("/v1/user/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers")
web.Router("/v1/user/msgs", &mobile_client.UserController{}, "Post:Messages")
web.Router("/v1/user/msgs/mark-read", &mobile_client.UserController{}, "Post:Messages")
web.Router("/v1/user/msgs/mark-read", &mobile_client.UserController{}, "Post:MessagesMarkRead")
// 特殊处理
web.Router("/v1/app/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers")
web.Router("/v1/web/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers")
web.Router("/v1/web/orgs/department-users", &web_client.OrgController{}, "Post:DepartmentUsers")
}
... ...