作者 陈志颖

feat:增加共创合约查找功能

... ... @@ -10,21 +10,21 @@ import (
type SearchCooperationContractQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize" valid:"Required"`
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 页面大小
PageNumber int64 `cname:"页面大小" json:"pageNumber" valid:"Required"`
PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
// 共创合约编号
CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber,omitempty"`
// 发起人姓名
SponsorName string `cname:"发起人姓名" json:"sponsorName,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据is" json:"userBaseId,string" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
}
func (searchCooperationContractQuery *SearchCooperationContractQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -394,10 +394,27 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchCooperationContractQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": cooperationContracts,
},
}, nil
}
}
// SearchCooperationContractByUndertaker 根据承接人返回共创项目合约
... ...
... ... @@ -88,12 +88,6 @@ func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data ma
if departmentNumber, ok := data["departmentNumber"]; ok {
cooperationContractChangeLog.Operator.Department.DepartmentNumber = departmentNumber.(string)
}
if roleId, ok := data["roleId"]; ok {
cooperationContractChangeLog.Operator.Role.RoleId = roleId.(int64)
}
if roleName, ok := data["roleName"]; ok {
cooperationContractChangeLog.Operator.Role.RoleName = roleName.(string)
}
if userAvatar, ok := data["userAvatar"]; ok {
cooperationContractChangeLog.Operator.UserInfo.UserAvatar = userAvatar.(string)
}
... ...
... ... @@ -105,12 +105,6 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{}
if isOrganization, ok := data["isOrganization"]; ok {
cooperationProject.CooperationProjectPublisher.Department.IsOrganization = isOrganization.(bool)
}
if roleId, ok := data["roleId"]; ok {
cooperationProject.CooperationProjectPublisher.Role.RoleId = roleId.(int64)
}
if roleName, ok := data["roleName"]; ok {
cooperationProject.CooperationProjectPublisher.Role.RoleName = roleName.(string)
}
if userAvatar, ok := data["userAvatar"]; ok {
cooperationProject.CooperationProjectPublisher.UserInfo.UserAvatar = userAvatar.(string)
}
... ...
... ... @@ -118,12 +118,6 @@ func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{})
if isOrganization, ok := data["isOrganization"]; ok {
dividendsEstimate.DividendsUser.Department.IsOrganization = isOrganization.(bool)
}
if roleId, ok := data["roleId"]; ok {
dividendsEstimate.DividendsUser.Role.RoleId = roleId.(int64)
}
if roleName, ok := data["roleName"]; ok {
dividendsEstimate.DividendsUser.Role.RoleName = roleName.(string)
}
if userAvatar, ok := data["userAvatar"]; ok {
dividendsEstimate.DividendsUser.UserInfo.UserAvatar = userAvatar.(string)
}
... ...
... ... @@ -87,12 +87,6 @@ func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error
if companyName, ok := data["companyName"]; ok {
dividendsOrder.OrderSalesman.Org.Company.CompanyName = companyName.(string)
}
if roleId, ok := data["roleId"]; ok {
dividendsOrder.OrderSalesman.Role.RoleId = roleId.(int64)
}
if roleName, ok := data["roleName"]; ok {
dividendsOrder.OrderSalesman.Role.RoleName = roleName.(string)
}
if userAvatar, ok := data["userAvatar"]; ok {
dividendsOrder.OrderSalesman.UserInfo.UserAvatar = userAvatar.(string)
}
... ...
... ... @@ -95,12 +95,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]int
if orgId, ok := data["orgId"]; ok {
dividendsReturnedOrder.Org.OrgId = orgId.(int64)
}
if roleId, ok := data["roleId"]; ok {
dividendsReturnedOrder.Operator.Role.RoleId = roleId.(int64)
}
if roleName, ok := data["roleName"]; ok {
dividendsReturnedOrder.Operator.Role.RoleName = roleName.(string)
}
if userType, ok := data["userType"]; ok {
dividendsReturnedOrder.Operator.UserType = userType.(int32)
}
... ...
... ... @@ -13,9 +13,13 @@ type Participator struct {
// 用户所属的部门
Department *Department `json:"department"`
// 用户角色
Role *Role `json:"role"`
Roles []*Role `json:"role"`
// 冗余字段,jsonb格式,不限制存放内容
UserInfo *UserInfo `json:"userInfo"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 状态
... ...
... ... @@ -7,7 +7,7 @@ type Referrer struct {
// 用户基本id
UserBaseId int64 `json:"userBaseId,string"`
// 用户角色
Role *Role `json:"role"`
Roles []*Role `json:"role"`
// 用户关联的组织机构
Orgs []*Org `json:"orgs"`
// 用户所属的组织机构
... ... @@ -20,4 +20,8 @@ type Referrer struct {
UserInfo *UserInfo `json:"userInfo"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
}
... ...
... ... @@ -22,6 +22,10 @@ type Relevant struct {
UserInfo *UserInfo `json:"userInfo"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
// 状态
Status int32 `json:"status"`
// 公司
... ...
... ... @@ -7,7 +7,7 @@ type Salesman struct {
// 用户基本id
UserBaseId int64 `json:"userBaseId,string"`
// 用户角色
Role *Role `json:"role"`
Roles []*Role `json:"role"`
// 用户关联的组织机构
Orgs []*Org `json:"orgs"`
// 用户所属的组织机构
... ... @@ -20,4 +20,8 @@ type Salesman struct {
UserInfo *UserInfo `json:"userInfo"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
}
... ...
... ... @@ -22,6 +22,10 @@ type Undertaker struct {
UserInfo *UserInfo `json:"userInfo"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
// 推荐人
Referrer *Referrer `json:"referrer"`
// 关联业务员
... ...
... ... @@ -13,11 +13,15 @@ type User struct {
// 用户所属的部门
Department *Department `json:"department"`
// 用户角色
Role *Role `json:"role"`
Roles []*Role `json:"role"`
// 冗余字段,jsonb格式,不限制存放内容
UserInfo *UserInfo `json:"userInfo"`
// 用户类型
UserType int32 `json:"userType"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
// 状态
Status int32 `json:"status"`
// 用户关联公司信息
... ...
... ... @@ -680,6 +680,13 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
var cooperationContractModels []*models.CooperationContract
cooperationContracts := make([]*domain.CooperationContract, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions)
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
//query.Where(`cooperation_contract.cooperation_contract_sponsor->'userName' LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
}
query.SetOffsetAndLimit(20)
query.SetOrderDirect("cooperation_contract_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
... ...
... ... @@ -106,6 +106,8 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail)
UserAccount: "",
},
UserType: user.UserType,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: user.EnableStatus,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
... ... @@ -119,13 +121,15 @@ func (translator *UserTranslator) ToReferrerFromRepresentation(user *UserDetail)
return &domain.Referrer{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Role: nil,
Roles: nil,
Orgs: nil,
Org: nil,
Department: nil,
Company: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
}, nil
}
... ... @@ -139,6 +143,8 @@ func (translator *UserTranslator) ToUndertakerFromRepresentation(user *UserDetai
Roles: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
ContractAttachment: nil,
... ... @@ -149,13 +155,15 @@ func (translator *UserTranslator) ToSalesmanFromRepresentation(user *UserDetail)
return &domain.Salesman{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Role: nil,
Roles: nil,
Orgs: nil,
Org: nil,
Department: nil,
Company: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
}, nil
}
... ... @@ -166,9 +174,11 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail)
Org: nil,
Orgs: nil,
Department: nil,
Role: nil,
Roles: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
}, nil
... ... @@ -181,9 +191,11 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d
Org: nil,
Orgs: nil,
Department: nil,
Role: nil,
Roles: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
}, nil
... ...
... ... @@ -59,7 +59,6 @@ func (controller *CooperationContractController) RemoveCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
removeCooperationContractCommand := &command.RemoveCooperationContractCommand{}
_ = controller.Unmarshal(removeCooperationContractCommand)
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
removeCooperationContractCommand.CompanyId = header.CompanyId
removeCooperationContractCommand.OrgId = header.OrgId
... ... @@ -74,16 +73,12 @@ func (controller *CooperationContractController) RemoveCooperationContract() {
func (controller *CooperationContractController) SearchCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
searchCooperationContractQuery := &query.SearchCooperationContractQuery{}
// 解析头部信息
_ = controller.Unmarshal(searchCooperationContractQuery)
header := controller.GetRequestHeader(controller.Ctx)
searchCooperationContractQuery.CompanyId = header.CompanyId
searchCooperationContractQuery.OrgId = header.OrgId
searchCooperationContractQuery.UserId = header.UserId
searchCooperationContractQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
searchCooperationContractQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
searchCooperationContractQuery.PageNumber = pageNumber
data, err := cooperationContractService.SearchCooperationContract(searchCooperationContractQuery)
controller.Response(data, err)
}
... ...