作者 yangfu

登录修改 用户信息

@@ -800,3 +800,40 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac @@ -800,3 +800,40 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac
800 rsp = rspData 800 rsp = rspData
801 return rsp, err 801 return rsp, err
802 } 802 }
  803 +
  804 +/*******************运营登录**********************/
  805 +//AuthLogin 用户登录
  806 +func (svr AuthService) AuthAdminLogin(loginCommand *command.LoginPwdCommand) (interface{}, error) {
  807 + if err := loginCommand.ValidateCommand(); err != nil {
  808 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  809 + }
  810 + if len(loginCommand.Username) == 0 {
  811 + return nil, application.ThrowError(application.BUSINESS_ERROR, "账号不存在")
  812 + }
  813 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  814 + users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  815 + UserType: domain.UserTypeOperationAdmin,
  816 + Phone: loginCommand.Username,
  817 + })
  818 + if err != nil {
  819 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  820 + }
  821 + if len(users.Users) == 0 {
  822 + return nil, application.ThrowError(application.BUSINESS_ERROR, "账号不存在")
  823 + }
  824 + login := &command.LoginCommand{
  825 + GrantType: "signInPassword",
  826 + Phone: loginCommand.Username,
  827 + Password: loginCommand.Password,
  828 + SessionMode: loginCommand.SessionMode,
  829 + DeviceType: loginCommand.DeviceType,
  830 + }
  831 + if len(loginCommand.CaptchaChallenge) > 0 {
  832 + geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
  833 + validateResult := geetest.SuccessValidate(loginCommand.CaptchaChallenge, loginCommand.CaptchaValidate, loginCommand.CaptchaSeccode, "", "")
  834 + if !validateResult {
  835 + log.Logger.Error("validate captcha fail")
  836 + }
  837 + }
  838 + return svr.AuthLogin(login)
  839 +}
@@ -54,6 +54,11 @@ func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyComm @@ -54,6 +54,11 @@ func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyComm
54 if err != nil { 54 if err != nil {
55 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 55 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
56 } 56 }
  57 + if cmd.Status == domain.CompanyAuthenticated {
  58 +
  59 + } else if cmd.Status == domain.CompanyUnauthenticated {
  60 +
  61 + }
