作者 yangfu

Merge branch 'dev' into test

@@ -68,7 +68,7 @@ type ( @@ -68,7 +68,7 @@ type (
68 } 68 }
69 RoleItem { 69 RoleItem {
70 Id int64 `json:"id,optional"` // 角色ID 70 Id int64 `json:"id,optional"` // 角色ID
71 - CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID 71 + CompanyId int64 `json:"companyId,optional,string,omitempty"` // 公司ID
72 Name string `json:"name"` // 角色名称 72 Name string `json:"name"` // 角色名称
73 AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表 73 AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
74 AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述 74 AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
@@ -139,8 +139,10 @@ type( @@ -139,8 +139,10 @@ type(
139 Type string `json:"type"` // 快讯类型 文章:Article 讨论:Discuss ... 139 Type string `json:"type"` // 快讯类型 文章:Article 讨论:Discuss ...
140 Title string `json:"title"` // 标题 140 Title string `json:"title"` // 标题
141 Summary string `json:"summary"` // 快讯概要 141 Summary string `json:"summary"` // 快讯概要
142 - Time int64 `json:"time"` // 时间 142 + Time int64 `json:"time"` // 时间
143 ReadFlag bool `json:"readFlag"` // 已读标识 true:已读 false:未读 143 ReadFlag bool `json:"readFlag"` // 已读标识 true:已读 false:未读
  144 + Images []string `json:"images"` // 图片列表
  145 + Author UserItem `json:"author"` // 作者
144 } 146 }
145 MiniUserFollowedSearchRequest{ 147 MiniUserFollowedSearchRequest{
146 Page int `json:"page,optional"` 148 Page int `json:"page,optional"`
@@ -166,7 +168,7 @@ type( @@ -166,7 +168,7 @@ type(
166 //Roles []int64 `json:"roleId,omitempty"` // 角色 168 //Roles []int64 `json:"roleId,omitempty"` // 角色
167 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) 169 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
168 Name string `json:"name,omitempty"` // 名称 170 Name string `json:"name,omitempty"` // 名称
169 - Avatar string `json:"avatar,omitempty"` // 头像 171 + Avatar *string `json:"avatar,omitempty"` // 头像
170 Phone string `json:"phone,omitempty"` // 手机号 唯一 172 Phone string `json:"phone,omitempty"` // 手机号 唯一
171 Position string `json:"position,omitempty"` // 职位 173 Position string `json:"position,omitempty"` // 职位
172 Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 174 Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
@@ -31,14 +31,16 @@ func (l *SystemDeleteRoleLogic) SystemDeleteRole(req *types.RoleDeleteRequest) ( @@ -31,14 +31,16 @@ func (l *SystemDeleteRoleLogic) SystemDeleteRole(req *types.RoleDeleteRequest) (
31 conn = l.svcCtx.DefaultDBConn() 31 conn = l.svcCtx.DefaultDBConn()
32 role *domain.Role 32 role *domain.Role
33 userRemoveRoleList []*domain.User 33 userRemoveRoleList []*domain.User
  34 + userRoles []*domain.UserRole
34 ) 35 )
35 if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil { 36 if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil {
36 return nil, xerr.NewErrMsgErr("角色不存在", err) 37 return nil, xerr.NewErrMsgErr("角色不存在", err)
37 } 38 }
38 - for _, item := range role.Users { 39 + _, userRoles, _ = l.svcCtx.UserRoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(role.CompanyId)().WithKV("roleId", role.Id).WithFindOnly())
  40 + for _, item := range userRoles {
39 var user *domain.User 41 var user *domain.User
40 - if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, item.Id); err != nil {  
41 - return nil, xerr.NewErrMsgErr("用户存在", err) 42 + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, item.UserId); err != nil {
  43 + continue
42 } 44 }
43 userRemoveRoleList = append(userRemoveRoleList, user) 45 userRemoveRoleList = append(userRemoveRoleList, user)
44 } 46 }
@@ -52,6 +54,9 @@ func (l *SystemDeleteRoleLogic) SystemDeleteRole(req *types.RoleDeleteRequest) ( @@ -52,6 +54,9 @@ func (l *SystemDeleteRoleLogic) SystemDeleteRole(req *types.RoleDeleteRequest) (
52 return err 54 return err
53 } 55 }
54 } 56 }
  57 + if err = l.svcCtx.UserRoleRepository.DeleteRole(l.ctx, conn, role.Id); err != nil {
  58 + return err
  59 + }
