作者 yangfu

登录修改 用户信息

... ... @@ -800,3 +800,40 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac
rsp = rspData
return rsp, err
}
/*******************运营登录**********************/
//AuthLogin 用户登录
func (svr AuthService) AuthAdminLogin(loginCommand *command.LoginPwdCommand) (interface{}, error) {
if err := loginCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
if len(loginCommand.Username) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "账号不存在")
}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
UserType: domain.UserTypeOperationAdmin,
Phone: loginCommand.Username,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if len(users.Users) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "账号不存在")
}
login := &command.LoginCommand{
GrantType: "signInPassword",
Phone: loginCommand.Username,
Password: loginCommand.Password,
SessionMode: loginCommand.SessionMode,
DeviceType: loginCommand.DeviceType,
}
if len(loginCommand.CaptchaChallenge) > 0 {
geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
validateResult := geetest.SuccessValidate(loginCommand.CaptchaChallenge, loginCommand.CaptchaValidate, loginCommand.CaptchaSeccode, "", "")
if !validateResult {
log.Logger.Error("validate captcha fail")
}
}
return svr.AuthLogin(login)
}
... ...
... ... @@ -54,6 +54,11 @@ func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyComm
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cmd.Status == domain.CompanyAuthenticated {
} else if cmd.Status == domain.CompanyUnauthenticated {
}
return struct{}{}, nil
}
... ...
package command
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type AdminUserAddCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersCode string `json:"userCode" valid:"Required"`
// 用户姓名
UsersName string `json:"userName" valid:"Required"`
// 部门id
DepartmentName string `json:"departmentName" valid:"Required"`
// 手机号码
Phone string `json:"phone" valid:"Required"`
}
//func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
//
//}
//
//func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
// valid := validation.Validation{}
// b, err := valid.Valid(companyUserAddCommand)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
//}
... ...
package command
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type AdminUserEditCommand struct {
//操作人
Operator domain.Operator `json:"-"`
UserId int64 `json:"userId"`
// 用户编号
UsersCode string `json:"userCode" valid:"Required"`
// 用户姓名
UsersName string `json:"userName" valid:"Required"`
// 部门id
DepartmentName string `json:"departmentName" valid:"Required"`
// 手机号码
Phone string `json:"phone" valid:"Required"`
}
//func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
//
//}
//
//func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
// valid := validation.Validation{}
// b, err := valid.Valid(companyUserAddCommand)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
//}
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type EnableAdminUserCommand struct {
Operator domain.Operator `json:"-"`
UserId int64 `cname:"用户id列表" json:"userId" valid:"Required"`
// 启用状态(启用:1 禁用:2 )
EnableStatus int `cname:"启用状态(启用:1 禁用:2 )" json:"enableStatus" valid:"Required"`
}
func (batchEnableCommand *EnableAdminUserCommand) Valid(validation *validation.Validation) {
}
func (batchEnableCommand *EnableAdminUserCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(batchEnableCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(batchEnableCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"time"
)
type AdminUserDto struct {
// 用户基础数据id
UserId int `json:"userId,omitempty"`
// 用工编号
UserCode string `json:"userCode"`
//姓名
UserName string `json:"userName"`
// 账号
Phone string `json:"phone"`
// 用户关联的组织
DepartmentName string `json:"departmentName"`
// 账号状态 1:正常 2.禁用 3:注销
EnableStatus int `json:"enableStatus,omitempty"`
// 推荐人
Referer string `json:"referer"`
// 创建时间
RegistrationDate string `json:"registrationDate,omitempty"`
// 最后登录时间
LastLogIn string `json:"lastLogIn"`
}
func NewAdminUserDto(v allied_creation_user.UserDetail) AdminUserDto {
item := AdminUserDto{
UserCode: v.UserCode,
UserId: v.UserId,
Phone: v.UserInfo.Phone,
DepartmentName: v.Department.DepartmentName,
EnableStatus: v.EnableStatus,
UserName: v.UserInfo.UserName,
RegistrationDate: v.CreatedAt.Format("2006-01-02"),
LastLogIn: "",
}
if v.Favorite.LastLogInAt > 0 {
item.LastLogIn = time.Unix(v.Favorite.LastLogInAt, 0).Format("2006-01-02 15:04:05")
}
return item
}
... ...
package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListAdminUserQuery struct {
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `cname:"查询偏离量" json:"pageNumber"`
// 查询限制
PageSize int `cname:"查询限制" json:"pageSize"`
// 用户姓名
UserName string `cname:"用户姓名" json:"userName,omitempty"`
// 所属组织
DepartmentName string `cname:"所属部门" json:"departmentName,omitempty"`
}
func (listUserQuery *ListAdminUserQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listUserQuery *ListAdminUserQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listUserQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listUserQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"strconv"
)
// 返回公司用户信息列表
func (usersService *UserService) AdminUserList(companyUserListQuery *query.ListAdminUserQuery) (int64, interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
Limit: companyUserListQuery.PageSize,
OrganizationId: 0,
DepartmentId: 0,
UserName: companyUserListQuery.UserName,
DepName: companyUserListQuery.DepartmentName,
Phone: "",
UserType: domain.UserTypeOperationAdmin,
PullRealTime: true,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//数据转换
cnt := int64(result.Count)
var (
listData = make([]dto.AdminUserDto, 0)
item dto.AdminUserDto
)
for _, v := range result.Users {
item = dto.NewAdminUserDto(v)
listData = append(listData, item)
}
return cnt, listData, nil
}
// 启用禁用用户
func (usersService *UserService) EnableAdminUser(companyUserEnableCommand *command.EnableAdminUserCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserEnableCommand.Operator)
var userIds []int64 = []int64{companyUserEnableCommand.UserId}
_, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: userIds,
EnableStatus: companyUserEnableCommand.EnableStatus,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return companyUserEnableCommand, err
}
func (usersService *UserService) GetAdminUser(userId int) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
domain.Operator{})
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
UserId: userId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
userInfo := dto.NewAdminUserDto(result.UserDetail)
return userInfo, nil
}
func (usersService *UserService) CreateAdminUser(cmd *command.AdminUserAddCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cmd.Operator)
userOrg := []int64{}
userRole := []int64{}
initPassword := domain.DefaultPassword
result, err := creationUserGateway.AdminUserCreate(allied_creation_user.ReqCreateUser{
CompanyId: cmd.Operator.CompanyId,
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType: domain.UserTypeOperationAdmin,
UserCode: cmd.UsersCode,
UserOrg: userOrg,
UserRole: userRole,
// 启用状态(启用:1 禁用:2)
EnableStatus: 1,
UserName: cmd.UsersName,
Phone: cmd.Phone,
Password: initPassword,
DepartmentName: cmd.DepartmentName,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
data := struct {
UserId string `json:"userId"`
command.AdminUserAddCommand
}{
UserId: strconv.Itoa(result.UserId),
AdminUserAddCommand: *cmd,
}
return data, err
}
func (usersService *UserService) UpdateAdminUser(cmd *command.AdminUserEditCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cmd.Operator)
user, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
Account: cmd.Phone,
})
_, err = creationUserGateway.AdminUserUpdate(allied_creation_user.ReqUpdateUser{
UserId: cmd.UserId,
//CooperationCompany: cmd.CooperationCompany,
//CooperationDeadline: time.Unix(cmd.CooperationDeadline/1000, 0),
Email: user.UserInfo.Email,
//EnableStatus: user.,
UserCode: cmd.UsersCode,
UserName: cmd.UsersName,
Avatar: user.UserInfo.Avatar,
//OrgId: cmd.Operator.OrgId,
Phone: cmd.Phone,
DepartmentName: cmd.DepartmentName,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return cmd, err
}
func (svr *UserService) GetAdminUserInfo(operator domain.Operator) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
operator)
resultUser, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
Account: operator.Phone,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
UserBaseId: int64(resultUser.UserBaseID),
UserType: domain.UserTypeOperationAdmin,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if len(users.Users) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
}
var user = map[string]interface{}{
"userId": users.Users[0].UserId,
"userInfo": map[string]interface{}{
"userName": resultUser.UserInfo.UserName,
"userPhone": resultUser.UserInfo.Phone,
"userAvatar": resultUser.UserInfo.Avatar,
"email": resultUser.UserInfo.Email,
},
"department": struct{}{},
"company": map[string]interface{}{},
//"im": resultUser.Im,
"org": struct{}{},
}
return user, nil
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
... ... @@ -49,7 +50,7 @@ func (userService *UserService) ResetPassword(cmd *command.ResetPasswordCommand)
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
_, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
Phone: cmd.Account,
Password: "4a693460c4cf078ea5b6b5a9e2cf382064a6f810", //TL123456!
Password: domain.DefaultPassword, //TL123456!
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -26,7 +26,7 @@ func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFa
}
// 返回菜单列表
func (menuService *MenuService) MenuList(menuListQuery *query.MenuListQuery) (interface{}, error) {
func (menuService *MenuService) CustomizeMenus(menuListQuery *query.MenuListQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuListQuery.Operator,
)
... ... @@ -59,6 +59,21 @@ func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdate
return menuUpdateCommand, nil
}
func (menuService *MenuService) MenuSearch(menuListQuery *query.MenuListQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuListQuery.Operator,
)
result, err := creationUserGateway.MenusSearch(allied_creation_user.ReqMenusSearch{
MenuCategory: menuListQuery.MenuCategory,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"menus": result.Menus,
}, nil
}
func NewMenuService(options map[string]interface{}) *MenuService {
newMenuService := &MenuService{}
return newMenuService
... ...
... ... @@ -3,10 +3,11 @@ package domain
/***** 1.用户模块 *****/
// 用户类型
const (
UserTypeEmployee = 1
UserTypeCooperation = 2
UserTypeVisitor = 4
UserTypeCompanyAdmin = 1024
UserTypeEmployee = 1
UserTypeCooperation = 2
UserTypeVisitor = 4
UserTypeOperationAdmin = 8
UserTypeCompanyAdmin = 1024
)
// 用户状态
... ... @@ -80,3 +81,7 @@ const (
BlockChainSourceCooperationProject = "allied-creation.cooperation.project"
BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate"
)
const (
DefaultPassword = "4a693460c4cf078ea5b6b5a9e2cf382064a6f810" // TL123456!
)
... ...
... ... @@ -495,3 +495,66 @@ func (gateway HttplibAlliedCreationUser) EnableUserBase(param ReqEnableUserBase)
//err = gateway.GetResponseData(result, &data)
return nil, err
}
func (gateway HttplibAlliedCreationUser) AdminUserCreate(param ReqCreateUser) (*DataCreateUser, error) {
url := gateway.baseUrL + "/admin-user"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:创建用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("创建用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取创建用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:创建用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析创建用户:%w", err)
}
var data DataCreateUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserUpdate 更新用户
func (gateway HttplibAlliedCreationUser) AdminUserUpdate(param ReqUpdateUser) (*DataUpdateUser, error) {
url := gateway.baseUrL + "/admin-user/" + strconv.Itoa(int(param.UserId))
method := "put"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:更新用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:更新用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新用户:%w", err)
}
var data DataUpdateUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -69,6 +69,11 @@ type UserDetail struct {
} `json:"im"`
// 收藏的菜单(工作台)(菜单编码列表)
FavoriteMenus []string `json:"favoriteMenus"`
Favorite struct {
OrgItems []int64 `json:"orgItems"`
Referer string `json:"referer"`
LastLogInAt int64 `json:"lastLogInAt"`
} `json:"favorite"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
}
... ... @@ -153,6 +158,9 @@ type (
Avatar string `json:"avatar"`
// 邮箱
Email string `json:"email"`
// 部门
DepartmentName string `cname:"部门" json:"departmentName"`
}
DataCreateUser struct {
UserId int `json:"userId"`
... ... @@ -189,6 +197,9 @@ type (
Avatar string `json:"avatar"`
// 邮箱
Email string `json:"email"`
// 运营管理扩展
// 部门
DepartmentName string `cname:"部门" json:"departmentName"`
}
DataUpdateUser struct {
... ...
... ... @@ -63,6 +63,43 @@ func (smsServe HttplibSmsServe) SendSms(phone string) error {
return nil
}
//SendSms 公共短信验证码服务 发送验证码
func (smsServe HttplibSmsServe) SendNoticeSms(phone string, tplId int, tplValues []string) error {
url := smsServe.baseUrL + "/service/sendNoticeSms"
method := "post"
req := smsServe.CreateRequest(url, method)
param := map[string]interface{}{
"phone": phone,
"tplId": tplId,
"tplValues": tplValues,
}
log.Logger.Debug("向公共短信验证码服务请求数据:短信验证码接口。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return fmt.Errorf("请求公共短信验证码服务失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return fmt.Errorf("获取公共短信验证码服务失败:%w", err)
}
log.Logger.Debug("获取公共短信验证码服务请求数据", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return fmt.Errorf("解析更新组织:%w", err)
}
if result.Code != 0 {
return fmt.Errorf(result.Msg)
}
return nil
}
//CheckSmsCode 公共短信验证码服务 校验验证码
func (smsServe HttplibSmsServe) CheckSmsCode(phone string, code string) error {
if code == constant.SMSCODE_ALL_POWER {
... ...
... ... @@ -49,6 +49,7 @@ func init() {
filters.SecureKeyMap["token"] = "x-mmm-accesstoken"
web.InsertFilter("/*", web.BeforeRouter, AllowCors())
web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger))
web.InsertFilter("/v1/background/*", web.BeforeExec, middleware.CheckAccessToken())
web.InsertFilter("/v1/web/*", web.BeforeExec, middleware.CheckAccessToken())
web.InsertFilter("/v1/app/*", web.BeforeExec, middleware.CheckAccessToken())
web.InsertFilter("/v1/user/*", web.BeforeExec, middleware.CheckAccessToken())
... ...
package backgroud_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
type AuthController struct {
controllers.BaseController
}
func (controller *AuthController) LoginPwd() {
authService := service.AuthService{}
loginCmd := &command.LoginPwdCommand{}
//Must()
controller.Unmarshal(loginCmd)
data, err := authService.AuthAdminLogin(loginCmd)
controller.Response(data, err)
}
... ...
... ... @@ -4,10 +4,11 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
type UserController struct {
baseController
controllers.BaseController
}
func (controller *UserController) SearchUser() {
... ... @@ -15,7 +16,7 @@ func (controller *UserController) SearchUser() {
listCompanyQuery := &query.ListUserQuery{}
controller.Unmarshal(listCompanyQuery)
cnt, data, err := companyService.SearchUser(listCompanyQuery)
controller.returnPageListData(cnt, data, err, listCompanyQuery.PageNumber)
controller.ReturnPageListData(cnt, data, err, listCompanyQuery.PageNumber)
}
func (controller *UserController) EnableUser() {
... ... @@ -33,3 +34,51 @@ func (controller *UserController) ResetPassword() {
data, err := companyService.ResetPassword(cmd)
controller.Response(data, err)
}
func (controller *UserController) SearchAdminUser() {
companyService := service.NewUserService(nil)
q := &query.ListAdminUserQuery{}
controller.Unmarshal(q)
cnt, data, err := companyService.AdminUserList(q)
controller.ReturnPageListData(cnt, data, err, q.PageNumber)
}
func (controller *UserController) EnableAdminUser() {
companyService := service.NewUserService(nil)
cmd := &command.EnableAdminUserCommand{}
controller.Unmarshal(cmd)
data, err := companyService.EnableAdminUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) GetAdminUser() {
companyService := service.NewUserService(nil)
userId, _ := controller.GetInt(":userId")
data, err := companyService.GetAdminUser(userId)
controller.Response(data, err)
}
func (controller *UserController) UpdateAdminUser() {
companyService := service.NewUserService(nil)
cmd := &command.AdminUserEditCommand{}
controller.Unmarshal(cmd)
userId, _ := controller.GetInt(":userId")
cmd.UserId = int64(userId)
data, err := companyService.UpdateAdminUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) CreateAdminUser() {
companyService := service.NewUserService(nil)
cmd := &command.AdminUserAddCommand{}
controller.Unmarshal(cmd)
data, err := companyService.CreateAdminUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) GetAdminUserInfo() {
companyService := service.NewUserService(nil)
operator := controller.GetOperator()
data, err := companyService.GetAdminUserInfo(operator)
controller.Response(data, err)
}
... ...
... ... @@ -19,7 +19,7 @@ func (controller *MenuController) MenuList() {
log.Logger.Debug("json err:" + err.Error())
}
menuListQuery.Operator = controller.GetOperator()
data, err := menuService.MenuList(menuListQuery)
data, err := menuService.CustomizeMenus(menuListQuery)
controller.Response(data, err)
}
... ... @@ -46,3 +46,15 @@ func (controller *MenuController) MenuFavorite() {
data, err := menuService.MenuFavorite(menuFavoriteCommand)
controller.Response(data, err)
}
func (controller *MenuController) MenuSearch() {
menuService := service.NewMenuService(nil)
menuListQuery := &query.MenuListQuery{}
err := controller.Unmarshal(menuListQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
menuListQuery.Operator = controller.GetOperator()
data, err := menuService.MenuSearch(menuListQuery)
controller.Response(data, err)
}
... ...
... ... @@ -42,6 +42,8 @@ func CheckAccessToken() web.FilterFunc {
"/v1/user/cooperation-org": "",
"/v1/app/cooperation-projects/person/shared-info": "", //共创项目详情 - 未登录可以查看
"/v1/app/cooperation-projects/person/shared-info/attachment": "",
"/v1/background/auth/login/pwd": "",
}
var err error
if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil {
... ...
... ... @@ -3,6 +3,7 @@ package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
)
func init() {
... ... @@ -33,4 +34,16 @@ func init() {
web.Router("/v1/background/user/search", &backgroud_client.UserController{}, "Post:SearchUser")
web.Router("/v1/background/user/enable", &backgroud_client.UserController{}, "Post:EnableUser")
web.Router("/v1/background/user/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword")
// admin
web.Router("/v1/background/user-admin/search", &backgroud_client.UserController{}, "Post:SearchAdminUser")
web.Router("/v1/background/user-admin/:userId", &backgroud_client.UserController{}, "Get:GetAdminUser")
web.Router("/v1/background/user-admin/:userId", &backgroud_client.UserController{}, "Put:UpdateAdminUser")
web.Router("/v1/background/user-admin/", &backgroud_client.UserController{}, "Post:CreateAdminUser")
web.Router("/v1/background/user-admin/enable", &backgroud_client.UserController{}, "Post:EnableAdminUser")
web.Router("/v1/background/user-admin/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword")
web.Router("/v1/background/auth/login/pwd", &backgroud_client.AuthController{}, "Post:LoginPwd")
web.Router("/v1/background/auth/user-info", &backgroud_client.UserController{}, "Post:GetAdminUserInfo")
web.Router("/v1/background/auth/user-menu", &web_client.MenuController{}, "Post:MenuSearch")
}
... ...