正在显示
9 个修改的文件
包含
128 行增加
和
47 行删除
| @@ -12,7 +12,7 @@ type ListCompanyCustomizeMenusCommand struct { | @@ -12,7 +12,7 @@ type ListCompanyCustomizeMenusCommand struct { | ||
| 12 | // 企业id | 12 | // 企业id |
| 13 | CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` | 13 | CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` |
| 14 | // 菜单类别 web app | 14 | // 菜单类别 web app |
| 15 | - MenuCategory string `json:"menuCategory,omitempty" valid:"Required"` | 15 | + MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty" valid:"Required"` |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) { | 18 | func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) { |
| @@ -12,11 +12,11 @@ type GetUserProfileQuery struct { | @@ -12,11 +12,11 @@ type GetUserProfileQuery struct { | ||
| 12 | // 用户Id 用户唯一标识 | 12 | // 用户Id 用户唯一标识 |
| 13 | UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string,omitempty"` | 13 | UserId int64 `cname:"用户Id 用户唯一标识" json:"userId,string,omitempty"` |
| 14 | // 手机号码 | 14 | // 手机号码 |
| 15 | - Phone string `cname:"手机号码" json:"phone,omitempty"` | 15 | + //Phone string `cname:"手机号码" json:"phone,omitempty"` |
| 16 | // 企业id | 16 | // 企业id |
| 17 | - CompanyId int64 `cname:"企业id" json:"companyId,string,omitempty"` | 17 | + //CompanyId int64 `cname:"企业id" json:"companyId,string,omitempty"` |
| 18 | // 用户编号 企业内标识 | 18 | // 用户编号 企业内标识 |
| 19 | - UserCode string `cname:"用户编号 企业内标识" json:"userCode,omitempty"` | 19 | + //UserCode string `cname:"用户编号 企业内标识" json:"userCode,omitempty"` |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | func (getUserProfileQuery *GetUserProfileQuery) Valid(validation *validation.Validation) { | 22 | func (getUserProfileQuery *GetUserProfileQuery) Valid(validation *validation.Validation) { |
| @@ -164,11 +164,14 @@ func (userService *UserService) CreateCooperator(createCooperatorCommand *comman | @@ -164,11 +164,14 @@ func (userService *UserService) CreateCooperator(createCooperatorCommand *comman | ||
| 164 | if user, err = createUserService.CreateUser(nil, newUser, createCooperatorCommand.Password); err != nil { | 164 | if user, err = createUserService.CreateUser(nil, newUser, createCooperatorCommand.Password); err != nil { |
| 165 | return nil, err | 165 | return nil, err |
| 166 | } | 166 | } |
| 167 | - | 167 | + userDto := &dto.UserDto{} |
| 168 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
| 169 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 170 | + } | ||
| 168 | if err := transactionContext.CommitTransaction(); err != nil { | 171 | if err := transactionContext.CommitTransaction(); err != nil { |
| 169 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 172 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 170 | } | 173 | } |
| 171 | - return user, nil | 174 | + return userDto, nil |
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | // 创建 | 177 | // 创建 |
| @@ -211,17 +214,17 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | @@ -211,17 +214,17 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | ||
| 211 | } | 214 | } |
| 212 | } | 215 | } |
| 213 | newUser := &domain.User{ | 216 | newUser := &domain.User{ |
| 214 | - CompanyId: createUserCommand.CompanyId, | ||
| 215 | - UserType: createUserCommand.UserType, | ||
| 216 | - UserCode: createUserCommand.UserCode, | ||
| 217 | - OrganizationId: createUserCommand.OrganizationId, | ||
| 218 | - DepartmentId: createUserCommand.DepartmentId, | ||
| 219 | - UserOrg: sampleUserOrg, | ||
| 220 | - UserRole: sampleUserRole, | ||
| 221 | - FavoriteMenus: []string{}, | ||
| 222 | - CooperationInfo: &domain.CooperationInfo{}, | ||
| 223 | - UserInfo: nweUserInfo, | ||
| 224 | - EnableStatus: createUserCommand.EnableStatus, | 217 | + CompanyId: createUserCommand.CompanyId, |
| 218 | + UserType: createUserCommand.UserType, | ||
| 219 | + UserCode: createUserCommand.UserCode, | ||
| 220 | + OrganizationId: createUserCommand.OrganizationId, | ||
| 221 | + DepartmentId: createUserCommand.DepartmentId, | ||
| 222 | + UserOrg: sampleUserOrg, | ||
| 223 | + UserRole: sampleUserRole, | ||
| 224 | + FavoriteMenus: []string{}, | ||
| 225 | + //CooperationInfo: &domain.CooperationInfo{}, | ||
| 226 | + UserInfo: nweUserInfo, | ||
| 227 | + EnableStatus: createUserCommand.EnableStatus, | ||
| 225 | Ext: &domain.Ext{ | 228 | Ext: &domain.Ext{ |
| 226 | Phone: createUserCommand.Phone, | 229 | Phone: createUserCommand.Phone, |
| 227 | UserName: createUserCommand.UserName, | 230 | UserName: createUserCommand.UserName, |
| @@ -236,10 +239,14 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | @@ -236,10 +239,14 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | ||
| 236 | if user, err = createUserService.CreateUser(nil, newUser, createUserCommand.Password); err != nil { | 239 | if user, err = createUserService.CreateUser(nil, newUser, createUserCommand.Password); err != nil { |
| 237 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 240 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 238 | } | 241 | } |
| 242 | + userDto := &dto.UserDto{} | ||
| 243 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
| 244 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 245 | + } | ||
| 239 | if err := transactionContext.CommitTransaction(); err != nil { | 246 | if err := transactionContext.CommitTransaction(); err != nil { |
| 240 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 247 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 241 | } | 248 | } |
| 242 | - return user, nil | 249 | + return userDto, nil |
| 243 | } | 250 | } |
| 244 | 251 | ||
| 245 | // 移除我收藏的菜单 | 252 | // 移除我收藏的菜单 |
| @@ -404,7 +411,7 @@ func (userService *UserService) GetUserAccessMenus(getUserAccessMenusQuery *quer | @@ -404,7 +411,7 @@ func (userService *UserService) GetUserAccessMenus(getUserAccessMenusQuery *quer | ||
| 404 | }, nil | 411 | }, nil |
| 405 | } | 412 | } |
| 406 | 413 | ||
| 407 | -// TODO:获取用户概要数据 | 414 | +// 获取用户概要数据 |
| 408 | func (userService *UserService) GetUserProfile(getUserProfileQuery *query.GetUserProfileQuery) (interface{}, error) { | 415 | func (userService *UserService) GetUserProfile(getUserProfileQuery *query.GetUserProfileQuery) (interface{}, error) { |
| 409 | if err := getUserProfileQuery.ValidateQuery(); err != nil { | 416 | if err := getUserProfileQuery.ValidateQuery(); err != nil { |
| 410 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 417 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -419,10 +426,29 @@ func (userService *UserService) GetUserProfile(getUserProfileQuery *query.GetUse | @@ -419,10 +426,29 @@ func (userService *UserService) GetUserProfile(getUserProfileQuery *query.GetUse | ||
| 419 | defer func() { | 426 | defer func() { |
| 420 | transactionContext.RollbackTransaction() | 427 | transactionContext.RollbackTransaction() |
| 421 | }() | 428 | }() |
| 429 | + | ||
| 430 | + _, user, err := factory.FastPgUser(transactionContext, getUserProfileQuery.UserId) | ||
| 431 | + if err != nil { | ||
| 432 | + return nil, err | ||
| 433 | + } | ||
| 434 | + _, userBase, err := factory.FastPgUserBase(transactionContext, user.UserBaseId) | ||
| 435 | + if err != nil { | ||
| 436 | + return nil, err | ||
| 437 | + } | ||
| 438 | + var userProfile = make(map[string]interface{}) | ||
| 439 | + userProfile["userId"] = user.UserId | ||
| 440 | + userProfile["userCode"] = user.UserCode | ||
| 441 | + | ||
| 442 | + userProfile["userBaseId"] = user.UserBaseId | ||
| 443 | + userProfile["phone"] = userBase.UserInfo.Phone | ||
| 444 | + userProfile["avatar"] = userBase.UserInfo.Avatar | ||
| 445 | + userProfile["email"] = userBase.UserInfo.Email | ||
| 446 | + userProfile["userName"] = userBase.UserInfo.UserName | ||
| 447 | + | ||
| 422 | if err := transactionContext.CommitTransaction(); err != nil { | 448 | if err := transactionContext.CommitTransaction(); err != nil { |
| 423 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 449 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 424 | } | 450 | } |
| 425 | - return nil, nil | 451 | + return userProfile, nil |
| 426 | } | 452 | } |
| 427 | 453 | ||
| 428 | // 返回列表 | 454 | // 返回列表 |
| @@ -557,11 +583,14 @@ func (userService *UserService) UpdateCooperator(updateCooperatorCommand *comman | @@ -557,11 +583,14 @@ func (userService *UserService) UpdateCooperator(updateCooperatorCommand *comman | ||
| 557 | if user, err = updateUserService.UpdateUser(nil, user, userInfo, updateCooperatorCommand.EnableStatus); err != nil { | 583 | if user, err = updateUserService.UpdateUser(nil, user, userInfo, updateCooperatorCommand.EnableStatus); err != nil { |
| 558 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 584 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 559 | } | 585 | } |
| 560 | - | 586 | + userDto := &dto.UserDto{} |
| 587 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
| 588 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 589 | + } | ||
| 561 | if err := transactionContext.CommitTransaction(); err != nil { | 590 | if err := transactionContext.CommitTransaction(); err != nil { |
| 562 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 591 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 563 | } | 592 | } |
| 564 | - return struct{}{}, nil | 593 | + return userDto, nil |
| 565 | } | 594 | } |
| 566 | 595 | ||
| 567 | // 更新我喜欢菜单列表 | 596 | // 更新我喜欢菜单列表 |
| @@ -630,11 +659,14 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | @@ -630,11 +659,14 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | ||
| 630 | if user, err = updateUserService.UpdateUser(nil, user, userInfo, updateUserCommand.EnableStatus); err != nil { | 659 | if user, err = updateUserService.UpdateUser(nil, user, userInfo, updateUserCommand.EnableStatus); err != nil { |
| 631 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 660 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 632 | } | 661 | } |
| 633 | - | 662 | + userDto := &dto.UserDto{} |
| 663 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
| 664 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 665 | + } | ||
| 634 | if err := transactionContext.CommitTransaction(); err != nil { | 666 | if err := transactionContext.CommitTransaction(); err != nil { |
| 635 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 667 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 636 | } | 668 | } |
| 637 | - return user, nil | 669 | + return userDto, nil |
| 638 | } | 670 | } |
| 639 | 671 | ||
| 640 | // 更新用户基础信息数据 | 672 | // 更新用户基础信息数据 |
| @@ -652,10 +684,27 @@ func (userService *UserService) UpdateUsersBase(updateUsersBaseCommand *command. | @@ -652,10 +684,27 @@ func (userService *UserService) UpdateUsersBase(updateUsersBaseCommand *command. | ||
| 652 | defer func() { | 684 | defer func() { |
| 653 | transactionContext.RollbackTransaction() | 685 | transactionContext.RollbackTransaction() |
| 654 | }() | 686 | }() |
| 687 | + | ||
| 688 | + _, user, err := factory.FastPgUser(transactionContext, updateUsersBaseCommand.UserId) | ||
| 689 | + if err != nil { | ||
| 690 | + return nil, err | ||
| 691 | + } | ||
| 692 | + userInfo := &domain.UserInfo{ | ||
| 693 | + UserName: updateUsersBaseCommand.UserName, | ||
| 694 | + Phone: updateUsersBaseCommand.Phone, | ||
| 695 | + Avatar: updateUsersBaseCommand.Avatar, | ||
| 696 | + Email: updateUsersBaseCommand.Email, | ||
| 697 | + } | ||
| 698 | + updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ | ||
| 699 | + "transactionContext": transactionContext, | ||
| 700 | + }) | ||
| 701 | + if user, err = updateUserService.UpdateUser(nil, user, userInfo, user.EnableStatus); err != nil { | ||
| 702 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 703 | + } | ||
| 655 | if err := transactionContext.CommitTransaction(); err != nil { | 704 | if err := transactionContext.CommitTransaction(); err != nil { |
| 656 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 705 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 657 | } | 706 | } |
| 658 | - return nil, nil | 707 | + return struct{}{}, nil |
| 659 | } | 708 | } |
| 660 | 709 | ||
| 661 | func NewUserService(options map[string]interface{}) *UserService { | 710 | func NewUserService(options map[string]interface{}) *UserService { |
| @@ -45,7 +45,7 @@ type Menu struct { | @@ -45,7 +45,7 @@ type Menu struct { | ||
| 45 | // 菜单编号 | 45 | // 菜单编号 |
| 46 | MenuId int64 `json:"menuId,omitempty"` | 46 | MenuId int64 `json:"menuId,omitempty"` |
| 47 | // 父级id | 47 | // 父级id |
| 48 | - ParentId int64 `json:"parentId,omitempty"` | 48 | + ParentId int64 `json:"parentId"` |
| 49 | // 菜单名称 | 49 | // 菜单名称 |
| 50 | MenuName string `json:"menuName,omitempty"` | 50 | MenuName string `json:"menuName,omitempty"` |
| 51 | // 菜单别名 | 51 | // 菜单别名 |
| @@ -28,7 +28,7 @@ func init() { | @@ -28,7 +28,7 @@ func init() { | ||
| 28 | web.BConfig.Listen.HTTPPort = port | 28 | web.BConfig.Listen.HTTPPort = port |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| 31 | - web.InsertFilter("/*", web.BeforeExec, filters.AllowCors()) | 31 | + web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors()) |
| 32 | web.InsertFilter("/*", web.BeforeExec, CreateRequestLogFilter(Logger)) | 32 | web.InsertFilter("/*", web.BeforeExec, CreateRequestLogFilter(Logger)) |
| 33 | web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(Logger), web.WithReturnOnOutput(false)) | 33 | web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(Logger), web.WithReturnOnOutput(false)) |
| 34 | } | 34 | } |
| @@ -15,6 +15,6 @@ func init() { | @@ -15,6 +15,6 @@ func init() { | ||
| 15 | web.Router("/company/:companyId/customize-menus", &controllers.CompanyController{}, "Put:UpdateCompanyCustomizeMenus") | 15 | web.Router("/company/:companyId/customize-menus", &controllers.CompanyController{}, "Put:UpdateCompanyCustomizeMenus") |
| 16 | 16 | ||
| 17 | // 适配web | 17 | // 适配web |
| 18 | - web.Router("/v1/web/menus/search", &controllers.CompanyController{}, "Post:SearchCompanyCustomizeMenus") | ||
| 19 | - web.Router("/v1/web/menus", &controllers.CompanyController{}, "Put:AdapterUpdateCompanyCustomizeMenus") | 18 | + //web.Router("/v1/web/menus/search", &controllers.CompanyController{}, "Post:SearchCompanyCustomizeMenus") |
| 19 | + //web.Router("/v1/web/menus", &controllers.CompanyController{}, "Put:AdapterUpdateCompanyCustomizeMenus") | ||
| 20 | } | 20 | } |
| @@ -13,12 +13,12 @@ func init() { | @@ -13,12 +13,12 @@ func init() { | ||
| 13 | web.Router("/menus/", &controllers.MenuController{}, "Get:ListMenu") | 13 | web.Router("/menus/", &controllers.MenuController{}, "Get:ListMenu") |
| 14 | web.Router("/menus/search", &controllers.MenuController{}, "Post:SearchMenu") | 14 | web.Router("/menus/search", &controllers.MenuController{}, "Post:SearchMenu") |
| 15 | 15 | ||
| 16 | - web.Router("/v1/opt/menus/", &controllers.MenuController{}, "Post:CreateMenu") | ||
| 17 | - web.Router("/v1/opt/menus/:menuId", &controllers.MenuController{}, "Put:UpdateMenu") | ||
| 18 | - web.Router("/v1/opt/menus/:menuId", &controllers.MenuController{}, "Get:GetMenu") | ||
| 19 | - web.Router("/v1/opt/menus/:menuId", &controllers.MenuController{}, "Delete:RemoveMenu") | ||
| 20 | - web.Router("/v1/opt/menus/search", &controllers.MenuController{}, "Get:ListMenu") | ||
| 21 | - web.Router("/v1/opt/menus/search", &controllers.MenuController{}, "Post:SearchMenu") | 16 | + web.Router("/v1/web/menus/", &controllers.MenuController{}, "Post:CreateMenu") |
| 17 | + web.Router("/v1/web/menus/:menuId", &controllers.MenuController{}, "Put:UpdateMenu") | ||
| 18 | + web.Router("/v1/web/menus/:menuId", &controllers.MenuController{}, "Get:GetMenu") | ||
| 19 | + web.Router("/v1/web/menus/:menuId", &controllers.MenuController{}, "Delete:RemoveMenu") | ||
| 20 | + web.Router("/v1/web/menus/search", &controllers.MenuController{}, "Get:ListMenu") | ||
| 21 | + web.Router("/v1/web/menus/search", &controllers.MenuController{}, "Post:SearchMenu") | ||
| 22 | 22 | ||
| 23 | web.Router("/v1/web/common/dictionary/search", &controllers.CommonController{}, "Post:DictionarySearch") | 23 | web.Router("/v1/web/common/dictionary/search", &controllers.CommonController{}, "Post:DictionarySearch") |
| 24 | } | 24 | } |
| @@ -11,20 +11,32 @@ import ( | @@ -11,20 +11,32 @@ import ( | ||
| 11 | ) | 11 | ) |
| 12 | 12 | ||
| 13 | var _ = Describe("获取用户概要数据", func() { | 13 | var _ = Describe("获取用户概要数据", func() { |
| 14 | - return | ||
| 15 | var userId int64 | 14 | var userId int64 |
| 16 | BeforeEach(func() { | 15 | BeforeEach(func() { |
| 17 | - _, err := pG.DB.QueryOne( | 16 | + var err error |
| 17 | + _, err = pG.DB.QueryOne( | ||
| 18 | pg.Scan(&userId), | 18 | pg.Scan(&userId), |
| 19 | - "INSERT INTO users (user_id, company_id, user_base_id, user_type, user_code, organization_id, department_id, user_info, user_org, user_role, favorite_menus, cooperation_info, enable_status, ext, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id", | ||
| 20 | - "testUserId", "testCompanyId", "testUserBaseId", "testUserType", "testUserCode", "testOrganizationId", "testDepartmentId", "testUserInfo", "testUserOrg", "testUserRole", "testFavoriteMenus", "testCooperationInfo", "testEnableStatus", "testExt", "testCreatedAt", "testUpdatedAt") | 19 | + "INSERT INTO \"users\".\"user_base\"(\"user_base_id\", \"user_info\", \"account\", \"password\", \"im\", \"related_user\", \"status\", \"created_at\", \"updated_at\") VALUES (999, '{\"phone\": \"phone\", \"userName\": \"string\"}', 'phone', 'string', '{\"accid\": \"\", \"imToken\": \"\", \"csAccountId\": \"\"}', '{999}', 1, '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08') RETURNING user_base_id;", |
| 20 | + ) | ||
| 21 | + Expect(err).NotTo(HaveOccurred()) | ||
| 22 | + | ||
| 23 | + _, err = pG.DB.QueryOne( | ||
| 24 | + pg.Scan(&userId), | ||
| 25 | + "INSERT INTO \"users\".\"user\"(\"user_id\", \"company_id\", \"user_base_id\", \"user_type\", \"user_code\", \"organization_id\", \"department_id\", \"user_org\", \"user_role\", \"favorite_menus\", \"cooperation_info\", \"enable_status\", \"ext\", \"created_at\", \"updated_at\") VALUES (999, 5, 999, 1025, 'ADMIN01', 5, 5, '[{\"orgId\": 5, \"orgName\": \"string1\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"deletedAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[{\"ext\": {\"orgName\": \"string1\"}, \"roleId\": 5, \"roleName\": \"企业管理员\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[]', '{\"cooperationCompany\": \"\", \"cooperationDeadline\": \"0001-01-01T00:00:00Z\"}', 1, '{\"phone\": \"18860183031\", \"depName\": \"string1\", \"orgName\": \"string1\"}', '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08');\n", | ||
| 26 | + ) | ||
| 27 | + Expect(err).NotTo(HaveOccurred()) | ||
| 28 | + | ||
| 29 | + _, err = pG.DB.QueryOne( | ||
| 30 | + pg.Scan(&userId), | ||
| 31 | + "INSERT INTO users.org (org_id,company_id,created_at,updated_at,deleted_at,org_code,org_name,ext,org_status,is_org,parent_id,parent_path) VALUES (999,999,'2021-07-26 08:06:29.3101584+00:00:00','2021-07-26 08:06:29.3101584+00:00:00','0001-01-01 00:00:00+00:00:00','ENTERPRISE01','string1','{}',1,1,0,'');", | ||
| 32 | + ) | ||
| 21 | Expect(err).NotTo(HaveOccurred()) | 33 | Expect(err).NotTo(HaveOccurred()) |
| 22 | }) | 34 | }) |
| 23 | Describe("获取用户概要数据", func() { | 35 | Describe("获取用户概要数据", func() { |
| 24 | Context("", func() { | 36 | Context("", func() { |
| 25 | It("", func() { | 37 | It("", func() { |
| 26 | httpExpect := httpexpect.New(GinkgoT(), server.URL) | 38 | httpExpect := httpexpect.New(GinkgoT(), server.URL) |
| 27 | - httpExpect.GET("/user/{userId}/profile"). | 39 | + httpExpect.GET("/user/999/profile"). |
| 28 | Expect(). | 40 | Expect(). |
| 29 | Status(http.StatusOK). | 41 | Status(http.StatusOK). |
| 30 | JSON(). | 42 | JSON(). |
| @@ -36,7 +48,11 @@ var _ = Describe("获取用户概要数据", func() { | @@ -36,7 +48,11 @@ var _ = Describe("获取用户概要数据", func() { | ||
| 36 | }) | 48 | }) |
| 37 | }) | 49 | }) |
| 38 | AfterEach(func() { | 50 | AfterEach(func() { |
| 39 | - _, err := pG.DB.Exec("DELETE FROM users WHERE true") | 51 | + _, err := pG.DB.Exec("DELETE FROM users.user_base WHERE user_base_id = 999") |
| 52 | + Expect(err).NotTo(HaveOccurred()) | ||
| 53 | + _, err = pG.DB.Exec(`DELETE FROM users."user" WHERE user_id = 999`) | ||
| 54 | + Expect(err).NotTo(HaveOccurred()) | ||
| 55 | + _, err = pG.DB.Exec(`DELETE FROM users."org" WHERE org_id = 999`) | ||
| 40 | Expect(err).NotTo(HaveOccurred()) | 56 | Expect(err).NotTo(HaveOccurred()) |
| 41 | }) | 57 | }) |
| 42 | }) | 58 | }) |
| @@ -11,13 +11,25 @@ import ( | @@ -11,13 +11,25 @@ import ( | ||
| 11 | ) | 11 | ) |
| 12 | 12 | ||
| 13 | var _ = Describe("更新用户基础信息数据", func() { | 13 | var _ = Describe("更新用户基础信息数据", func() { |
| 14 | - return | ||
| 15 | var userId int64 | 14 | var userId int64 |
| 16 | BeforeEach(func() { | 15 | BeforeEach(func() { |
| 17 | - _, err := pG.DB.QueryOne( | 16 | + var err error |
| 17 | + _, err = pG.DB.QueryOne( | ||
| 18 | pg.Scan(&userId), | 18 | pg.Scan(&userId), |
| 19 | - "INSERT INTO users (user_id, company_id, user_base_id, user_type, user_code, organization_id, department_id, user_info, user_org, user_role, favorite_menus, cooperation_info, enable_status, ext, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id", | ||
| 20 | - "testUserId", "testCompanyId", "testUserBaseId", "testUserType", "testUserCode", "testOrganizationId", "testDepartmentId", "testUserInfo", "testUserOrg", "testUserRole", "testFavoriteMenus", "testCooperationInfo", "testEnableStatus", "testExt", "testCreatedAt", "testUpdatedAt") | 19 | + "INSERT INTO \"users\".\"user_base\"(\"user_base_id\", \"user_info\", \"account\", \"password\", \"im\", \"related_user\", \"status\", \"created_at\", \"updated_at\") VALUES (999, '{\"phone\": \"phone\", \"userName\": \"string\"}', 'phone', 'string', '{\"accid\": \"\", \"imToken\": \"\", \"csAccountId\": \"\"}', '{999}', 1, '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08') RETURNING user_base_id;", |
| 20 | + ) | ||
| 21 | + Expect(err).NotTo(HaveOccurred()) | ||
| 22 | + | ||
| 23 | + _, err = pG.DB.QueryOne( | ||
| 24 | + pg.Scan(&userId), | ||
| 25 | + "INSERT INTO \"users\".\"user\"(\"user_id\", \"company_id\", \"user_base_id\", \"user_type\", \"user_code\", \"organization_id\", \"department_id\", \"user_org\", \"user_role\", \"favorite_menus\", \"cooperation_info\", \"enable_status\", \"ext\", \"created_at\", \"updated_at\") VALUES (999, 5, 999, 1025, 'ADMIN01', 5, 5, '[{\"orgId\": 5, \"orgName\": \"string1\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"deletedAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[{\"ext\": {\"orgName\": \"string1\"}, \"roleId\": 5, \"roleName\": \"企业管理员\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[]', '{\"cooperationCompany\": \"\", \"cooperationDeadline\": \"0001-01-01T00:00:00Z\"}', 1, '{\"phone\": \"18860183031\", \"depName\": \"string1\", \"orgName\": \"string1\"}', '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08');\n", | ||
| 26 | + ) | ||
| 27 | + Expect(err).NotTo(HaveOccurred()) | ||
| 28 | + | ||
| 29 | + _, err = pG.DB.QueryOne( | ||
| 30 | + pg.Scan(&userId), | ||
| 31 | + "INSERT INTO users.org (org_id,company_id,created_at,updated_at,deleted_at,org_code,org_name,ext,org_status,is_org,parent_id,parent_path) VALUES (999,999,'2021-07-26 08:06:29.3101584+00:00:00','2021-07-26 08:06:29.3101584+00:00:00','0001-01-01 00:00:00+00:00:00','ENTERPRISE01','string1','{}',1,1,0,'');", | ||
| 32 | + ) | ||
| 21 | Expect(err).NotTo(HaveOccurred()) | 33 | Expect(err).NotTo(HaveOccurred()) |
| 22 | }) | 34 | }) |
| 23 | Describe("更新用户基础信息数据", func() { | 35 | Describe("更新用户基础信息数据", func() { |
| @@ -30,7 +42,7 @@ var _ = Describe("更新用户基础信息数据", func() { | @@ -30,7 +42,7 @@ var _ = Describe("更新用户基础信息数据", func() { | ||
| 30 | "phone": "string", | 42 | "phone": "string", |
| 31 | "email": "string", | 43 | "email": "string", |
| 32 | } | 44 | } |
| 33 | - httpExpect.PUT("/user/{userId}/base-info"). | 45 | + httpExpect.PUT("/user/999/base-info"). |
| 34 | WithJSON(body). | 46 | WithJSON(body). |
| 35 | Expect(). | 47 | Expect(). |
| 36 | Status(http.StatusOK). | 48 | Status(http.StatusOK). |
| @@ -43,7 +55,11 @@ var _ = Describe("更新用户基础信息数据", func() { | @@ -43,7 +55,11 @@ var _ = Describe("更新用户基础信息数据", func() { | ||
| 43 | }) | 55 | }) |
| 44 | }) | 56 | }) |
| 45 | AfterEach(func() { | 57 | AfterEach(func() { |
| 46 | - _, err := pG.DB.Exec("DELETE FROM users WHERE true") | 58 | + _, err := pG.DB.Exec("DELETE FROM users.user_base WHERE user_base_id = 999") |
| 59 | + Expect(err).NotTo(HaveOccurred()) | ||
| 60 | + _, err = pG.DB.Exec(`DELETE FROM users."user" WHERE user_id = 999`) | ||
| 61 | + Expect(err).NotTo(HaveOccurred()) | ||
| 62 | + _, err = pG.DB.Exec(`DELETE FROM users."org" WHERE org_id = 999`) | ||
| 47 | Expect(err).NotTo(HaveOccurred()) | 63 | Expect(err).NotTo(HaveOccurred()) |
| 48 | }) | 64 | }) |
| 49 | }) | 65 | }) |
-
请 注册 或 登录 后发表评论