57 return struct{}{}, nil 62 return struct{}{}, nil
58 } 63 }
59 64
  1 +package command
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 +)
  6 +
  7 +type AdminUserAddCommand struct {
  8 + //操作人
  9 + Operator domain.Operator `json:"-"`
  10 + // 用户编号
  11 + UsersCode string `json:"userCode" valid:"Required"`
  12 + // 用户姓名
  13 + UsersName string `json:"userName" valid:"Required"`
  14 + // 部门id
  15 + DepartmentName string `json:"departmentName" valid:"Required"`
  16 + // 手机号码
  17 + Phone string `json:"phone" valid:"Required"`
  18 +}
  19 +
  20 +//func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
  21 +//
  22 +//}
  23 +//
  24 +//func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
  25 +// valid := validation.Validation{}
  26 +// b, err := valid.Valid(companyUserAddCommand)
  27 +// if err != nil {
  28 +// return err
  29 +// }
  30 +// if !b {
  31 +// for _, validErr := range valid.Errors {
  32 +// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  33 +// }
  34 +// }
  35 +// return nil
  36 +//}
  1 +package command
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 +)
  6 +
  7 +type AdminUserEditCommand struct {
  8 + //操作人
  9 + Operator domain.Operator `json:"-"`
  10 + UserId int64 `json:"userId"`
  11 + // 用户编号
  12 + UsersCode string `json:"userCode" valid:"Required"`
  13 + // 用户姓名
  14 + UsersName string `json:"userName" valid:"Required"`
  15 + // 部门id
  16 + DepartmentName string `json:"departmentName" valid:"Required"`
  17 + // 手机号码
  18 + Phone string `json:"phone" valid:"Required"`
  19 +}
  20 +
  21 +//func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
  22 +//
  23 +//}
  24 +//
  25 +//func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
  26 +// valid := validation.Validation{}
  27 +// b, err := valid.Valid(companyUserAddCommand)
  28 +// if err != nil {
  29 +// return err
  30 +// }
  31 +// if !b {
  32 +// for _, validErr := range valid.Errors {
  33 +// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  34 +// }
  35 +// }
  36 +// return nil
  37 +//}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type EnableAdminUserCommand struct {
  13 + Operator domain.Operator `json:"-"`
  14 + UserId int64 `cname:"用户id列表" json:"userId" valid:"Required"`
  15 + // 启用状态(启用:1 禁用:2 )
  16 + EnableStatus int `cname:"启用状态(启用:1 禁用:2 )" json:"enableStatus" valid:"Required"`
  17 +}
  18 +
  19 +func (batchEnableCommand *EnableAdminUserCommand) Valid(validation *validation.Validation) {
  20 +}
  21 +
  22 +func (batchEnableCommand *EnableAdminUserCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(batchEnableCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(batchEnableCommand).Elem()
  30 + for _, validErr := range valid.Errors {
  31 + field, isExist := elem.FieldByName(validErr.Field)
  32 + if isExist {
  33 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  34 + } else {
  35 + return fmt.Errorf(validErr.Message)
  36 + }
  37 + }
  38 + }
  39 + return nil
  40 +}
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  5 + "time"
  6 +)
  7 +
  8 +type AdminUserDto struct {
  9 + // 用户基础数据id
  10 + UserId int `json:"userId,omitempty"`
  11 + // 用工编号
  12 + UserCode string `json:"userCode"`
  13 + //姓名
  14 + UserName string `json:"userName"`
  15 + // 账号
  16 + Phone string `json:"phone"`
  17 + // 用户关联的组织
  18 + DepartmentName string `json:"departmentName"`
  19 + // 账号状态 1:正常 2.禁用 3:注销
  20 + EnableStatus int `json:"enableStatus,omitempty"`
  21 + // 推荐人
  22 + Referer string `json:"referer"`
  23 + // 创建时间
  24 + RegistrationDate string `json:"registrationDate,omitempty"`
  25 + // 最后登录时间
  26 + LastLogIn string `json:"lastLogIn"`
  27 +}
  28 +
  29 +func NewAdminUserDto(v allied_creation_user.UserDetail) AdminUserDto {
  30 + item := AdminUserDto{
  31 + UserCode: v.UserCode,
  32 + UserId: v.UserId,
  33 + Phone: v.UserInfo.Phone,
  34 + DepartmentName: v.Department.DepartmentName,
  35 + EnableStatus: v.EnableStatus,
  36 + UserName: v.UserInfo.UserName,
  37 + RegistrationDate: v.CreatedAt.Format("2006-01-02"),
  38 + LastLogIn: "",
  39 + }
  40 + if v.Favorite.LastLogInAt > 0 {
  41 + item.LastLogIn = time.Unix(v.Favorite.LastLogInAt, 0).Format("2006-01-02 15:04:05")
  42 + }
  43 + return item
  44 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type ListAdminUserQuery struct {
  13 + Operator domain.Operator `json:"-"`
  14 + // 查询偏离量
  15 + PageNumber int `cname:"查询偏离量" json:"pageNumber"`
  16 + // 查询限制
  17 + PageSize int `cname:"查询限制" json:"pageSize"`
  18 + // 用户姓名
  19 + UserName string `cname:"用户姓名" json:"userName,omitempty"`
  20 + // 所属组织
  21 + DepartmentName string `cname:"所属部门" json:"departmentName,omitempty"`
  22 +}
  23 +
  24 +func (listUserQuery *ListAdminUserQuery) Valid(validation *validation.Validation) {
  25 + //validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (listUserQuery *ListAdminUserQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(listUserQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(listUserQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  10 + "strconv"
  11 +)
  12 +
  13 +// 返回公司用户信息列表
  14 +func (usersService *UserService) AdminUserList(companyUserListQuery *query.ListAdminUserQuery) (int64, interface{}, error) {
  15 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  16 + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  17 + Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
  18 + Limit: companyUserListQuery.PageSize,
  19 + OrganizationId: 0,
  20 + DepartmentId: 0,
  21 + UserName: companyUserListQuery.UserName,
  22 + DepName: companyUserListQuery.DepartmentName,
  23 + Phone: "",
  24 + UserType: domain.UserTypeOperationAdmin,
  25 + PullRealTime: true,
  26 + })
  27 +
  28 + if err != nil {
  29 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  30 + }
  31 + //数据转换
  32 + cnt := int64(result.Count)
  33 + var (
  34 + listData = make([]dto.AdminUserDto, 0)
  35 + item dto.AdminUserDto
  36 + )
  37 + for _, v := range result.Users {
  38 + item = dto.NewAdminUserDto(v)
  39 + listData = append(listData, item)
  40 + }
  41 + return cnt, listData, nil
  42 +}
  43 +
  44 +// 启用禁用用户
  45 +func (usersService *UserService) EnableAdminUser(companyUserEnableCommand *command.EnableAdminUserCommand) (interface{}, error) {
  46 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  47 + companyUserEnableCommand.Operator)
  48 +
  49 + var userIds []int64 = []int64{companyUserEnableCommand.UserId}
  50 + _, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
  51 + UserIds: userIds,
  52 + EnableStatus: companyUserEnableCommand.EnableStatus,
  53 + })
  54 + if err != nil {
  55 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  56 + }
  57 + return companyUserEnableCommand, err
  58 +}
  59 +
  60 +func (usersService *UserService) GetAdminUser(userId int) (interface{}, error) {
  61 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  62 + domain.Operator{})
  63 + result, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
  64 + UserId: userId,
  65 + })
  66 + if err != nil {
  67 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  68 + }
  69 + userInfo := dto.NewAdminUserDto(result.UserDetail)
  70 + return userInfo, nil
  71 +}
  72 +
  73 +func (usersService *UserService) CreateAdminUser(cmd *command.AdminUserAddCommand) (interface{}, error) {
  74 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  75 + cmd.Operator)
  76 + userOrg := []int64{}
  77 + userRole := []int64{}
  78 + initPassword := domain.DefaultPassword
  79 +
  80 + result, err := creationUserGateway.AdminUserCreate(allied_creation_user.ReqCreateUser{
  81 + CompanyId: cmd.Operator.CompanyId,
  82 + // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
  83 + UserType: domain.UserTypeOperationAdmin,
  84 + UserCode: cmd.UsersCode,
  85 + UserOrg: userOrg,
  86 + UserRole: userRole,
  87 + // 启用状态(启用:1 禁用:2)
  88 + EnableStatus: 1,
  89 + UserName: cmd.UsersName,
  90 + Phone: cmd.Phone,
  91 + Password: initPassword,
  92 + DepartmentName: cmd.DepartmentName,
  93 + })
  94 + if err != nil {
  95 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  96 + }
  97 +
  98 + data := struct {
  99 + UserId string `json:"userId"`
  100 + command.AdminUserAddCommand
  101 + }{
  102 + UserId: strconv.Itoa(result.UserId),
  103 + AdminUserAddCommand: *cmd,
  104 + }
  105 + return data, err
  106 +}
  107 +
  108 +func (usersService *UserService) UpdateAdminUser(cmd *command.AdminUserEditCommand) (interface{}, error) {
  109 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  110 + cmd.Operator)
  111 + user, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  112 + Account: cmd.Phone,
  113 + })
  114 + _, err = creationUserGateway.AdminUserUpdate(allied_creation_user.ReqUpdateUser{
  115 + UserId: cmd.UserId,
  116 + //CooperationCompany: cmd.CooperationCompany,
  117 + //CooperationDeadline: time.Unix(cmd.CooperationDeadline/1000, 0),
  118 + Email: user.UserInfo.Email,
  119 + //EnableStatus: user.,
  120 + UserCode: cmd.UsersCode,
  121 + UserName: cmd.UsersName,
  122 + Avatar: user.UserInfo.Avatar,
  123 + //OrgId: cmd.Operator.OrgId,
  124 + Phone: cmd.Phone,
  125 + DepartmentName: cmd.DepartmentName,
  126 + })
  127 + if err != nil {
  128 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  129 + }
  130 + return cmd, err
  131 +}
  132 +
  133 +func (svr *UserService) GetAdminUserInfo(operator domain.Operator) (interface{}, error) {
  134 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  135 + operator)
  136 +
  137 + resultUser, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  138 + Account: operator.Phone,
  139 + })
  140 + if err != nil {
  141 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  142 + }
  143 +
  144 + users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  145 + UserBaseId: int64(resultUser.UserBaseID),
  146 + UserType: domain.UserTypeOperationAdmin,
  147 + })
  148 + if err != nil {
  149 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  150 + }
  151 + if len(users.Users) == 0 {
  152 + return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
  153 + }
  154 + var user = map[string]interface{}{
  155 + "userId": users.Users[0].UserId,
  156 + "userInfo": map[string]interface{}{
  157 + "userName": resultUser.UserInfo.UserName,
  158 + "userPhone": resultUser.UserInfo.Phone,
  159 + "userAvatar": resultUser.UserInfo.Avatar,
  160 + "email": resultUser.UserInfo.Email,
  161 + },
  162 + "department": struct{}{},
  163 + "company": map[string]interface{}{},
  164 + //"im": resultUser.Im,
  165 + "org": struct{}{},
  166 + }
  167 + return user, nil
  168 +}
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
9 ) 10 )
10 11
@@ -49,7 +50,7 @@ func (userService *UserService) ResetPassword(cmd *command.ResetPasswordCommand) @@ -49,7 +50,7 @@ func (userService *UserService) ResetPassword(cmd *command.ResetPasswordCommand)
49 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator) 50 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
50 _, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{ 51 _, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
51 Phone: cmd.Account, 52 Phone: cmd.Account,
52 - Password: "4a693460c4cf078ea5b6b5a9e2cf382064a6f810", //TL123456! 53 + Password: domain.DefaultPassword, //TL123456!
53 }) 54 })
54 if err != nil { 55 if err != nil {
55 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 56 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -26,7 +26,7 @@ func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFa @@ -26,7 +26,7 @@ func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFa
26 } 26 }
27 27
28 // 返回菜单列表 28 // 返回菜单列表
29 -func (menuService *MenuService) MenuList(menuListQuery *query.MenuListQuery) (interface{}, error) { 29 +func (menuService *MenuService) CustomizeMenus(menuListQuery *query.MenuListQuery) (interface{}, error) {
30 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( 30 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
31 menuListQuery.Operator, 31 menuListQuery.Operator,
32 ) 32 )
@@ -59,6 +59,21 @@ func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdate @@ -59,6 +59,21 @@ func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdate
59 return menuUpdateCommand, nil 59 return menuUpdateCommand, nil
60 } 60 }
61 61
  62 +func (menuService *MenuService) MenuSearch(menuListQuery *query.MenuListQuery) (interface{}, error) {
  63 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  64 + menuListQuery.Operator,
  65 + )
  66 + result, err := creationUserGateway.MenusSearch(allied_creation_user.ReqMenusSearch{
  67 + MenuCategory: menuListQuery.MenuCategory,
  68 + })
  69 + if err != nil {
  70 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  71 + }
  72 + return map[string]interface{}{
  73 + "menus": result.Menus,
  74 + }, nil
  75 +}
  76 +