55 return nil 60 return nil
56 }, true); err != nil { 61 }, true); err != nil {
57 return nil, xerr.NewErrMsgErr("删除角色失败", err) 62 return nil, xerr.NewErrMsgErr("删除角色失败", err)
@@ -56,6 +56,13 @@ func (l *SystemSaveRoleLogic) SystemSaveRole(req *types.RoleSaveRequest) (resp * @@ -56,6 +56,13 @@ func (l *SystemSaveRoleLogic) SystemSaveRole(req *types.RoleSaveRequest) (resp *
56 if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { 56 if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
57 return err 57 return err
58 } 58 }
  59 + if _, err = l.svcCtx.UserRoleRepository.Insert(l.ctx, conn, &domain.UserRole{
  60 + CompanyId: user.CompanyId,
  61 + UserId: user.Id,
  62 + RoleId: role.Id,
  63 + }); err != nil {
  64 + return err
  65 + }
59 } 66 }
60 return nil 67 return nil
61 }, true); err != nil { 68 }, true); err != nil {
@@ -82,7 +89,7 @@ func NewDomainRole(ctx context.Context, item types.RoleItem) *domain.Role { @@ -82,7 +89,7 @@ func NewDomainRole(ctx context.Context, item types.RoleItem) *domain.Role {
82 Name: item.Name, 89 Name: item.Name,
83 Auths: item.AuthIds, 90 Auths: item.AuthIds,
84 Remark: item.Remark, 91 Remark: item.Remark,
85 - Users: users, 92 + //Users: users,
86 } 93 }
87 return role 94 return role
88 } 95 }
@@ -37,6 +37,8 @@ func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) ( @@ -37,6 +37,8 @@ func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) (
37 37
38 userRemoveRoleList []*domain.User 38 userRemoveRoleList []*domain.User
39 userAddRoleList []*domain.User 39 userAddRoleList []*domain.User
  40 +
  41 + userRoles []*domain.UserRole
40 ) 42 )
41 if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil { 43 if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil {
42 return nil, xerr.NewErrMsgErr("角色不存在", err) 44 return nil, xerr.NewErrMsgErr("角色不存在", err)
@@ -46,11 +48,12 @@ func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) ( @@ -46,11 +48,12 @@ func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) (
46 return nil, xerr.NewErrMsg(fmt.Sprintf("unknown auth %d ", authId)) 48 return nil, xerr.NewErrMsg(fmt.Sprintf("unknown auth %d ", authId))
47 } 49 }
48 } 50 }
49 - lo.ForEach(role.Users, func(item domain.User, index int) {  
50 - beforeUserIds = append(beforeUserIds, item.Id) 51 + _, userRoles, _ = l.svcCtx.UserRoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(role.CompanyId)().WithKV("roleId", role.Id).WithFindOnly())
  52 + beforeUserIds = domain.Values(userRoles, func(item *domain.UserRole) int64 {
  53 + return item.UserId
51 }) 54 })
52 tempRole := NewDomainRole(l.ctx, req.Role) 55 tempRole := NewDomainRole(l.ctx, req.Role)
53 - lo.ForEach(tempRole.Users, func(item domain.User, index int) { 56 + lo.ForEach(req.Role.Users, func(item types.RoleUser, index int) {
54 afterUserIds = append(afterUserIds, item.Id) 57 afterUserIds = append(afterUserIds, item.Id)
55 }) 58 })
56 removeList, addList := lo.Difference(beforeUserIds, afterUserIds) 59 removeList, addList := lo.Difference(beforeUserIds, afterUserIds)
@@ -69,26 +72,36 @@ func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) ( @@ -69,26 +72,36 @@ func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) (
69 userAddRoleList = append(userAddRoleList, user) 72 userAddRoleList = append(userAddRoleList, user)
70 } 73 }
71 if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { 74 if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  75 + // 更新角色
72 role.Name = tempRole.Name 76 role.Name = tempRole.Name
73 role.Auths = tempRole.Auths 77 role.Auths = tempRole.Auths
74 role.Remark = tempRole.Remark 78 role.Remark = tempRole.Remark
75 - role.Users = tempRole.Users  
76 if role, err = l.svcCtx.RoleRepository.UpdateWithVersion(ctx, conn, role); err != nil { 79 if role, err = l.svcCtx.RoleRepository.UpdateWithVersion(ctx, conn, role); err != nil {
77 return err 80 return err
78 } 81 }
79 - 82 + // 移除角色用户
80 for _, user := range userRemoveRoleList { 83 for _, user := range userRemoveRoleList {
81 user.RemoveRole(role.Id) 84 user.RemoveRole(role.Id)
82 if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { 85 if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
83 return err 86 return err
84 } 87 }
  88 + if err = l.svcCtx.UserRoleRepository.DeleteByUserAndRole(ctx, conn, user.Id, role.Id); err != nil {
  89 + return err
  90 + }
85 } 91 }
86 - 92 + // 新增角色用户
87 for _, user := range userAddRoleList { 93 for _, user := range userAddRoleList {
88 user.AddRole(role.Id) 94 user.AddRole(role.Id)
89 if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { 95 if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
90 return err 96 return err
91 } 97 }
  98 + if _, err = l.svcCtx.UserRoleRepository.Insert(l.ctx, conn, &domain.UserRole{
  99 + CompanyId: user.CompanyId,
  100 + UserId: user.Id,
  101 + RoleId: role.Id,
  102 + }); err != nil {
  103 + return err
  104 + }
92 } 105 }
93 return nil 106 return nil
94 }, true); err != nil { 107 }, true); err != nil {
@@ -58,7 +58,7 @@ func NewUserItemSimple(user *domain.User, company *domain.Company) *types.UserIt @@ -58,7 +58,7 @@ func NewUserItemSimple(user *domain.User, company *domain.Company) *types.UserIt
58 Id: user.Id, 58 Id: user.Id,
59 Name: user.Name, 59 Name: user.Name,
60 CompanyName: lo.Ternary(company != nil, company.Name, ""), 60 CompanyName: lo.Ternary(company != nil, company.Name, ""),
61 - Avatar: user.Avatar, 61 + Avatar: lo.ToPtr(user.Avatar),
62 Phone: user.Phone, 62 Phone: user.Phone,
63 Position: user.Position, 63 Position: user.Position,
64 AuditStatus: &user.AuditStatus, 64 AuditStatus: &user.AuditStatus,
@@ -48,7 +48,7 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp * @@ -48,7 +48,7 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *
48 User: &types.UserItem{ 48 User: &types.UserItem{
49 Id: user.Id, 49 Id: user.Id,
50 Name: user.Name, 50 Name: user.Name,
51 - Avatar: user.Avatar, 51 + Avatar: lo.ToPtr(user.Avatar),
52 Position: user.Position, 52 Position: user.Position,
53 AuditStatus: lo.ToPtr(user.AuditStatus), 53 AuditStatus: lo.ToPtr(user.AuditStatus),
54 Enable: user.Enable, 54 Enable: user.Enable,
@@ -34,6 +34,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp * @@ -34,6 +34,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
34 userToken = contextdata.GetUserTokenFromCtx(l.ctx) 34 userToken = contextdata.GetUserTokenFromCtx(l.ctx)
35 articles []*domain.Article 35 articles []*domain.Article
36 readArticles = make([]*domain.UserReadArticle, 0) 36 readArticles = make([]*domain.UserReadArticle, 0)
  37 + userMap = make(map[int64]*domain.User)
37 ) 38 )
38 if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil { 39 if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
39 return nil, xerr.NewErrMsgErr("用户不存在", err) 40 return nil, xerr.NewErrMsgErr("用户不存在", err)
@@ -67,8 +68,19 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp * @@ -67,8 +68,19 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
67 Title: item.Title, 68 Title: item.Title,
68 Summary: item.Summary, 69 Summary: item.Summary,
69 Time: item.CreatedAt, 70 Time: item.CreatedAt,
  71 + Images: make([]string, 0),
70 ReadFlag: false, 72 ReadFlag: false,
71 } 73 }
  74 + if author, _ := domain.LazyLoad(userMap, l.ctx, conn, item.AuthorId, l.svcCtx.UserRepository.FindOne); author != nil {
  75 + newsItem.Author = types.UserItem{
  76 + Id: author.Id,
  77 + Name: author.Name,
  78 + Avatar: lo.ToPtr(author.Avatar),
  79 + }
  80 + }
  81 + for _, img := range item.Images {
  82 + newsItem.Images = append(newsItem.Images, img.Url)
  83 + }
