作者 tangxuhui

更新 共创项目数据结构

... ... @@ -2,9 +2,10 @@ package service
import (
"errors"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/auth/command"
... ...
... ... @@ -14,8 +14,8 @@ type ListCooperationProjectQuery struct {
PageNumber int `json:"pageNumber"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
// 项目状态 全部、招标中、已结束
// Status int32 `json:"status" valid:"Required"`
// 项目状态 1招标中,2结束 0全部
Status int32 `json:"status" valid:"Required"`
//发起部门名称
DepartmentName string `json:"departmentName"`
//项目名称
... ...
package dto
//CooperationMode 共创模式
// type CooperationMode struct {
// CooperationModeID int `json:"cooperationModeId,string,"`
// CooperationModeName string `json:"cooperationModeName"`
// CooperationModeNumber string `json:"cooperationModeNumber"`
// }
//Department 部门
// type Department struct {
// DepartmentId int `json:"departmentId,string"`
// DepartmentName string `json:"departmentName"`
// DepartmentNumber string `json:"departmentNumber"`
// }
//UserBase 嵌套的用户数据
// type UserBase struct {
// UsersId int `json:"usersId"`
// UserInfo struct {
// UsersName string `json:"usersName"`
// UsersCode string `json:"usersCode"`
// Phone string `json:"phone"`
// UsersId int `json:"userId,string"`
// } `json:"cooperationProjectSpons"` //共创发起人
// }
//CooperationProjectItem 返回共创项目列表项
// type CooperationProjectItem struct {
// CooperationMode CooperationMode `json:"cooperationMode"` //共创模式
// CooperationProjectID int `json:"cooperationProjectId,string,"` //id
// CooperationProjectName string `json:"cooperationProjectName"` //共创项目名称
// CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
// CooperationProjectPublishTime string `json:"cooperationProjectPublishTime"` //共创项目发布时间
// Department Department `json:"department"` //项目发起部门
// Status int `json:"status"` //项目状态
// CooperationProjectSpons UserBase `json:"cooperationProjectSpons"`
// }
//CooperationProjectInfo 返回共创项目详情
// type CooperationProjectInfo struct {
// CooperationMode CooperationMode `json:"cooperationMode"` //共创模式
// CooperationProjectID int `json:"cooperationProjectId,string,"` //id
// CooperationProjectName string `json:"cooperationProjectName"` //共创项目名称
// CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
// CooperationProjectPublishTime string `json:"cooperationProjectPublishTime"` //共创项目发布时间
// Department Department `json:"department"` //项目发起部门
// Status int `json:"status"` //项目状态
// CooperationProjectSpons UserBase `json:"cooperationProjectSpons"` // 项目发起人
// }
... ...
package service
import (
"strconv"
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"strconv"
)
// CooperationProjectService 共创项目服务
... ... @@ -86,16 +87,18 @@ func (srv CooperationProjectService) EndCooperationProject(userMenusCommand *com
}
// SearchCooperationProject TODO:获取共创项目列表
func (srv CooperationProjectService) SearchCooperationProject(userMenusCommand *command.ListCooperationProjectQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
func (srv CooperationProjectService) SearchCooperationProject(projectQuery *command.ListCooperationProjectQuery) (int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
PageNumber: projectQuery.PageNumber,
PageSize: projectQuery.PageSize,
Status: int(projectQuery.Status),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
// var dataList []dto.CooperationProjectItem
//TODO 数据填充
return int(result.Total), result.CooperationProjects, nil
}
... ...
... ... @@ -65,7 +65,7 @@ func (srv UserService) ChangePassword(changePasswordCommand *command.ChangePassw
return struct{}{}, nil
}
//ChangePassword 修改密码
//ChangePhone 修改手机号
func (srv UserService) ChangePhone(resetPhoneCommand *command.ResetPhoneCommand) (interface{}, error) {
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
err := smsServeGateway.CheckSmsCode(resetPhoneCommand.NewPhone, resetPhoneCommand.SmsCode)
... ... @@ -85,8 +85,8 @@ func (srv UserService) ChangePhone(resetPhoneCommand *command.ResetPhoneCommand)
return struct{}{}, nil
}
//UpdateUserInfo 更新用户信息
func (srv UserService) UpdateUserInfo(updateUserInfoCommand *command.UpdateUserInfoCommand) (interface{}, error) {
//UpdateUserBaseInfo 更新用户信息
func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateUserInfoCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
user, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: int(updateUserInfoCommand.Operator.UserId),
... ... @@ -94,10 +94,24 @@ func (srv UserService) UpdateUserInfo(updateUserInfoCommand *command.UpdateUserI
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
}
var (
userName string
avatar string
)
if len(updateUserInfoCommand.Avatar) > 0 {
avatar = user.UserInfo.Avatar
} else {
avatar = updateUserInfoCommand.Avatar
}
if len(updateUserInfoCommand.UserName) > 0 {
userName = updateUserInfoCommand.UserName
} else {
userName = user.UserInfo.UserName
}
_, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{
UserId: int64(user.UserId),
UserName: updateUserInfoCommand.UserName,
Avatar: updateUserInfoCommand.Avatar,
UserName: userName,
Avatar: avatar,
Phone: user.UserInfo.Phone,
Email: user.UserInfo.Email,
})
... ...
... ... @@ -138,7 +138,7 @@ func (srv AuthService) GetQrcode() (interface{}, error) {
return data, nil
}
//QrcodeLoginStatus 扫码登录状态
//QrcodeLoginStatus 询问扫码登录状态
func (srv AuthService) QrcodeLoginStatus(queryParam query.QrcodeLoginStatusQuery) (interface{}, error) {
qrmsg := domain.QrcodeMessage{}
err := qrmsg.ParseToken(queryParam.Token)
... ... @@ -150,8 +150,23 @@ func (srv AuthService) QrcodeLoginStatus(queryParam query.QrcodeLoginStatusQuery
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
loginToken := domain.LoginToken{
UserId: qrmsgCache.UserId,
UserBaseId: qrmsgCache.UserBaseId,
Account: qrmsgCache.Account,
Platform: domain.LoginPlatformWeb,
CompanyId: qrmsgCache.CompanyId,
OrgId: qrmsgCache.OrgId,
}
accessToken, err := loginToken.GenerateAccessToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
_ = accessToken
//TODO 填充token数据
data := map[string]interface{}{
"isLogin": qrmsgCache.IsLogin,
"isLogin": qrmsgCache.IsLogin,
"accessToken": "",
}
return data, nil
}
... ...
package allied_creation_cooperation
import "time"
type CooperationProject struct {
Company struct {
CompanyId int `json:"companyId,string,"`
CompanyLogo string `json:"companyLogo"`
CompanyName string `json:"companyName"`
} `json:"company"` //项目归属企业
Org struct {
OrgId int `json:"orgId"`
OrgName string `json:"orgName"`
} `json:"org"` //项目创建时的组织
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string,"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //项目模式
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Attachment []struct {
FileType string `json:"fileType"`
Name string `json:"name"`
Url string `json:"url"`
FileSize int `json:"fileSize"`
} `json:"attachment"` //图片附件
CooperationProjectId int `json:"cooperationProjectId,string,"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectNumber string `json:"cooperationProjectNumber"`
CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
CreatedAt time.Time `json:"createdAt"`
CooperationProjectPublisher struct {
UsersId int `json:"usersId"`
UserInfo struct {
UsersName string `json:"usersName"`
UsersCode string `json:"usersCode"`
Phone string `json:"phone"`
UsersId int `json:"userId,string,"`
} `json:"userInfo"`
} `json:"cooperationProjectPublisher"` //项目发布人,即操作人
CooperationProjectSponsor struct {
UsersId int `json:"usersId"`
UserInfo struct {
UsersName string `json:"usersName"`
UsersCode string `json:"usersCode"`
Phone string `json:"phone"`
UsersId int `json:"userId,string,"`
} `json:"userInfo"`
} `json:"cooperationProjectSponsor"` //项目发起人
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
Department struct {
DepartmentNumber string `json:"departmentNumber"`
DepartmentId int `json:"departmentId,string,"`
DepartmentName string `json:"departmentName"`
} `json:"department"` //项目发起部门
Status int `json:"status"`
}
//创建共创项目
type (
ReqCooperationProjectAdd struct {
... ... @@ -12,7 +68,7 @@ type (
}
DataCooperationProjectAdd struct {
CooperationProjectId int `json:"cooperationProjectId"`
CooperationProject
}
)
... ... @@ -32,47 +88,7 @@ type (
}
DataCooperationProjectGet struct {
CooperationProject struct {
CooperationMode struct {
CooperationModeID int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"`
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Images []string `json:"images"`
CooperationProjectID int `json:"cooperationProjectId,string"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectNumber string `json:"cooperationProjectNumber"`
CooperationProjectPublishTime string `json:"cooperationProjectPublishTime"`
CooperationProjectPublisher struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline string `json:"cooperationDeadline"`
Email string `json:"email"`
Phone string `json:"phone"`
Status int `json:"status"`
UsersCode string `json:"usersCode"`
UsersID int `json:"usersId,string"`
UsersName string `json:"usersName"`
} `json:"cooperationProjectPublisher"`
CooperationProjectSponsor struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline string `json:"cooperationDeadline"`
Email string `json:"email"`
Phone string `json:"phone"`
Status int `json:"status"`
UsersCode string `json:"usersCode"`
UsersID int `json:"usersId,string"`
UsersName string `json:"usersName"`
} `json:"cooperationProjectSponsor"`
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"`
Department struct {
CompanyID int `json:"companyId,string"`
OrgCode string `json:"orgCode"`
OrgID int `json:"orgId,string"`
OrgName string `json:"orgName"`
} `json:"department"`
Status int `json:"status"`
} `json:"cooperationProject"`
CooperationProject CooperationProject `json:"cooperationProject"`
}
)
... ... @@ -95,6 +111,7 @@ type (
}
DataCooperationProjectUpdate struct {
CooperationProject
}
)
... ... @@ -126,52 +143,13 @@ type (
DepartmentName string `json:"departmentName"`
//项目名称
CooperationProjectName string `json:"cooperationProjectName"`
Status int `json:"status"`
// 共创项目状态,1招标中,2结束 0 全部
Status int `json:"status"`
}
DataCooperationProjectSearch struct {
Total int64 `json:"total"`
CooperationProjects []struct {
CooperationMode struct {
CooperationModeID int `json:"cooperationModeId,string,"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"`
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Images []string `json:"images"`
CooperationProjectID int `json:"cooperationProjectId,string,"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectNumber string `json:"cooperationProjectNumber"`
CooperationProjectPublishTime string `json:"cooperationProjectPublishTime"`
CooperationProjectPublisher struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline string `json:"cooperationDeadline"`
Email string `json:"email"`
Phone string `json:"phone"`
Status int `json:"status"`
UsersCode string `json:"usersCode"`
UsersID int `json:"usersId,string,"`
UsersName string `json:"usersName"`
} `json:"cooperationProjectPublisher"`
CooperationProjectSponsor struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline string `json:"cooperationDeadline"`
Email string `json:"email"`
Phone string `json:"phone"`
Status int `json:"status"`
UsersCode string `json:"usersCode"`
UsersID int `json:"usersId,string,"`
UsersName string `json:"usersName"`
} `json:"cooperationProjectSponsor"`
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"`
Department struct {
CompanyID int `json:"companyId,string,"`
OrgCode string `json:"orgCode"`
OrgID int `json:"orgId,string,"`
OrgName string `json:"orgName"`
} `json:"department"`
Status int `json:"status"`
} `json:"cooperationProjects"`
Total int64 `json:"total"`
CooperationProjects []CooperationProject `json:"cooperationProjects"`
}
)
... ...
... ... @@ -194,7 +194,7 @@ func (controller *CooperationController) SearchCooperationProject() {
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchCooperationProject(cmd)
_, data, err := svr.SearchCooperationProject(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -68,6 +68,6 @@ func (controller *UserController) UpdateUserInfo() {
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.UpdateUserInfo(cmd)
data, err := authService.UpdateUserBaseInfo(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -7,15 +7,17 @@ import (
)
func init() {
//登录注册
web.Router("/v1/app/users/regist/company", &common_controller.CommonController{}, "Post:CompanySignUp")
web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login")
web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken")
web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken")
//获取用户数据
web.Router("/v1/app/user/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/app/user/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/app/user/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
//公司用户注册
web.Router("/v1/app/auth/company-sign-up", &mobile_client.AuthController{}, "Post:CompanySignUp")
//公司重置密码
web.Router("/v1/app/auth/reset-password", &mobile_client.AuthController{}, "Post:ResetPassword")
}
... ...