62 func NewMenuService(options map[string]interface{}) *MenuService { 77 func NewMenuService(options map[string]interface{}) *MenuService {
63 newMenuService := &MenuService{} 78 newMenuService := &MenuService{}
64 return newMenuService 79 return newMenuService
@@ -3,10 +3,11 @@ package domain @@ -3,10 +3,11 @@ package domain
3 /***** 1.用户模块 *****/ 3 /***** 1.用户模块 *****/
4 // 用户类型 4 // 用户类型
5 const ( 5 const (
6 - UserTypeEmployee = 1  
7 - UserTypeCooperation = 2  
8 - UserTypeVisitor = 4  
9 - UserTypeCompanyAdmin = 1024 6 + UserTypeEmployee = 1
  7 + UserTypeCooperation = 2
  8 + UserTypeVisitor = 4
  9 + UserTypeOperationAdmin = 8
  10 + UserTypeCompanyAdmin = 1024
10 ) 11 )
11 12
12 // 用户状态 13 // 用户状态
@@ -80,3 +81,7 @@ const ( @@ -80,3 +81,7 @@ const (
80 BlockChainSourceCooperationProject = "allied-creation.cooperation.project" 81 BlockChainSourceCooperationProject = "allied-creation.cooperation.project"
81 BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate" 82 BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate"
82 ) 83 )
  84 +
  85 +const (
  86 + DefaultPassword = "4a693460c4cf078ea5b6b5a9e2cf382064a6f810" // TL123456!
  87 +)
@@ -495,3 +495,66 @@ func (gateway HttplibAlliedCreationUser) EnableUserBase(param ReqEnableUserBase) @@ -495,3 +495,66 @@ func (gateway HttplibAlliedCreationUser) EnableUserBase(param ReqEnableUserBase)
495 //err = gateway.GetResponseData(result, &data) 495 //err = gateway.GetResponseData(result, &data)
496 return nil, err 496 return nil, err
497 } 497 }
  498 +
  499 +func (gateway HttplibAlliedCreationUser) AdminUserCreate(param ReqCreateUser) (*DataCreateUser, error) {
  500 + url := gateway.baseUrL + "/admin-user"
  501 + method := "post"
  502 + req := gateway.CreateRequest(url, method)
  503 + //TODO traceID
  504 + log.Logger.Debug("向用户模块请求数据:创建用户。", map[string]interface{}{
  505 + "api": method + ":" + url,
  506 + "param": param,
  507 + })
  508 + req, err := req.JSONBody(param)
  509 + if err != nil {
  510 + return nil, fmt.Errorf("创建用户失败:%w", err)
  511 + }
  512 +
  513 + byteResult, err := req.Bytes()
  514 + if err != nil {
  515 + return nil, fmt.Errorf("获取创建用户失败:%w", err)
  516 + }
  517 + log.Logger.Debug("获取用户模块请求数据:创建用户。", map[string]interface{}{
  518 + "result": string(byteResult),
  519 + })
  520 + var result service_gateway.GatewayResponse
  521 + err = json.Unmarshal(byteResult, &result)
  522 + if err != nil {
  523 + return nil, fmt.Errorf("解析创建用户:%w", err)
  524 + }
  525 + var data DataCreateUser
  526 + err = gateway.GetResponseData(result, &data)
  527 + return &data, err
  528 +}
  529 +
  530 +//UserUpdate 更新用户
  531 +func (gateway HttplibAlliedCreationUser) AdminUserUpdate(param ReqUpdateUser) (*DataUpdateUser, error) {
  532 + url := gateway.baseUrL + "/admin-user/" + strconv.Itoa(int(param.UserId))
  533 + method := "put"
  534 + req := gateway.CreateRequest(url, method)
  535 + //TODO traceID
  536 + log.Logger.Debug("向用户模块请求数据:更新用户。", map[string]interface{}{
  537 + "api": method + ":" + url,
  538 + "param": param,
  539 + })
  540 + req, err := req.JSONBody(param)
  541 + if err != nil {
  542 + return nil, fmt.Errorf("请求更新用户失败:%w", err)
  543 + }
  544 +
  545 + byteResult, err := req.Bytes()
  546 + if err != nil {
  547 + return nil, fmt.Errorf("获取更新用户失败:%w", err)
  548 + }
  549 + log.Logger.Debug("获取用户模块请求数据:更新用户。", map[string]interface{}{
  550 + "result": string(byteResult),
  551 + })
  552 + var result service_gateway.GatewayResponse
  553 + err = json.Unmarshal(byteResult, &result)
  554 + if err != nil {
  555 + return nil, fmt.Errorf("解析更新用户:%w", err)
  556 + }
  557 + var data DataUpdateUser
  558 + err = gateway.GetResponseData(result, &data)
  559 + return &data, err
  560 +}
