修改用户接口
This commit is contained in:
parent
a87c903304
commit
b91b256204
|
|
@ -140,6 +140,7 @@ CREATE TABLE IF NOT EXISTS `menu`(
|
|||
`icon` varchar(255) NOT NULL DEFAULT '' COMMENT '图标',
|
||||
`path` varchar(512) NOT NULL DEFAULT '' COMMENT '访问路径',
|
||||
`child_path` varchar(255) NOT NULL DEFAULT '' COMMENT '子级路径(前端用)',
|
||||
`component` varchar(512) NOT NULL DEFAULT '' COMMENT '组件路径',
|
||||
`go_first_child` tinyint(1) NOT NULL DEFAULT 0 COMMENT '前端用',
|
||||
`is_show` int(5) NOT NULL DEFAULT 0 COMMENT '是否显示(0:否;1:是)',
|
||||
`created_by` VARCHAR(64) DEFAULT '' COMMENT '创建人',
|
||||
|
|
@ -193,11 +194,11 @@ REPLACE INTO `user`(`account`,`name`,`mobile`,`email`,`pwd`,`salt`,`created_by`)
|
|||
REPLACE INTO `application` (`code`,`secret`,`name`,`description`,`created_by`) VALUES('user-busniss-center','146E5EA66B4B6036C6BBF395CC90C30E','用户中心','用户,统一登陆等','admin');
|
||||
|
||||
--init menu
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`is_show`,`created_by`) VALUES('user-busniss-center','index','首页','',1,0,'home','/home','',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`is_show`,`created_by`) VALUES('user-busniss-center','user','用户','',1,1,'user','/user','',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`is_show`,`created_by`) VALUES('user-busniss-center','organization','组织','',1,2,'organization','/organization','',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`is_show`,`created_by`) VALUES('user-busniss-center','role','角色','',1,3,'role','/role','',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`is_show`,`created_by`) VALUES('user-busniss-center','application','应用','',1,4,'application','/application','',1,'admin');
|
||||
-- REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`component`,`is_show`,`created_by`) VALUES('user-busniss-center','index','首页','',1,0,'home','/home','','/view/dashboard/index.vue',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`component`,`is_show`,`created_by`) VALUES('user-busniss-center','user','用户','',1,1,'user','/user','','/view/user/index.vue',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`component`,`is_show`,`created_by`) VALUES('user-busniss-center','organization','组织','',1,2,'organization','/organization','','/view/organization/index.vue',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`component`,`is_show`,`created_by`) VALUES('user-busniss-center','role','角色','',1,3,'role','/role','','/view/role/index.vue',1,'admin');
|
||||
REPLACE INTO `menu`(`app_code`,`code`,`name`,`parent_code`,`type`,`order`,`icon`,`path`,`child_path`,`component`,`is_show`,`created_by`) VALUES('user-busniss-center','application','应用','',1,4,'application','/application','','/view/application/index.vue',1,'admin');
|
||||
|
||||
-- init role
|
||||
REPLACE INTO `role` (`code`,`name`,`created_by`) VALUES('super_admin','超级管理员','admin');
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ type Menu struct {
|
|||
ChildPath string `json:"child_path"` // 子级路径(前端用)
|
||||
GoFirstChild int8 `json:"go_first_child"` // 前端用
|
||||
IsShow int32 `json:"is_show"` // 是否显示(0:否;1:是)
|
||||
Component string `json:"component"` // 组件路径
|
||||
Children []Menu `json:"children"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ type UserInfo struct {
|
|||
|
||||
type User struct {
|
||||
UserInfo
|
||||
Roles []roleModel.Role
|
||||
Orgs []orgModel.Organization
|
||||
Menus appModel.MenuTree
|
||||
Roles []roleModel.Role `json:"roles"`
|
||||
Orgs []orgModel.Organization `json:"orgs"`
|
||||
Menus []appModel.Menu `json:"menus"`
|
||||
}
|
||||
|
||||
type ModifyInfo struct {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ type Menu struct {
|
|||
Icon string `gorm:"column:icon;NOT NULL"` // 图标
|
||||
Path string `gorm:"column:path;NOT NULL"` // 访问路径
|
||||
ChildPath string `gorm:"column:child_path;NOT NULL"` // 子级路径(前端用)
|
||||
Component string `gorm:"column:component"` // 组件路径
|
||||
GoFirstChild int `gorm:"column:go_first_child;default:0;NOT NULL"` // 前端用
|
||||
IsShow int `gorm:"column:is_show;default:0;NOT NULL"` // 是否显示(0:否;1:是)
|
||||
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ func (u *userService) GetUser(ctx context.Context, req *userModel.GetUserReq) (u
|
|||
return
|
||||
}
|
||||
|
||||
user.Menus = appModel.MenuTree{Menus: appInfo.Menus}
|
||||
user.Menus = appInfo.Menus
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ func (u *userService) setLoginStatus(ctx context.Context, user repo.User, claims
|
|||
if c, ok := ctx.(*gin.Context); ok {
|
||||
expires := u.conf.Jwt.Expires
|
||||
domain := u.conf.App.Host
|
||||
// domain := contextHelper.GetHost(ctx)
|
||||
c.Writer.Header().Add("Set-Cookie", fmt.Sprintf("%s=%s; Max-Age=%d; Path=/;Domain=%s", COOKIE_KEY_TOKEN, tokenStr, expires, domain))
|
||||
c.Writer.Header().Add("Set-Cookie", fmt.Sprintf("%s=%s; Max-Age=%d; Path=/;Domain=%s", COOKIE_KEY_ACCOUNT, claims["account"], expires, domain))
|
||||
c.Writer.Header().Add("Set-Cookie", fmt.Sprintf("%s=%s; Max-Age=%d; Path=/;Domain=%s", COOKIE_KEY_ID, claims["id"], expires, domain))
|
||||
c.Writer.Header().Add("Set-Cookie", fmt.Sprintf("%s=%d; Max-Age=%d; Path=/;Domain=%s", COOKIE_KEY_ID, claims["id"], expires, domain))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -69,3 +69,21 @@ func PutSession(ctx context.Context, sess *session.Session) context.Context {
|
|||
return context.WithValue(ctx, contextSessionKey{}, sess)
|
||||
}
|
||||
}
|
||||
|
||||
func GetHost(ctx context.Context) string {
|
||||
switch c := ctx.(type) {
|
||||
case *gin.Context:
|
||||
return c.Request.Host
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func GetPath(ctx context.Context) string {
|
||||
switch c := ctx.(type) {
|
||||
case *gin.Context:
|
||||
return c.Request.URL.Path
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
userModel "busniess-user-center/internal/models/user"
|
||||
"busniess-user-center/internal/service/user"
|
||||
|
||||
contextUtil "busniess-user-center/pkg/utils/context"
|
||||
ginUtil "busniess-user-center/pkg/utils/gin"
|
||||
"busniess-user-center/server/user/proto"
|
||||
"context"
|
||||
|
|
@ -37,7 +38,7 @@ func RegisterRoute(api *gin.RouterGroup) {
|
|||
api.POST("/logout", ginUtil.WrapNo(server.Logout))
|
||||
api.POST("/modify", ginUtil.WrapNoRsp(server.Modify))
|
||||
api.GET("/search", ginUtil.Wrap(server.Search))
|
||||
api.GET("/user", ginUtil.Wrap(server.GetUser))
|
||||
api.GET("/user", ginUtil.WrapNoReq(server.GetUser))
|
||||
api.POST("/reset", ginUtil.WrapNoRsp(server.ResetPwd))
|
||||
api.POST("/enable", ginUtil.WrapNoRsp(server.Enable))
|
||||
api.POST("/disable", ginUtil.WrapNoRsp(server.Disable))
|
||||
|
|
@ -89,8 +90,13 @@ func (u *UserServer) Search(ctx context.Context, query *base.Query) (*userModel.
|
|||
return u.userService.Search(ctx, query)
|
||||
}
|
||||
|
||||
func (u *UserServer) GetUser(ctx context.Context, req *userModel.GetUserReq) (userModel.User, error) {
|
||||
return u.userService.GetUser(ctx, req)
|
||||
func (u *UserServer) GetUser(ctx context.Context) (userModel.User, error) {
|
||||
session, err := contextUtil.GetSession(ctx)
|
||||
if err != nil {
|
||||
return userModel.User{}, err
|
||||
}
|
||||
|
||||
return u.userService.GetUser(ctx, &userModel.GetUserReq{AppCode: session.AppCode, Account: session.Account})
|
||||
}
|
||||
|
||||
func (u *UserServer) ResetPwd(ctx context.Context, req *userModel.ResetPwdReq) error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue