修复pgsql和数据库导入bug,增加默认mod中的datatypes (#1712)
* 多文件: fix error specified more than once in PG * Update sys_authority.go * Update sys_authority.go * sys_export_template.go: 导入Excel时使用批量插入提高性能 * 添加gorm.io/datatypes --------- Co-authored-by: crazyrunsnail <fjyuan1991@163.com> Co-authored-by: XiMo-210 <2831802697@qq.com>
This commit is contained in:
co-authored by
crazyrunsnail
XiMo-210
parent
61dd524c26
commit
4074a52b1b
@@ -118,7 +118,13 @@ func (userService *UserService) SetUserAuthority(id uint, authorityId uint) (err
|
||||
|
||||
func (userService *UserService) SetUserAuthorities(id uint, authorityIds []uint) (err error) {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
TxErr := tx.Delete(&[]system.SysUserAuthority{}, "sys_user_id = ?", id).Error
|
||||
var user system.SysUser
|
||||
TxErr := tx.Where("id = ?", id).First(&user).Error
|
||||
if TxErr != nil {
|
||||
global.GVA_LOG.Debug(TxErr.Error())
|
||||
return errors.New("查询用户数据失败")
|
||||
}
|
||||
TxErr = tx.Delete(&[]system.SysUserAuthority{}, "sys_user_id = ?", id).Error
|
||||
if TxErr != nil {
|
||||
return TxErr
|
||||
}
|
||||
@@ -132,7 +138,7 @@ func (userService *UserService) SetUserAuthorities(id uint, authorityIds []uint)
|
||||
if TxErr != nil {
|
||||
return TxErr
|
||||
}
|
||||
TxErr = tx.Where("id = ?", id).First(&system.SysUser{}).Update("authority_id", authorityIds[0]).Error
|
||||
TxErr = tx.Model(&user).Update("authority_id", authorityIds[0]).Error
|
||||
if TxErr != nil {
|
||||
return TxErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user