@@ -69,6 +69,11 @@ type UserDetail struct { @@ -69,6 +69,11 @@ type UserDetail struct {
69 } `json:"im"` 69 } `json:"im"`
70 // 收藏的菜单(工作台)(菜单编码列表) 70 // 收藏的菜单(工作台)(菜单编码列表)
71 FavoriteMenus []string `json:"favoriteMenus"` 71 FavoriteMenus []string `json:"favoriteMenus"`
  72 + Favorite struct {
  73 + OrgItems []int64 `json:"orgItems"`
  74 + Referer string `json:"referer"`
  75 + LastLogInAt int64 `json:"lastLogInAt"`
  76 + } `json:"favorite"`
72 // 创建时间 77 // 创建时间
73 CreatedAt time.Time `json:"createdAt,omitempty"` 78 CreatedAt time.Time `json:"createdAt,omitempty"`
74 } 79 }
@@ -153,6 +158,9 @@ type ( @@ -153,6 +158,9 @@ type (
153 Avatar string `json:"avatar"` 158 Avatar string `json:"avatar"`
154 // 邮箱 159 // 邮箱
155 Email string `json:"email"` 160 Email string `json:"email"`
  161 +
  162 + // 部门
  163 + DepartmentName string `cname:"部门" json:"departmentName"`
156 } 164 }
157 DataCreateUser struct { 165 DataCreateUser struct {
158 UserId int `json:"userId"` 166 UserId int `json:"userId"`
@@ -189,6 +197,9 @@ type ( @@ -189,6 +197,9 @@ type (
189 Avatar string `json:"avatar"` 197 Avatar string `json:"avatar"`
190 // 邮箱 198 // 邮箱
191 Email string `json:"email"` 199 Email string `json:"email"`
  200 + // 运营管理扩展
  201 + // 部门
  202 + DepartmentName string `cname:"部门" json:"departmentName"`
192 } 203 }
193 204
194 DataUpdateUser struct { 205 DataUpdateUser struct {
@@ -63,6 +63,43 @@ func (smsServe HttplibSmsServe) SendSms(phone string) error { @@ -63,6 +63,43 @@ func (smsServe HttplibSmsServe) SendSms(phone string) error {
63 return nil 63 return nil
64 } 64 }
65 65
  66 +//SendSms 公共短信验证码服务 发送验证码
  67 +func (smsServe HttplibSmsServe) SendNoticeSms(phone string, tplId int, tplValues []string) error {
  68 + url := smsServe.baseUrL + "/service/sendNoticeSms"
  69 + method := "post"
  70 + req := smsServe.CreateRequest(url, method)
  71 + param := map[string]interface{}{
  72 + "phone": phone,
  73 + "tplId": tplId,
  74 + "tplValues": tplValues,
  75 + }
  76 + log.Logger.Debug("向公共短信验证码服务请求数据:短信验证码接口。", map[string]interface{}{
  77 + "api": method + ":" + url,
  78 + "param": param,
  79 + })
  80 + req, err := req.JSONBody(param)
  81 + if err != nil {
  82 + return fmt.Errorf("请求公共短信验证码服务失败:%w", err)
  83 + }
  84 +
  85 + byteResult, err := req.Bytes()
  86 + if err != nil {
  87 + return fmt.Errorf("获取公共短信验证码服务失败:%w", err)
  88 + }
  89 + log.Logger.Debug("获取公共短信验证码服务请求数据", map[string]interface{}{
  90 + "result": string(byteResult),
  91 + })
  92 + var result service_gateway.GatewayResponse
  93 + err = json.Unmarshal(byteResult, &result)
  94 + if err != nil {
  95 + return fmt.Errorf("解析更新组织:%w", err)
  96 + }
  97 + if result.Code != 0 {
  98 + return fmt.Errorf(result.Msg)
  99 + }
  100 + return nil
  101 +}
  102 +
66 //CheckSmsCode 公共短信验证码服务 校验验证码 103 //CheckSmsCode 公共短信验证码服务 校验验证码
67 func (smsServe HttplibSmsServe) CheckSmsCode(phone string, code string) error { 104 func (smsServe HttplibSmsServe) CheckSmsCode(phone string, code string) error {
68 if code == constant.SMSCODE_ALL_POWER { 105 if code == constant.SMSCODE_ALL_POWER {
@@ -49,6 +49,7 @@ func init() { @@ -49,6 +49,7 @@ func init() {
49 filters.SecureKeyMap["token"] = "x-mmm-accesstoken" 49 filters.SecureKeyMap["token"] = "x-mmm-accesstoken"
50 web.InsertFilter("/*", web.BeforeRouter, AllowCors()) 50 web.InsertFilter("/*", web.BeforeRouter, AllowCors())
51 web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger)) 51 web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger))
  52 + web.InsertFilter("/v1/background/*", web.BeforeExec, middleware.CheckAccessToken())
52 web.InsertFilter("/v1/web/*", web.BeforeExec, middleware.CheckAccessToken()) 53 web.InsertFilter("/v1/web/*", web.BeforeExec, middleware.CheckAccessToken())
53 web.InsertFilter("/v1/app/*", web.BeforeExec, middleware.CheckAccessToken()) 54 web.InsertFilter("/v1/app/*", web.BeforeExec, middleware.CheckAccessToken())
54 web.InsertFilter("/v1/user/*", web.BeforeExec, middleware.CheckAccessToken()) 55 web.InsertFilter("/v1/user/*", web.BeforeExec, middleware.CheckAccessToken())
  1 +package backgroud_client
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/service"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
  7 +)
  8 +
  9 +type AuthController struct {
  10 + controllers.BaseController
  11 +}
  12 +
  13 +func (controller *AuthController) LoginPwd() {
  14 + authService := service.AuthService{}
  15 + loginCmd := &command.LoginPwdCommand{}
  16 + //Must()
  17 + controller.Unmarshal(loginCmd)
  18 + data, err := authService.AuthAdminLogin(loginCmd)
  19 + controller.Response(data, err)
  20 +}
@@ -4,10 +4,11 @@ import ( @@ -4,10 +4,11 @@ import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/service" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/service"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
7 ) 8 )
8 9
9 type UserController struct { 10 type UserController struct {
10 - baseController 11 + controllers.BaseController
11 } 12 }
12 13
13 func (controller *UserController) SearchUser() { 14 func (controller *UserController) SearchUser() {
@@ -15,7 +16,7 @@ func (controller *UserController) SearchUser() { @@ -15,7 +16,7 @@ func (controller *UserController) SearchUser() {
15 listCompanyQuery := &query.ListUserQuery{} 16 listCompanyQuery := &query.ListUserQuery{}
16 controller.Unmarshal(listCompanyQuery) 17 controller.Unmarshal(listCompanyQuery)
17 cnt, data, err := companyService.SearchUser(listCompanyQuery) 18 cnt, data, err := companyService.SearchUser(listCompanyQuery)
18 - controller.returnPageListData(cnt, data, err, listCompanyQuery.PageNumber) 19 + controller.ReturnPageListData(cnt, data, err, listCompanyQuery.PageNumber)
19 } 20 }
20 21
21 func (controller *UserController) EnableUser() { 22 func (controller *UserController) EnableUser() {
@@ -33,3 +34,51 @@ func (controller *UserController) ResetPassword() { @@ -33,3 +34,51 @@ func (controller *UserController) ResetPassword() {
33 data, err := companyService.ResetPassword(cmd) 34 data, err := companyService.ResetPassword(cmd)
34 controller.Response(data, err) 35 controller.Response(data, err)
35 } 36 }
  37 +
  38 +func (controller *UserController) SearchAdminUser() {
  39 + companyService := service.NewUserService(nil)
  40 + q := &query.ListAdminUserQuery{}
  41 + controller.Unmarshal(q)
  42 + cnt, data, err := companyService.AdminUserList(q)
  43 + controller.ReturnPageListData(cnt, data, err, q.PageNumber)
  44 +}
  45 +
  46 +func (controller *UserController) EnableAdminUser() {
  47 + companyService := service.NewUserService(nil)
  48 + cmd := &command.EnableAdminUserCommand{}
  49 + controller.Unmarshal(cmd)
  50 + data, err := companyService.EnableAdminUser(cmd)
  51 + controller.Response(data, err)
  52 +}
  53 +
  54 +func (controller *UserController) GetAdminUser() {
  55 + companyService := service.NewUserService(nil)
  56 + userId, _ := controller.GetInt(":userId")
  57 + data, err := companyService.GetAdminUser(userId)
  58 + controller.Response(data, err)
  59 +}
  60 +
  61 +func (controller *UserController) UpdateAdminUser() {
  62 + companyService := service.NewUserService(nil)
  63 + cmd := &command.AdminUserEditCommand{}
  64 + controller.Unmarshal(cmd)
  65 + userId, _ := controller.GetInt(":userId")
  66 + cmd.UserId = int64(userId)
  67 + data, err := companyService.UpdateAdminUser(cmd)
  68 + controller.Response(data, err)
  69 +}
  70 +
  71 +func (controller *UserController) CreateAdminUser() {
  72 + companyService := service.NewUserService(nil)
  73 + cmd := &command.AdminUserAddCommand{}
  74 + controller.Unmarshal(cmd)
  75 + data, err := companyService.CreateAdminUser(cmd)
  76 + controller.Response(data, err)
  77 +}
  78 +
  79 +func (controller *UserController) GetAdminUserInfo() {
  80 + companyService := service.NewUserService(nil)
  81 + operator := controller.GetOperator()
  82 + data, err := companyService.GetAdminUserInfo(operator)
  83 + controller.Response(data, err)
  84 +}
@@ -19,7 +19,7 @@ func (controller *MenuController) MenuList() { @@ -19,7 +19,7 @@ func (controller *MenuController) MenuList() {
19 log.Logger.Debug("json err:" + err.Error()) 19 log.Logger.Debug("json err:" + err.Error())
20 } 20 }
21 menuListQuery.Operator = controller.GetOperator() 21 menuListQuery.Operator = controller.GetOperator()
22 - data, err := menuService.MenuList(menuListQuery) 22 + data, err := menuService.CustomizeMenus(menuListQuery)
23 controller.Response(data, err) 23 controller.Response(data, err)
24 } 24 }
25 25
@@ -46,3 +46,15 @@ func (controller *MenuController) MenuFavorite() { @@ -46,3 +46,15 @@ func (controller *MenuController) MenuFavorite() {
46 data, err := menuService.MenuFavorite(menuFavoriteCommand) 46 data, err := menuService.MenuFavorite(menuFavoriteCommand)
47 controller.Response(data, err) 47 controller.Response(data, err)
48 } 48 }
  49 +
  50 +func (controller *MenuController) MenuSearch() {
  51 + menuService := service.NewMenuService(nil)
  52 + menuListQuery := &query.MenuListQuery{}
  53 + err := controller.Unmarshal(menuListQuery)
  54 + if err != nil {
  55 + log.Logger.Debug("json err:" + err.Error())
  56 + }
  57 + menuListQuery.Operator = controller.GetOperator()
  58 + data, err := menuService.MenuSearch(menuListQuery)
  59 + controller.Response(data, err)
  60 +}
@@ -42,6 +42,8 @@ func CheckAccessToken() web.FilterFunc { @@ -42,6 +42,8 @@ func CheckAccessToken() web.FilterFunc {
42 "/v1/user/cooperation-org": "", 42 "/v1/user/cooperation-org": "",
43 "/v1/app/cooperation-projects/person/shared-info": "", //共创项目详情 - 未登录可以查看 43 "/v1/app/cooperation-projects/person/shared-info": "", //共创项目详情 - 未登录可以查看
44 "/v1/app/cooperation-projects/person/shared-info/attachment": "", 44 "/v1/app/cooperation-projects/person/shared-info/attachment": "",
  45 +
  46 + "/v1/background/auth/login/pwd": "",
45 } 47 }
46 var err error 48 var err error
47 if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil { 49 if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil {
@@ -3,6 +3,7 @@ package routers @@ -3,6 +3,7 @@ package routers
3 import ( 3 import (
4 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
6 ) 7 )
7 8
8 func init() { 9 func init() {
@@ -33,4 +34,16 @@ func init() { @@ -33,4 +34,16 @@ func init() {
33 web.Router("/v1/background/user/search", &backgroud_client.UserController{}, "Post:SearchUser") 34 web.Router("/v1/background/user/search", &backgroud_client.UserController{}, "Post:SearchUser")
34 web.Router("/v1/background/user/enable", &backgroud_client.UserController{}, "Post:EnableUser") 35 web.Router("/v1/background/user/enable", &backgroud_client.UserController{}, "Post:EnableUser")
35 web.Router("/v1/background/user/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword") 36 web.Router("/v1/background/user/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword")
  37 +
  38 + // admin
  39 + web.Router("/v1/background/user-admin/search", &backgroud_client.UserController{}, "Post:SearchAdminUser")
  40 + web.Router("/v1/background/user-admin/:userId", &backgroud_client.UserController{}, "Get:GetAdminUser")
  41 + web.Router("/v1/background/user-admin/:userId", &backgroud_client.UserController{}, "Put:UpdateAdminUser")
  42 + web.Router("/v1/background/user-admin/", &backgroud_client.UserController{}, "Post:CreateAdminUser")
  43 + web.Router("/v1/background/user-admin/enable", &backgroud_client.UserController{}, "Post:EnableAdminUser")
  44 + web.Router("/v1/background/user-admin/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword")
  45 +
  46 + web.Router("/v1/background/auth/login/pwd", &backgroud_client.AuthController{}, "Post:LoginPwd")
  47 + web.Router("/v1/background/auth/user-info", &backgroud_client.UserController{}, "Post:GetAdminUserInfo")
  48 + web.Router("/v1/background/auth/user-menu", &web_client.MenuController{}, "Post:MenuSearch")
36 } 49 }