正在显示
12 个修改的文件
包含
302 行增加
和
6 行删除
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | +) | ||
11 | + | ||
12 | +type CreateAdminUserCommand struct { | ||
13 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
14 | + // 企业id | ||
15 | + CompanyId int64 `cname:"企业id" json:"companyId"` | ||
16 | + // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) | ||
17 | + UserType int `cname:"用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)" json:"userType" valid:"Required"` | ||
18 | + // 用户编号 企业内标识 | ||
19 | + UserCode string `cname:"用户编号 企业内标识" json:"userCode"` | ||
20 | + // 组织机构 | ||
21 | + OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"` | ||
22 | + // 所属部门 | ||
23 | + DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"` | ||
24 | + // 用户关联的组织 | ||
25 | + UserOrg []int64 `cname:"用户关联的组织" json:"userOrg,omitempty"` | ||
26 | + // 用户关联的角色 | ||
27 | + UserRole []int64 `cname:"用户关联的角色" json:"userRole,omitempty"` | ||
28 | + // 共创公司 | ||
29 | + CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"` | ||
30 | + // 共创到期时间 (yyyy-MM-dd) | ||
31 | + CooperationDeadline time.Time `cname:"共创到期时间 (yyyy-MM-dd)" json:"cooperationDeadline,omitempty"` | ||
32 | + // 启用状态(启用:1 禁用:2) | ||
33 | + EnableStatus int `cname:"启用状态(启用:1 禁用:2)" json:"enableStatus,omitempty" valid:"Required"` | ||
34 | + // 密码 | ||
35 | + Password string `cname:"密码" json:"password" valid:"Required"` | ||
36 | + // 用户姓名 | ||
37 | + UserName string `cname:"用户姓名" json:"userName" valid:"Required"` | ||
38 | + // 手机号码 | ||
39 | + Phone string `cname:"手机号码" json:"phone" valid:"Required"` | ||
40 | + // 头像 | ||
41 | + Avatar string `cname:"头像" json:"avatar"` | ||
42 | + // 邮箱 | ||
43 | + Email string `cname:"邮箱" json:"email"` | ||
44 | + | ||
45 | + // 运营管理扩展 | ||
46 | + // 部门 | ||
47 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
48 | +} | ||
49 | + | ||
50 | +func (createUserCommand *CreateAdminUserCommand) Valid(validation *validation.Validation) { | ||
51 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
52 | +} | ||
53 | + | ||
54 | +func (createUserCommand *CreateAdminUserCommand) ValidateCommand() error { | ||
55 | + valid := validation.Validation{} | ||
56 | + b, err := valid.Valid(createUserCommand) | ||
57 | + if err != nil { | ||
58 | + return err | ||
59 | + } | ||
60 | + if !b { | ||
61 | + elem := reflect.TypeOf(createUserCommand).Elem() | ||
62 | + for _, validErr := range valid.Errors { | ||
63 | + field, isExist := elem.FieldByName(validErr.Field) | ||
64 | + if isExist { | ||
65 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
66 | + } else { | ||
67 | + return fmt.Errorf(validErr.Message) | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + return nil | ||
72 | +} |
@@ -41,6 +41,10 @@ type CreateUserCommand struct { | @@ -41,6 +41,10 @@ type CreateUserCommand struct { | ||
41 | Avatar string `cname:"头像" json:"avatar"` | 41 | Avatar string `cname:"头像" json:"avatar"` |
42 | // 邮箱 | 42 | // 邮箱 |
43 | Email string `cname:"邮箱" json:"email"` | 43 | Email string `cname:"邮箱" json:"email"` |
44 | + | ||
45 | + // 运营管理扩展 | ||
46 | + // 部门 | ||
47 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
44 | } | 48 | } |
45 | 49 | ||
46 | func (createUserCommand *CreateUserCommand) Valid(validation *validation.Validation) { | 50 | func (createUserCommand *CreateUserCommand) Valid(validation *validation.Validation) { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + "time" | ||
9 | + | ||
10 | + "github.com/beego/beego/v2/core/validation" | ||
11 | +) | ||
12 | + | ||
13 | +type UpdateAdminUserCommand struct { | ||
14 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
15 | + // 用户Id 用户唯一标识 | ||
16 | + UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"` | ||
17 | + // 组织机构 | ||
18 | + OrganizationId int64 `cname:"组织机构" json:"organizationId,omitempty"` | ||
19 | + // 所属部门 | ||
20 | + DepartmentId int64 `cname:"所属部门" json:"departmentId,omitempty"` | ||
21 | + // 用户关联的组织 | ||
22 | + UserOrg []int64 `cname:"用户关联的组织" json:"userOrg,omitempty"` | ||
23 | + // 用户关联的角色 | ||
24 | + UserRole []int64 `cname:"用户关联的角色" json:"userRole,omitempty"` | ||
25 | + // 共创公司 | ||
26 | + CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"` | ||
27 | + // 共创到期时间 (yyyy-MM-dd) | ||
28 | + CooperationDeadline time.Time `cname:"共创到期时间 (yyyy-MM-dd)" json:"cooperationDeadline,omitempty"` | ||
29 | + // 启用状态(启用:1 禁用:2) | ||
30 | + EnableStatus int `cname:"启用状态(启用:1 禁用:2)" json:"enableStatus,omitempty"` | ||
31 | + // 用户姓名 | ||
32 | + UserName string `cname:"用户姓名" json:"userName" valid:"Required"` | ||
33 | + // 手机号码 | ||
34 | + Phone string `cname:"手机号码" json:"phone" valid:"Required"` | ||
35 | + // 头像 | ||
36 | + Avatar string `cname:"头像" json:"avatar"` | ||
37 | + // 邮箱 | ||
38 | + Email string `cname:"邮箱" json:"email"` | ||
39 | + | ||
40 | + // 运营管理扩展 | ||
41 | + // 部门 | ||
42 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
43 | +} | ||
44 | + | ||
45 | +func (updateUserCommand *UpdateAdminUserCommand) Valid(validation *validation.Validation) { | ||
46 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
47 | +} | ||
48 | + | ||
49 | +func (updateUserCommand *UpdateAdminUserCommand) ValidateCommand() error { | ||
50 | + valid := validation.Validation{} | ||
51 | + b, err := valid.Valid(updateUserCommand) | ||
52 | + if err != nil { | ||
53 | + return err | ||
54 | + } | ||
55 | + if !b { | ||
56 | + elem := reflect.TypeOf(updateUserCommand).Elem() | ||
57 | + for _, validErr := range valid.Errors { | ||
58 | + field, isExist := elem.FieldByName(validErr.Field) | ||
59 | + if isExist { | ||
60 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
61 | + } else { | ||
62 | + return fmt.Errorf(validErr.Message) | ||
63 | + } | ||
64 | + } | ||
65 | + } | ||
66 | + return nil | ||
67 | +} |
@@ -36,6 +36,10 @@ type UpdateUserCommand struct { | @@ -36,6 +36,10 @@ type UpdateUserCommand struct { | ||
36 | Avatar string `cname:"头像" json:"avatar"` | 36 | Avatar string `cname:"头像" json:"avatar"` |
37 | // 邮箱 | 37 | // 邮箱 |
38 | Email string `cname:"邮箱" json:"email"` | 38 | Email string `cname:"邮箱" json:"email"` |
39 | + | ||
40 | + // 运营管理扩展 | ||
41 | + // 部门 | ||
42 | + DepartmentName string `cname:"部门" json:"departmentName"` | ||
39 | } | 43 | } |
40 | 44 | ||
41 | func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) { | 45 | func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) { |
@@ -273,6 +273,7 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | @@ -273,6 +273,7 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser | ||
273 | Ext: &domain.Ext{ | 273 | Ext: &domain.Ext{ |
274 | Phone: createUserCommand.Phone, | 274 | Phone: createUserCommand.Phone, |
275 | UserName: createUserCommand.UserName, | 275 | UserName: createUserCommand.UserName, |
276 | + DepName: createUserCommand.DepartmentName, | ||
276 | }, | 277 | }, |
277 | CreatedAt: time.Now(), | 278 | CreatedAt: time.Now(), |
278 | UpdatedAt: time.Now(), | 279 | UpdatedAt: time.Now(), |
@@ -536,10 +537,12 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -536,10 +537,12 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
536 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) | 537 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) |
537 | _, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId) | 538 | _, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId) |
538 | _, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId) | 539 | _, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId) |
539 | - if dep != nil && org != nil && company != nil && userBase != nil { | 540 | + if dep != nil && org != nil && company != nil { |
540 | user.Department = dep.ConvDep() | 541 | user.Department = dep.ConvDep() |
541 | user.Organization = org.CloneSample() | 542 | user.Organization = org.CloneSample() |
542 | user.Company = company.CloneSample() | 543 | user.Company = company.CloneSample() |
544 | + } | ||
545 | + if userBase != nil { | ||
543 | user.UserInfo = userBase.UserInfo | 546 | user.UserInfo = userBase.UserInfo |
544 | user.Favorite = userBase.Favorite | 547 | user.Favorite = userBase.Favorite |
545 | } | 548 | } |
@@ -724,6 +727,7 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | @@ -724,6 +727,7 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser | ||
724 | Phone: updateUserCommand.Phone, | 727 | Phone: updateUserCommand.Phone, |
725 | Avatar: updateUserCommand.Avatar, | 728 | Avatar: updateUserCommand.Avatar, |
726 | Email: updateUserCommand.Email, | 729 | Email: updateUserCommand.Email, |
730 | + DepartmentName: updateUserCommand.DepartmentName, | ||
727 | } | 731 | } |
728 | 732 | ||
729 | updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ | 733 | updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ |
@@ -853,6 +857,123 @@ func (userService *UserService) UpdateFavorite(updateFavoriteCommand *command.Up | @@ -853,6 +857,123 @@ func (userService *UserService) UpdateFavorite(updateFavoriteCommand *command.Up | ||
853 | return struct{}{}, nil | 857 | return struct{}{}, nil |
854 | } | 858 | } |
855 | 859 | ||
860 | +// 创建 | ||
861 | +func (userService *UserService) CreateAdminUser(createUserCommand *command.CreateAdminUserCommand) (interface{}, error) { | ||
862 | + if err := createUserCommand.ValidateCommand(); err != nil { | ||
863 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
864 | + } | ||
865 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
866 | + if err != nil { | ||
867 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
868 | + } | ||
869 | + if err := transactionContext.StartTransaction(); err != nil { | ||
870 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
871 | + } | ||
872 | + defer func() { | ||
873 | + transactionContext.RollbackTransaction() | ||
874 | + }() | ||
875 | + nweUserInfo := &domain.UserInfo{ | ||
876 | + UserName: createUserCommand.UserName, | ||
877 | + Phone: createUserCommand.Phone, | ||
878 | + Avatar: createUserCommand.Avatar, | ||
879 | + Email: createUserCommand.Email, | ||
880 | + DepartmentName: createUserCommand.DepartmentName, | ||
881 | + } | ||
882 | + var sampleUserOrg = make([]*domain.Org, 0) | ||
883 | + var sampleUserRole = make([]*domain.Role, 0) | ||
884 | + newUser := &domain.User{ | ||
885 | + CompanyId: createUserCommand.CompanyId, | ||
886 | + UserType: createUserCommand.UserType, | ||
887 | + UserCode: createUserCommand.UserCode, | ||
888 | + OrganizationId: createUserCommand.OrganizationId, | ||
889 | + DepartmentId: createUserCommand.DepartmentId, | ||
890 | + UserOrg: sampleUserOrg, | ||
891 | + UserRole: sampleUserRole, | ||
892 | + FavoriteMenus: []string{}, | ||
893 | + //CooperationInfo: &domain.CooperationInfo{}, | ||
894 | + UserInfo: nweUserInfo, | ||
895 | + EnableStatus: createUserCommand.EnableStatus, | ||
896 | + Ext: &domain.Ext{ | ||
897 | + Phone: createUserCommand.Phone, | ||
898 | + UserName: createUserCommand.UserName, | ||
899 | + DepName: createUserCommand.DepartmentName, | ||
900 | + }, | ||
901 | + CreatedAt: time.Now(), | ||
902 | + UpdatedAt: time.Now(), | ||
903 | + } | ||
904 | + var user *domain.User | ||
905 | + createUserService, _ := factory.CreatePgCreateUserService(map[string]interface{}{ | ||
906 | + "transactionContext": transactionContext, | ||
907 | + }) | ||
908 | + if user, err = createUserService.CreateUser(nil, newUser, createUserCommand.Password); err != nil { | ||
909 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
910 | + } | ||
911 | + userDto := &dto.UserDto{} | ||
912 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
913 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
914 | + } | ||
915 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
916 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
917 | + } | ||
918 | + return userDto, nil | ||
919 | +} | ||
920 | + | ||
921 | +// 更新 | ||
922 | +func (userService *UserService) UpdateAdminUser(updateUserCommand *command.UpdateAdminUserCommand) (interface{}, error) { | ||
923 | + if err := updateUserCommand.ValidateCommand(); err != nil { | ||
924 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
925 | + } | ||
926 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
927 | + if err != nil { | ||
928 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
929 | + } | ||
930 | + if err := transactionContext.StartTransaction(); err != nil { | ||
931 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
932 | + } | ||
933 | + defer func() { | ||
934 | + transactionContext.RollbackTransaction() | ||
935 | + }() | ||
936 | + _, user, err := factory.FastPgUser(transactionContext, updateUserCommand.UserId, factory.WithDataAuthRequired(), factory.WithOperator(updateUserCommand.OperateInfo)) | ||
937 | + if err != nil { | ||
938 | + return nil, err | ||
939 | + } | ||
940 | + user.DepartmentId = updateUserCommand.DepartmentId | ||
941 | + user.OrganizationId = updateUserCommand.OrganizationId | ||
942 | + var userOrg = make([]*domain.Org, 0) | ||
943 | + for i := range updateUserCommand.UserOrg { | ||
944 | + userOrg = append(userOrg, &domain.Org{OrgId: updateUserCommand.UserOrg[i]}) | ||
945 | + } | ||
946 | + user.UserOrg = userOrg | ||
947 | + var userRole = make([]*domain.Role, 0) | ||
948 | + for i := range updateUserCommand.UserRole { | ||
949 | + userRole = append(userRole, &domain.Role{RoleId: updateUserCommand.UserRole[i]}) | ||
950 | + } | ||
951 | + user.UserRole = userRole | ||
952 | + | ||
953 | + userInfo := &domain.UserInfo{ | ||
954 | + UserName: updateUserCommand.UserName, | ||
955 | + Phone: updateUserCommand.Phone, | ||
956 | + Avatar: updateUserCommand.Avatar, | ||
957 | + Email: updateUserCommand.Email, | ||
958 | + DepartmentName: updateUserCommand.DepartmentName, | ||
959 | + } | ||
960 | + | ||
961 | + updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{ | ||
962 | + "transactionContext": transactionContext, | ||
963 | + }) | ||
964 | + if user, err = updateUserService.UpdateUser(nil, user, userInfo, user.EnableStatus); err != nil { | ||
965 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
966 | + } | ||
967 | + userDto := &dto.UserDto{} | ||
968 | + if err := userDto.LoadDto(user, nil); err != nil { | ||
969 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
970 | + } | ||
971 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
972 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
973 | + } | ||
974 | + return userDto, nil | ||
975 | +} | ||
976 | + | ||
856 | func NewUserService(options map[string]interface{}) *UserService { | 977 | func NewUserService(options map[string]interface{}) *UserService { |
857 | newUserService := &UserService{} | 978 | newUserService := &UserService{} |
858 | return newUserService | 979 | return newUserService |
@@ -15,6 +15,7 @@ const ( | @@ -15,6 +15,7 @@ const ( | ||
15 | UserTypeEmployee = 1 | 15 | UserTypeEmployee = 1 |
16 | UserTypeCooperation = 2 | 16 | UserTypeCooperation = 2 |
17 | UserTypeVisitor = 4 // 游客 | 17 | UserTypeVisitor = 4 // 游客 |
18 | + UserTypeOperationAdmin = 8 // 运营管理员 | ||
18 | UserTypeCompanyAdmin = 1024 | 19 | UserTypeCompanyAdmin = 1024 |
19 | ) | 20 | ) |
20 | 21 |
@@ -57,7 +57,7 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain | @@ -57,7 +57,7 @@ func (ptr *PgCreateUserService) CreateUser(optUser *domain.User, newUser *domain | ||
57 | // 普通账号需要验证 | 57 | // 普通账号需要验证 |
58 | // 1.用户编号唯一验证 用户编号在该企业内已存在,请重新输入 | 58 | // 1.用户编号唯一验证 用户编号在该企业内已存在,请重新输入 |
59 | // 2.当前企业内手机号唯一 手机号在该企业内已存在,请重新输入 | 59 | // 2.当前企业内手机号唯一 手机号在该企业内已存在,请重新输入 |
60 | - if newUser.UserType&(domain.UserTypeCompanyAdmin|domain.UserTypeVisitor) == 0 { | 60 | + if newUser.UserType&(domain.UserTypeCompanyAdmin|domain.UserTypeVisitor|domain.UserTypeOperationAdmin) == 0 { |
61 | if user, err = userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "organizationId": newUser.OrganizationId, "userCode": newUser.UserCode}); err == nil && user != nil { | 61 | if user, err = userRepository.FindOne(map[string]interface{}{"companyId": newUser.CompanyId, "organizationId": newUser.OrganizationId, "userCode": newUser.UserCode}); err == nil && user != nil { |
62 | return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入") | 62 | return nil, fmt.Errorf("用户编号在该企业内已存在,请重新输入") |
63 | } | 63 | } |
@@ -19,19 +19,19 @@ type PgRoleAccessMenusService struct { | @@ -19,19 +19,19 @@ type PgRoleAccessMenusService struct { | ||
19 | // | 19 | // |
20 | // options 数据参数 | 20 | // options 数据参数 |
21 | // data 需要验证权限的数据 | 21 | // data 需要验证权限的数据 |
22 | -func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleId []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) { | 22 | +func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleIds []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) { |
23 | var err error | 23 | var err error |
24 | var menus []*domain.Menu | 24 | var menus []*domain.Menu |
25 | menuIdSet := hashset.New() | 25 | menuIdSet := hashset.New() |
26 | - if len(roleId) == 0 { | 26 | + if len(roleIds) == 0 { |
27 | return menus, nil | 27 | return menus, nil |
28 | } | 28 | } |
29 | 29 | ||
30 | // 1.角色有权限的菜单列表 | 30 | // 1.角色有权限的菜单列表 |
31 | roleRepository, _ := repository.NewRoleRepository(ptr.transactionContext) | 31 | roleRepository, _ := repository.NewRoleRepository(ptr.transactionContext) |
32 | - for i := range roleId { | 32 | + for i := range roleIds { |
33 | var role *domain.Role | 33 | var role *domain.Role |
34 | - if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleId[i]}); role == nil { | 34 | + if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleIds[i]}); role == nil { |
35 | continue | 35 | continue |
36 | } | 36 | } |
37 | // 只要当前登录组织的有权限菜单 | 37 | // 只要当前登录组织的有权限菜单 |
@@ -87,6 +87,8 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do | @@ -87,6 +87,8 @@ func (ptr *PgUpdateUserService) UpdateUser(optUser *domain.OperateInfo, user *do | ||
87 | } | 87 | } |
88 | if dep != nil { | 88 | if dep != nil { |
89 | user.Ext.DepName = dep.OrgName | 89 | user.Ext.DepName = dep.OrgName |
90 | + } else { | ||
91 | + user.Ext.DepName = userInfo.DepartmentName | ||
90 | } | 92 | } |
91 | user.Ext.Phone = userBase.UserInfo.Phone | 93 | user.Ext.Phone = userBase.UserInfo.Phone |
92 | user.Ext.UserName = userBase.UserInfo.UserName | 94 | user.Ext.UserName = userBase.UserInfo.UserName |
@@ -159,3 +159,23 @@ func (controller *UserController) SearchUser() { | @@ -159,3 +159,23 @@ func (controller *UserController) SearchUser() { | ||
159 | data, err := userService.ListUser(listUserQuery) | 159 | data, err := userService.ListUser(listUserQuery) |
160 | controller.Response(data, err) | 160 | controller.Response(data, err) |
161 | } | 161 | } |
162 | + | ||
163 | +func (controller *UserController) CreateAdminUser() { | ||
164 | + userService := service.NewUserService(nil) | ||
165 | + createUserCommand := &command.CreateAdminUserCommand{} | ||
166 | + Must(controller.Unmarshal(createUserCommand)) | ||
167 | + createUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
168 | + data, err := userService.CreateAdminUser(createUserCommand) | ||
169 | + controller.Response(data, err) | ||
170 | +} | ||
171 | + | ||
172 | +func (controller *UserController) UpdateAdminUser() { | ||
173 | + userService := service.NewUserService(nil) | ||
174 | + updateUserCommand := &command.UpdateAdminUserCommand{} | ||
175 | + Must(controller.Unmarshal(updateUserCommand)) | ||
176 | + userId, _ := controller.GetInt64(":userId") | ||
177 | + updateUserCommand.UserId = userId | ||
178 | + updateUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
179 | + data, err := userService.UpdateAdminUser(updateUserCommand) | ||
180 | + controller.Response(data, err) | ||
181 | +} |
@@ -20,4 +20,7 @@ func init() { | @@ -20,4 +20,7 @@ func init() { | ||
20 | web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase") | 20 | web.Router("/user/:userId/base-info", &controllers.UserController{}, "Put:UpdateUsersBase") |
21 | web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator") | 21 | web.Router("/user/cooperator", &controllers.UserController{}, "Post:CreateCooperator") |
22 | web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator") | 22 | web.Router("/user/cooperator/:userId", &controllers.UserController{}, "Put:UpdateCooperator") |
23 | + | ||
24 | + web.Router("/admin-user/", &controllers.UserController{}, "Post:CreateAdminUser") | ||
25 | + web.Router("/admin-user/:userId", &controllers.UserController{}, "Put:UpdateAdminUser") | ||
23 | } | 26 | } |
-
请 注册 或 登录 后发表评论