72 if _, ok := readArticlesMap[item.Id]; ok { 84 if _, ok := readArticlesMap[item.Id]; ok {
73 newsItem.ReadFlag = true 85 newsItem.ReadFlag = true
74 } 86 }
@@ -472,12 +472,14 @@ type MiniUserNewsResposne struct { @@ -472,12 +472,14 @@ type MiniUserNewsResposne struct {
472 } 472 }
473 473
474 type UserNewsItem struct { 474 type UserNewsItem struct {
475 - NewsId int64 `json:"newsId"` // 快讯ID  
476 - Type string `json:"type"` // 快讯类型 文章:Article 讨论:Discuss ...  
477 - Title string `json:"title"` // 标题  
478 - Summary string `json:"summary"` // 快讯概要  
479 - Time int64 `json:"time"` // 时间  
480 - ReadFlag bool `json:"readFlag"` // 已读标识 true:已读 false:未读 475 + NewsId int64 `json:"newsId"` // 快讯ID
  476 + Type string `json:"type"` // 快讯类型 文章:Article 讨论:Discuss ...
  477 + Title string `json:"title"` // 标题
  478 + Summary string `json:"summary"` // 快讯概要
  479 + Time int64 `json:"time"` // 时间
  480 + ReadFlag bool `json:"readFlag"` // 已读标识 true:已读 false:未读
  481 + Images []string `json:"images"` // 图片列表
  482 + Author UserItem `json:"author"` // 作者
481 } 483 }
482 484
483 type MiniUserFollowedSearchRequest struct { 485 type MiniUserFollowedSearchRequest struct {
@@ -503,7 +505,7 @@ type UserItem struct { @@ -503,7 +505,7 @@ type UserItem struct {
503 CompanyLogo *string `json:"companyLogo,omitempty"` // 公司LOGO 505 CompanyLogo *string `json:"companyLogo,omitempty"` // 公司LOGO
504 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) 506 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
505 Name string `json:"name,omitempty"` // 名称 507 Name string `json:"name,omitempty"` // 名称
506 - Avatar string `json:"avatar,omitempty"` // 头像 508 + Avatar *string `json:"avatar,omitempty"` // 头像
507 Phone string `json:"phone,omitempty"` // 手机号 唯一 509 Phone string `json:"phone,omitempty"` // 手机号 唯一
508 Position string `json:"position,omitempty"` // 职位 510 Position string `json:"position,omitempty"` // 职位
509 Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 511 Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
@@ -1223,7 +1225,7 @@ type MiniSearchArticleItem struct { @@ -1223,7 +1225,7 @@ type MiniSearchArticleItem struct {
1223 ArticleId int64 `json:"articleId"` 1225 ArticleId int64 `json:"articleId"`
1224 Title string `json:"title"` 1226 Title string `json:"title"`
1225 Author string `json:"author"` // 发布人 1227 Author string `json:"author"` // 发布人
1226 - Avatar string `json:"avatar"` 1228 + Avatar string `json:"avatar"` // 发布人的头像
1227 Images []string `json:"images"` 1229 Images []string `json:"images"`
1228 CreatedAt int64 `json:"createdAt"` 1230 CreatedAt int64 `json:"createdAt"`
1229 MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] 1231 MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读]
@@ -1272,15 +1274,15 @@ type RoleSearchResponse struct { @@ -1272,15 +1274,15 @@ type RoleSearchResponse struct {
1272 } 1274 }
1273 1275
1274 type RoleItem struct { 1276 type RoleItem struct {
1275 - Id int64 `json:"id,optional"` // 角色ID  
1276 - CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID  
1277 - Name string `json:"name"` // 角色名称  
1278 - AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表  
1279 - AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述  
1280 - UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述  
1281 - Remark string `json:"remark,optional,omitempty"` // 备注  
1282 - Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户  
1283 - UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间 1277 + Id int64 `json:"id,optional"` // 角色ID
  1278 + CompanyId int64 `json:"companyId,optional,string,omitempty"` // 公司ID
  1279 + Name string `json:"name"` // 角色名称
  1280 + AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
  1281 + AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
  1282 + UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
  1283 + Remark string `json:"remark,optional,omitempty"` // 备注
  1284 + Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
  1285 + UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
1284 } 1286 }
1285 1287
1286 type RoleUser struct { 1288 type RoleUser struct {
@@ -105,6 +105,36 @@ func (repository *UserRoleRepository) DeleteByUser(ctx context.Context, conn tra @@ -105,6 +105,36 @@ func (repository *UserRoleRepository) DeleteByUser(ctx context.Context, conn tra
105 return nil 105 return nil
106 } 106 }
107 107
  108 +func (repository *UserRoleRepository) DeleteRole(ctx context.Context, conn transaction.Conn, roleId int64) error {
  109 + var (
  110 + tx = conn.DB()
  111 + m = &models.UserRole{}
  112 + )
  113 + queryFunc := func() (interface{}, error) {
  114 + tx = tx.Where("role_id = ?", roleId).Delete(m)
  115 + return m, tx.Error
  116 + }
  117 + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  118 + return err
  119 + }
  120 + return nil
  121 +}
  122 +
  123 +func (repository *UserRoleRepository) DeleteByUserAndRole(ctx context.Context, conn transaction.Conn, userId int64, roleId int64) error {
  124 + var (
  125 + tx = conn.DB()
  126 + m = &models.UserRole{}
  127 + )
  128 + queryFunc := func() (interface{}, error) {
  129 + tx = tx.Where("user_id = ?", userId).Where("role_id = ?", roleId).Delete(m)
  130 + return m, tx.Error
  131 + }
  132 + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  133 + return err
  134 + }
  135 + return nil
  136 +}
  137 +
108 func (repository *UserRoleRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.UserRole, error) { 138 func (repository *UserRoleRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.UserRole, error) {
109 var ( 139 var (
110 err error 140 err error
@@ -135,6 +165,12 @@ func (repository *UserRoleRepository) Find(ctx context.Context, conn transaction @@ -135,6 +165,12 @@ func (repository *UserRoleRepository) Find(ctx context.Context, conn transaction
135 ) 165 )
136 queryFunc := func() (interface{}, error) { 166 queryFunc := func() (interface{}, error) {
137 tx = tx.Model(&ms).Order("id desc") 167 tx = tx.Model(&ms).Order("id desc")
  168 + if v, ok := queryOptions["companyId"]; ok {
  169 + tx.Where("company_id = ?", v)
  170 + }
  171 + if v, ok := queryOptions["roleId"]; ok {
  172 + tx.Where("role_id = ?", v)
  173 + }
138 if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { 174 if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
139 return dms, tx.Error 175 return dms, tx.Error
140 } 176 }
@@ -11,7 +11,7 @@ type Role struct { @@ -11,7 +11,7 @@ type Role struct {
11 Name string `json:"name"` // 角色名称 11 Name string `json:"name"` // 角色名称
12 Auths []int64 `json:"auths"` // 角色权限列表 12 Auths []int64 `json:"auths"` // 角色权限列表
13 Remark string `json:"remark"` // 备注 13 Remark string `json:"remark"` // 备注
14 - Users []User `json:"users"` // 绑定的用户 14 + //Users []User `json:"users"` // (废弃)绑定的用户
15 15
16 CreatedAt int64 `json:"createdAt,omitempty"` 16 CreatedAt int64 `json:"createdAt,omitempty"`
17 UpdatedAt int64 `json:"updatedAt,omitempty"` 17 UpdatedAt int64 `json:"updatedAt,omitempty"`
@@ -22,6 +22,8 @@ type UserRoleRepository interface { @@ -22,6 +22,8 @@ type UserRoleRepository interface {
22 UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error) 22 UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error)
23 Delete(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error) 23 Delete(ctx context.Context, conn transaction.Conn, dm *UserRole) (*UserRole, error)
24 DeleteByUser(ctx context.Context, conn transaction.Conn, userId int64) error 24 DeleteByUser(ctx context.Context, conn transaction.Conn, userId int64) error
  25 + DeleteRole(ctx context.Context, conn transaction.Conn, roleId int64) error
  26 + DeleteByUserAndRole(ctx context.Context, conn transaction.Conn, userId int64, roleId int64) error
25 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*UserRole, error) 27 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*UserRole, error)
26 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*UserRole, error) 28 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*UserRole, error)
27 } 29 }