作者 陈志颖

feat:共创模式查找功能调整

... ... @@ -18,7 +18,7 @@ type RemoveCooperationModeCommand struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据is" json:"userBaseId,string"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string"`
}
func (removeCooperationModeCommand *RemoveCooperationModeCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -24,7 +24,7 @@ type UpdateCooperationModeCommand struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据is" json:"userBaseId,string"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string"`
}
func (updateCooperationModeCommand *UpdateCooperationModeCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -12,13 +12,13 @@ type GetCooperationModeQuery struct {
// 共创模式ID
CooperationModeId int64 `cname:"共创模式ID" json:"cooperationModeId,string" valid:"Required"`
// 公司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" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据is" json:"userBaseId,string"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string"`
}
func (getCooperationModeQuery *GetCooperationModeQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -14,7 +14,7 @@ type ListCooperationModeQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,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上下文获取,可翻译成发起人、承接人、推荐人、业务员
... ...
... ... @@ -14,7 +14,7 @@ type SearchCooperationModeQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 共创模式名称
CooperationModeName string `cname:"共创模式名称" json:"cooperationModeName" valid:"Required"`
CooperationModeName string `cname:"共创模式名称" json:"cooperationModeName,omitempty"`
// 组织机构名称
OrganizationName string `cname:"组织机构名称" json:"organizationName,omitempty"`
// 公司ID,通过集成REST上下文获取
... ...
... ... @@ -246,10 +246,27 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationModeRepository = value
}
if count, cooperationModes, err := cooperationModeRepository.Find(tool_funs.SimpleStructToMap(searchCooperationModeQuery)); 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 map[string]interface{}{
"grid": map[string]interface{}{
"list": cooperationModes,
"total": count,
},
}, nil
}
return nil, nil
}
// UpdateCooperationMode 更新共创模式服务
... ... @@ -280,7 +297,7 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationModeCommand.CooperationModeId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCooperationModeCommand.CooperationModeId, 10)))
}
if err := cooperationMode.Update(tool_funs.SimpleStructToMap(updateCooperationModeCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -155,6 +155,12 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf
var cooperationModeModels []*models.CooperationMode
cooperationModes := make([]*domain.CooperationMode, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationModeModels), queryOptions)
if cooperationModeName, ok := queryOptions["cooperationModeName"]; ok && cooperationModeName != "" {
query.Where("cooperation_mode_name like ?", fmt.Sprintf("%%%s%%", cooperationModeName))
}
if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
}
query.SetOffsetAndLimit(20)
query.SetOrderDirect("cooperation_mode_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
... ...
... ... @@ -74,6 +74,7 @@ func (controller *CooperationModeController) RemoveCooperationMode() {
func (controller *CooperationModeController) SearchCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
searchCooperationModeQuery := &query.SearchCooperationModeQuery{}
_ = controller.Unmarshal(searchCooperationModeQuery)
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
searchCooperationModeQuery.CompanyId = header.CompanyId
... ...