作者 郑周

角色添加用户

角色查询用户列表
接口完成
... ... @@ -28,6 +28,11 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{
}()
roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
//int64Array := make([]int64, 0)
//for i := range in.UserIds {
// int64Num, _ := strconv.ParseInt(in.UserIds[i], 10, 64)
// int64Array = append(int64Array, int64Num)
//}
// 检测已存在的关联用户
_, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999})
if err != nil {
... ...
... ... @@ -17,5 +17,5 @@ type EvaluationRule struct {
Score domain.Score `comment:"评分"`
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"`
DeletedAt *time.Time `comment:"删除时间"`
}
... ...
... ... @@ -10,5 +10,5 @@ type RoleUser struct {
CompanyId int64 `comment:"公司ID"`
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"`
DeletedAt *time.Time `comment:"删除时间"`
}
... ...
... ... @@ -125,7 +125,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64
}
if userIds, ok := queryOptions["userIds"]; ok {
query.Where("user_id in (?)", userIds)
query.Where("user_id in (?)", pg.In(userIds))
}
if v, ok := queryOptions["limit"].(int); ok {
... ... @@ -182,7 +182,7 @@ func (repo *RoleUserRepository) BatchDeleteById(ids []int64) error {
return err
}
func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int, companyId int64, roleId int64) ([]*domain.RoleContainUser, error) {
func (repo *RoleUserRepository) FindAllContainUser(pageNumber int, pageSize int, companyId int64, roleId int64) ([]*domain.RoleContainUser, error) {
limit := pageSize
offset := limit * (pageNumber - 1)
if offset < 0 {
... ... @@ -192,7 +192,7 @@ func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int,
"role_user".role_id,
"role_user".user_id,
"user".name as user_name,
"user".email as user_email,
"user".email as user_email
`
whereFrom := `
FROM "role_user"
... ...