新增todo接口

This commit is contained in:
guosl 2024-07-07 18:42:09 +08:00
parent f2dea316bd
commit a9d040fb36
10 changed files with 159 additions and 16 deletions

View File

@ -11,6 +11,7 @@ v0.1.0
v0.1.1
1> 用户中心的登陆和其他应用的登陆统一做成sso
2> 支持同步企业微信,钉钉等第三方的用户,组织等信息
v0.2.0

View File

@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`salt` varchar(32) NOT NULL COMMENT '',
`sex` TINYINT DEFAULT 0 COMMENT '性别:0-女,1-男',
`status` TINYINT DEFAULT 1 NOT NULL COMMENT '状态:0-禁用,1-启用',
`direct_leaders` VARCHAR(64) DEFAULT'' COMMENT '直属领导账号',
`created_by` VARCHAR(64) DEFAULT '' COMMENT '创建人',
`created_on` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '记录创建时间',
`modified_by` VARCHAR(64) DEFAULT '' COMMENT '修改人',
@ -28,6 +29,7 @@ CREATE TABLE IF NOT EXISTS `organization` (
`sort` SMALLINT UNSIGNED DEFAULT 0 COMMENT '层级序号',
`status` TINYINT DEFAULT 1 COMMENT '状态:0-无效,1-有效',
`path` VARCHAR(1024) COMMENT '全路径',
`leaders` VARCHAR(1024) COMMENT '领导账号列表:["user1","user2"]',
`created_by` VARCHAR(64) DEFAULT '' COMMENT '创建人',
`created_on` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '记录创建时间',
`modified_by` VARCHAR(64) DEFAULT '' COMMENT '修改人',
@ -143,7 +145,8 @@ CREATE TABLE IF NOT EXISTS `role_menu_permission`(
`created_on` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '记录创建时间',
`modified_by` VARCHAR(64) DEFAULT '' COMMENT '修改人',
`modified_on` DATETIME DEFAULT CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP COMMENT '记录修改时间',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE KEY `uk_role_menu`(`role_id`,`menu_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COMMENT='角色菜单权限表';

View File

@ -9,6 +9,7 @@ type Organization struct {
Sort uint `json:"sort"` // 层级序号
Status int `json:"status"` // 状态:0-无效,1-有效
Path string `json:"path"` // 全路径
Leaders []string `json:"leaders"`
CreatedOn time.Time `json:"created_on"` // 记录创建时间
Children []Organization `json:"children"`
}

View File

@ -4,6 +4,7 @@ type CreateOrgReq struct {
Name string `json:"name" binding:"required"`
ParentId uint `json:"parent_id" binding:"required"`
Sort int `json:"sort" binding:"required"`
Leaders []string `json:"leaders"`
}
type DelOrgReq struct {
@ -24,6 +25,7 @@ type SaveOrgReq struct {
Name string `json:"name" binding:"required"`
ParentId uint `json:"parent_id" binding:"required"`
Sort int `json:"sort" binding:"required"`
Leaders []string `json:"leaders"`
}
type DisableOrgReq struct {
@ -33,3 +35,11 @@ type DisableOrgReq struct {
type EnableOrgReq struct {
Id uint `json:"id" binding:"required"`
}
type AddUsersReq struct {
Ids []uint `json:"ids"`
}
type RemoveUsersReq struct {
Ids []uint `json:"ids"`
}

View File

@ -39,3 +39,53 @@ type DelReq struct {
type GetReq struct {
Id uint `form:"id" json:"id" binding:"required"`
}
type AddUsersReq struct {
Ids []uint `json:"ids"`
}
type RemoveUsersReq struct {
Ids []uint `json:"ids"`
}
type OrgAuthorRoleType int
const (
ExcludeChildrenOrgAuthor OrgAuthorRoleType = 0
IncludeChildrenOrgAuthor OrgAuthorRoleType = 1
)
type OrgAuthorBrief struct {
Id uint `json:"id" binding:"required"`
Type OrgAuthorRoleType `json:"type"`
}
type AddOrgsReq struct {
Orgs OrgAuthorBrief `json:"orgs"`
}
type RemoveOrgsReq struct {
Ids []uint `json:"ids"`
}
type RoleUsersReq struct {
Id uint `json:"id" binding:"required"`
}
type RoleOrgsReq struct {
Id uint `json:"id" binding:"required"`
}
type AuthorRoleMenuReq struct {
AppCode string `json:"app_code" binding:"required"`
Ids []uint `json:"ids" binding:"required"`
}
type RemoveReleMenuReq struct {
Ids []uint `json:"ids"`
}
type RoleMenuListReq struct {
AppCode string `json:"app_code" binding:"required"`
RoleId uint `json:"role_id" binding:"required"`
}

View File

@ -1,6 +1,9 @@
package role
import "time"
import (
appModel "busniess-user-center/internal/models/application"
"time"
)
type Role struct {
ID uint `json:"id"` // id
@ -8,3 +11,20 @@ type Role struct {
Name string `json:"name"` // 名称
CreatedOn time.Time `json:"created_on"` // 记录创建时间
}
type OrgRoleAuthor struct {
ID uint `json:"id"` // id
OrgId uint `json:"org_id"`
OrgName string `json:"org_name"`
RoleId uint `json:"role_id"`
RoleName string `json:"role_name"`
Option int `json:"option"` //选择:0-选择组织,1-选择组织含下级
}
type RoleMenu struct {
appModel.Menu
RoleId uint `json:"role_id"`
RoleName uint `json:"role_name"`
RoleCode uint `json:"role_code"`
Author bool `json:"author"`
}

View File

@ -1,5 +1,11 @@
package models
import (
appModel "busniess-user-center/internal/models/application"
orgModel "busniess-user-center/internal/models/organization"
roleModel "busniess-user-center/internal/models/role"
)
type UserStatus int
const (
@ -32,6 +38,9 @@ type UserInfo struct {
type User struct {
Id uint
UserInfo
Roles []roleModel.Role
Orgs []orgModel.Organization
Menus appModel.MenuTree
}
type ModifyInfo struct {
@ -54,6 +63,7 @@ type ResetPwdReq struct {
type GetUserReq struct {
Account string `form:"account" json:"account" binding:"required"`
AppCode string `form:"app_code" json:"app_code" binding:"required"`
}
func (q *Query) Default() {

View File

@ -28,6 +28,7 @@ type Organization struct {
Sort uint `gorm:"column:sort;default:0"` // 层级序号
Status int `gorm:"column:status;default:1"` // 状态:0-无效,1-有效
Path string `gorm:"column:path"` // 全路径
Leaders string `gorm:"column:leaders"`
CreatedBy string `gorm:"column:created_by"` // 创建人
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
ModifiedBy string `gorm:"column:modified_by"` // 修改人

View File

@ -72,3 +72,13 @@ func (u *OrganizationServer) DisableOrganization(ctx context.Context, info *orgM
func (u *OrganizationServer) EnableOrganization(ctx context.Context, info *orgModel.EnableOrgReq) error {
return u.organizationService.EnableOrganization(ctx, info)
}
func (u *OrganizationServer) AddUsers(ctx context.Context, info *orgModel.AddUsersReq) error {
// todo
return nil
}
func (u *OrganizationServer) RemoveUsers(ctx context.Context, info *orgModel.RemoveUsersReq) error {
// todo
return nil
}

View File

@ -4,6 +4,7 @@ import (
"context"
roleModel "busniess-user-center/internal/models/role"
userModel "busniess-user-center/internal/models/user"
roleService "busniess-user-center/internal/service/role"
ginUtil "busniess-user-center/pkg/utils/gin"
@ -57,3 +58,39 @@ func (u *RoleServer) Role(ctx context.Context, info *roleModel.GetReq) (roleMode
func (u *RoleServer) Search(ctx context.Context, info *roleModel.Query) ([]roleModel.Role, error) {
return u.roleService.Search(ctx, info)
}
func (u *RoleServer) AddUsers(ctx context.Context, info *roleModel.AddUsersReq) error {
return nil
}
func (u *RoleServer) RemoveUsers(ctx context.Context, info *roleModel.RemoveUsersReq) error {
return nil
}
func (u *RoleServer) AddOrgs(ctx context.Context, info *roleModel.AddOrgsReq) error {
return nil
}
func (u *RoleServer) RemoveOrgs(ctx context.Context, info *roleModel.RemoveOrgsReq) error {
return nil
}
func (u *RoleServer) RoleUsers(ctx context.Context, info *roleModel.RoleUsersReq) ([]userModel.User, error) {
return nil, nil
}
func (u *RoleServer) RoleOrgs(ctx context.Context, info *roleModel.RoleOrgsReq) ([]roleModel.OrgRoleAuthor, error) {
return nil, nil
}
func (u *RoleServer) AuthorRoleMenu(ctx context.Context, info *roleModel.AuthorRoleMenuReq) error {
return nil
}
func (u *RoleServer) RemoveRoleMenu(ctx context.Context, info *roleModel.RemoveReleMenuReq) error {
return nil
}
func (u *RoleServer) RoleMenuAuthorList(ctx context.Context, info *roleModel.AddOrgsReq) ([]roleModel.RoleMenu, error) {
return nil, nil
}