feat: 添加商城权限自动回收机制
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-04-27 01:18:20 +08:00
parent ba1a1ffbea
commit ab7fe0639a
2 changed files with 29 additions and 8 deletions

View File

@@ -29,6 +29,8 @@ type BaseSysUserService struct {
*cool.Service
}
const ShopRoleID uint = 27
// Person 方法 返回不带密码的用户信息
func (s *BaseSysUserService) Person(userId uint) (res gdb.Record, err error) {
m := cool.DBM(s.Model)
@@ -70,6 +72,19 @@ func (s *BaseSysUserService) SetdepartmentId(userId, departmentId uint32) (res *
return
}
func (s *BaseSysUserService) CancelShopPermission(ctx context.Context, userId uint) error {
_, err := cool.DBM(model.NewBaseSysUserRole()).
Where("userId", userId).
Where("roleId", ShopRoleID).
Delete()
if err != nil {
return err
}
return NewBaseSysPermsService().RefreshPerms(ctx, userId)
}
func (s *BaseSysUserService) DuihuanFreeGold(userId uint32, gold, free int64) {
m := cool.DBM(s.Model).Where("id", userId)
m.Data(g.Map{