正在显示
5 个修改的文件
包含
47 行增加
和
5 行删除
| @@ -24,7 +24,7 @@ type BatchOperateCooperationModeCommand struct { | @@ -24,7 +24,7 @@ type BatchOperateCooperationModeCommand struct { | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | func (batchOperateCooperationModeCommand *BatchOperateCooperationModeCommand) Valid(validation *validation.Validation) { | 26 | func (batchOperateCooperationModeCommand *BatchOperateCooperationModeCommand) Valid(validation *validation.Validation) { |
| 27 | - //validation.SetError("CustomValid", "未实现的自定义认证") | 27 | + |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | func (batchOperateCooperationModeCommand *BatchOperateCooperationModeCommand) ValidateCommand() error { | 30 | func (batchOperateCooperationModeCommand *BatchOperateCooperationModeCommand) ValidateCommand() error { |
| @@ -10,7 +10,7 @@ import ( | @@ -10,7 +10,7 @@ import ( | ||
| 10 | 10 | ||
| 11 | type BatchRemoveCooperationModeCommand struct { | 11 | type BatchRemoveCooperationModeCommand struct { |
| 12 | // 共创模式ID数组 | 12 | // 共创模式ID数组 |
| 13 | - CooperationModeIds []string `cname:"共创模式ID数组" json:"cooperationModeIds,string" valid:"Required"` | 13 | + CooperationModeIds []string `cname:"共创模式ID数组" json:"cooperationModeIds,string"` |
| 14 | // 公司ID,通过集成REST上下文获取 | 14 | // 公司ID,通过集成REST上下文获取 |
| 15 | CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | 15 | CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` |
| 16 | // 组织机构ID | 16 | // 组织机构ID |
| @@ -22,7 +22,19 @@ type BatchRemoveCooperationModeCommand struct { | @@ -22,7 +22,19 @@ type BatchRemoveCooperationModeCommand struct { | ||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) Valid(validation *validation.Validation) { | 24 | func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) Valid(validation *validation.Validation) { |
| 25 | - //validation.SetError("CustomValid", "未实现的自定义认证") | 25 | + if len(batchRemoveCooperationModeCommand.CooperationModeIds) > 0 { |
| 26 | + for _, cooperationModeId := range batchRemoveCooperationModeCommand.CooperationModeIds { | ||
| 27 | + switch v := reflect.ValueOf(cooperationModeId); v.Kind() { | ||
| 28 | + case reflect.String: | ||
| 29 | + fmt.Println(v.String()) | ||
| 30 | + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: | ||
| 31 | + fmt.Println(v.Int()) | ||
| 32 | + _ = validation.SetError("CustomValid", "共创模式ID类型错误") | ||
| 33 | + default: | ||
| 34 | + fmt.Printf("unhandled kind %s", v.Kind()) | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + } | ||
| 26 | } | 38 | } |
| 27 | 39 | ||
| 28 | func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) ValidateCommand() error { | 40 | func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) ValidateCommand() error { |
| @@ -464,10 +464,13 @@ func (cooperationModeService *CooperationModeService) BatchOperateCooperationMod | @@ -464,10 +464,13 @@ func (cooperationModeService *CooperationModeService) BatchOperateCooperationMod | ||
| 464 | } else { | 464 | } else { |
| 465 | cooperationModeDao = value | 465 | cooperationModeDao = value |
| 466 | } | 466 | } |
| 467 | - if len(batchOperateCooperationModeCommand.CooperationModeIds) == 0 { | 467 | + if len(batchOperateCooperationModeCommand.CooperationModeIds) <= 0 { |
| 468 | return map[string]interface{}{}, nil | 468 | return map[string]interface{}{}, nil |
| 469 | } | 469 | } |
| 470 | - cooperationModeIds, _ := utils.SliceAtoi(batchOperateCooperationModeCommand.CooperationModeIds) | 470 | + cooperationModeIds, err := utils.SliceAtoi(batchOperateCooperationModeCommand.CooperationModeIds) |
| 471 | + if err != nil { | ||
| 472 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创模式ID错误") | ||
| 473 | + } | ||
| 471 | if cooperationModes, err := cooperationModeDao.UpdateCooperationModeSlice(cooperationModeIds, batchOperateCooperationModeCommand.Status); err != nil { | 474 | if cooperationModes, err := cooperationModeDao.UpdateCooperationModeSlice(cooperationModeIds, batchOperateCooperationModeCommand.Status); err != nil { |
| 472 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 475 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 473 | } else { | 476 | } else { |
| @@ -36,6 +36,7 @@ type CooperationModeRepository interface { | @@ -36,6 +36,7 @@ type CooperationModeRepository interface { | ||
| 36 | BatchRemove(cooperationModes []*CooperationMode) ([]*CooperationMode, error) | 36 | BatchRemove(cooperationModes []*CooperationMode) ([]*CooperationMode, error) |
| 37 | FindOne(queryOptions map[string]interface{}) (*CooperationMode, error) | 37 | FindOne(queryOptions map[string]interface{}) (*CooperationMode, error) |
| 38 | Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error) | 38 | Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error) |
| 39 | + FindAll(queryOptions map[string]interface{}) (int64, []*CooperationMode, error) | ||
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | func (cooperationMode *CooperationMode) Identify() interface{} { | 42 | func (cooperationMode *CooperationMode) Identify() interface{} { |
| @@ -191,6 +191,32 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf | @@ -191,6 +191,32 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf | ||
| 191 | } | 191 | } |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | +func (repository *CooperationModeRepository) FindAll(queryOptions map[string]interface{}) (int64, []*domain.CooperationMode, error) { | ||
| 195 | + tx := repository.transactionContext.PgTx | ||
| 196 | + var cooperationModeModels []*models.CooperationMode | ||
| 197 | + cooperationModes := make([]*domain.CooperationMode, 0) | ||
| 198 | + query := sqlbuilder.BuildQuery(tx.Model(&cooperationModeModels), queryOptions) | ||
| 199 | + if cooperationModeName, ok := queryOptions["cooperationModeName"]; ok && cooperationModeName != "" { | ||
| 200 | + query.Where("cooperation_mode_name like ?", fmt.Sprintf("%%%s%%", cooperationModeName)) | ||
| 201 | + } | ||
| 202 | + if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" { | ||
| 203 | + query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName)) | ||
| 204 | + } | ||
| 205 | + query.SetOrderDirect("cooperation_mode_id", "DESC") | ||
| 206 | + if count, err := query.SelectAndCount(); err != nil { | ||
| 207 | + return 0, cooperationModes, err | ||
| 208 | + } else { | ||
| 209 | + for _, cooperationModeModel := range cooperationModeModels { | ||
| 210 | + if cooperationMode, err := transform.TransformToCooperationModeDomainModelFromPgModels(cooperationModeModel); err != nil { | ||
| 211 | + return 0, cooperationModes, err | ||
| 212 | + } else { | ||
| 213 | + cooperationModes = append(cooperationModes, cooperationMode) | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + return int64(count), cooperationModes, nil | ||
| 217 | + } | ||
| 218 | +} | ||
| 219 | + | ||
| 194 | func NewCooperationModeRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationModeRepository, error) { | 220 | func NewCooperationModeRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationModeRepository, error) { |
| 195 | if transactionContext == nil { | 221 | if transactionContext == nil { |
| 196 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 222 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
-
请 注册 或 登录 后发表评论