|
@@ -1,9 +1,9 @@
|
|
|
package data_manage_permission
|
|
|
|
|
|
import (
|
|
|
+ "eta_gn/eta_api/global"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
|
@@ -36,7 +36,7 @@ type ExcelClassifyPermission struct {
|
|
|
// @return err error
|
|
|
func SetIsPermissionByExcelClassifyIdList(classifyIdList []int, excelClassifySource int) (err error) {
|
|
|
num := len(classifyIdList)
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -62,7 +62,7 @@ func SetIsPermissionByExcelClassifyIdList(classifyIdList []int, excelClassifySou
|
|
|
|
|
|
// 先将所有已经设置了涉密的分类设置为不涉密
|
|
|
sql := `UPDATE excel_classify SET is_join_permission=?,modify_time=now() WHERE is_join_permission = 1 AND source = ?`
|
|
|
- _, err = o.Raw(sql, 0, excelClassifySource).Exec()
|
|
|
+ err = o.Exec(sql, 0, excelClassifySource).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -70,7 +70,7 @@ func SetIsPermissionByExcelClassifyIdList(classifyIdList []int, excelClassifySou
|
|
|
if num > 0 {
|
|
|
// 将对应的分类设置为涉密
|
|
|
sql = `UPDATE excel_classify SET is_join_permission=?,modify_time=now() WHERE source = ? AND excel_classify_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
- _, err = o.Raw(sql, 1, excelClassifySource, classifyIdList).Exec()
|
|
|
+ err = o.Exec(sql, 1, excelClassifySource, classifyIdList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -92,7 +92,7 @@ func SetPermissionByExcelIdList(excelIdList []string, userIdList []int, source i
|
|
|
if excelNum <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -107,7 +107,7 @@ func SetPermissionByExcelIdList(excelIdList []string, userIdList []int, source i
|
|
|
// 获取已经配置的表格权限用户
|
|
|
excelInfoPermissionList := make([]*ExcelInfoPermission, 0)
|
|
|
sql := `SELECT * FROM excel_info_permission WHERE source = ? AND excel_info_id in (` + utils.GetOrmInReplace(excelNum) + `) `
|
|
|
- _, err = o.Raw(sql, source, excelIdList).QueryRows(&excelInfoPermissionList)
|
|
|
+ err = o.Raw(sql, source, excelIdList).Scan(&excelInfoPermissionList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -126,7 +126,7 @@ func SetPermissionByExcelIdList(excelIdList []string, userIdList []int, source i
|
|
|
isJoinPermission = 0
|
|
|
}
|
|
|
sql = `UPDATE excel_info SET is_join_permission=?,modify_time=now() WHERE source = ? AND excel_info_id in (` + utils.GetOrmInReplace(excelNum) + `) `
|
|
|
- _, err = o.Raw(sql, isJoinPermission, source, excelIdList).Exec()
|
|
|
+ err = global.DmSQL["data"].Exec(sql, isJoinPermission, source, excelIdList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -163,7 +163,7 @@ func SetPermissionByExcelIdList(excelIdList []string, userIdList []int, source i
|
|
|
|
|
|
// 添加待配置项
|
|
|
if len(addList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addList)
|
|
|
+ err = o.CreateInBatches(addList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -180,7 +180,7 @@ func SetPermissionByExcelIdList(excelIdList []string, userIdList []int, source i
|
|
|
deletePermissionIdNum := len(deletePermissionIdList)
|
|
|
if deletePermissionIdNum > 0 {
|
|
|
sql = "DELETE FROM excel_info_permission WHERE excel_info_permission_id in (" + utils.GetOrmInReplace(deletePermissionIdNum) + ")"
|
|
|
- _, err = o.Raw(sql, deletePermissionIdList).Exec()
|
|
|
+ err = o.Exec(sql, deletePermissionIdList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -202,7 +202,7 @@ func SetPermissionByExcelClassifyIdList(classifyIdList []int, userIdList []int,
|
|
|
if userNum <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -217,7 +217,7 @@ func SetPermissionByExcelClassifyIdList(classifyIdList []int, userIdList []int,
|
|
|
// 获取当前选择用户已经配置的表格分类权限
|
|
|
classifyPermissionList := make([]*ExcelClassifyPermission, 0)
|
|
|
sql := `SELECT * FROM excel_classify_permission WHERE source = ? AND sys_user_id in (` + utils.GetOrmInReplace(userNum) + `) `
|
|
|
- _, err = o.Raw(sql, classifyType, userIdList).QueryRows(&classifyPermissionList)
|
|
|
+ err = o.Raw(sql, classifyType, userIdList).Scan(&classifyPermissionList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -252,7 +252,7 @@ func SetPermissionByExcelClassifyIdList(classifyIdList []int, userIdList []int,
|
|
|
|
|
|
// 添加待配置项
|
|
|
if len(addList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addList)
|
|
|
+ err = o.CreateInBatches(addList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -269,7 +269,7 @@ func SetPermissionByExcelClassifyIdList(classifyIdList []int, userIdList []int,
|
|
|
deletePermissionIdNum := len(deletePermissionIdList)
|
|
|
if deletePermissionIdNum > 0 {
|
|
|
sql = "DELETE FROM excel_classify_permission WHERE excel_classify_permission_id in (" + utils.GetOrmInReplace(deletePermissionIdNum) + ")"
|
|
|
- _, err = o.Raw(sql, deletePermissionIdList).Exec()
|
|
|
+ err = o.Exec(sql, deletePermissionIdList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -288,9 +288,8 @@ func SetPermissionByExcelClassifyIdList(classifyIdList []int, userIdList []int,
|
|
|
// @return excelClassifyIdList []int
|
|
|
// @return err error
|
|
|
func GetPermissionExcelClassifyIdListByUserId(userId int, classifyType int) (excelClassifyIdList []int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT excel_classify_id FROM excel_classify_permission WHERE source = ? AND sys_user_id = ? `
|
|
|
- _, err = o.Raw(sql, classifyType, userId).QueryRows(&excelClassifyIdList)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, classifyType, userId).Scan(&excelClassifyIdList).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -304,9 +303,8 @@ func GetPermissionExcelClassifyIdListByUserId(userId int, classifyType int) (exc
|
|
|
// @return userIdList []int
|
|
|
// @return err error
|
|
|
func GetPermissionUserIdListByExcelId(dataId int, source int) (userIdList []int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT sys_user_id FROM excel_info_permission WHERE source = ? AND excel_info_id= ? `
|
|
|
- _, err = o.Raw(sql, source, dataId).QueryRows(&userIdList)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, source, dataId).Scan(&userIdList).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -320,9 +318,8 @@ func GetPermissionUserIdListByExcelId(dataId int, source int) (userIdList []int,
|
|
|
// @return userIdList []int
|
|
|
// @return err error
|
|
|
func GetPermissionUserIdListByExcelClassifyId(classifyId int, source int) (userIdList []int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT sys_user_id FROM excel_classify_permission WHERE source = ? AND excel_classify_id= ? `
|
|
|
- _, err = o.Raw(sql, source, classifyId).QueryRows(&userIdList)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, source, classifyId).Scan(&userIdList).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -337,13 +334,12 @@ func GetPermissionUserIdListByExcelClassifyId(classifyId int, source int) (userI
|
|
|
// @return err error
|
|
|
func GetPermissionExcelIdList(userId, excelInfoId int) (idList []int, err error) {
|
|
|
pars := []interface{}{userId}
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT excel_info_id FROM excel_info_permission WHERE sys_user_id = ? `
|
|
|
if excelInfoId > 0 {
|
|
|
sql += ` AND excel_info_id = ? `
|
|
|
pars = append(pars, excelInfoId)
|
|
|
}
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&idList)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, pars).Scan(&idList).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -358,13 +354,12 @@ func GetPermissionExcelIdList(userId, excelInfoId int) (idList []int, err error)
|
|
|
// @return err error
|
|
|
func GetPermissionExcelClassifyIdList(userId, classifyId int) (idList []int, err error) {
|
|
|
pars := []interface{}{userId}
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT excel_classify_id FROM excel_classify_permission WHERE sys_user_id = ? `
|
|
|
if classifyId > 0 {
|
|
|
sql += ` AND excel_classify_id = ? `
|
|
|
pars = append(pars, classifyId)
|
|
|
}
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&idList)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, pars).Scan(&idList).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -381,10 +376,7 @@ func GetPermissionExcelClassifyIdList(userId, classifyId int) (idList []int, err
|
|
|
// @param uniqueCode string
|
|
|
// @return err error
|
|
|
func InheritParentClassifyByExcelClassifyId(dataSource, excelSource, classifyId, parentClassifyId int, classifyName, uniqueCode string) (err error) {
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
_ = o.Rollback()
|
|
@@ -395,7 +387,7 @@ func InheritParentClassifyByExcelClassifyId(dataSource, excelSource, classifyId,
|
|
|
|
|
|
// 将对应的分类设置为涉密
|
|
|
sql := `UPDATE excel_classify SET is_join_permission=?,modify_time=now() WHERE source = ? AND excel_classify_id = ? `
|
|
|
- _, err = o.Raw(sql, 1, excelSource, classifyId).Exec()
|
|
|
+ err = o.Exec(sql, 1, excelSource, classifyId).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -405,7 +397,7 @@ func InheritParentClassifyByExcelClassifyId(dataSource, excelSource, classifyId,
|
|
|
// 获取父级未授权的用户记录
|
|
|
var parentRecordItems []*ExcelInfoClassifyPermissionNoAuthRecord
|
|
|
sql = `SELECT * FROM data_permission_classify_no_auth_record WHERE classify_id = ? AND source = ? AND sub_source = ? ORDER BY data_permission_classify_no_auth_record_id desc LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, parentClassifyId, dataSource, excelSource).QueryRows(&parentRecordItems)
|
|
|
+ err = o.Raw(sql, parentClassifyId, dataSource, excelSource).Scan(&parentRecordItems).Error
|
|
|
|
|
|
addNoAuthRecordItems := make([]*ExcelInfoClassifyPermissionNoAuthRecord, 0)
|
|
|
for _, v := range parentRecordItems {
|
|
@@ -422,7 +414,7 @@ func InheritParentClassifyByExcelClassifyId(dataSource, excelSource, classifyId,
|
|
|
|
|
|
// 添加待配置项
|
|
|
if len(addNoAuthRecordItems) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addNoAuthRecordItems)
|
|
|
+ err = o.CreateInBatches(addNoAuthRecordItems, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -435,7 +427,7 @@ func InheritParentClassifyByExcelClassifyId(dataSource, excelSource, classifyId,
|
|
|
// 获取父级分类已经授权的用户
|
|
|
parentClassifyPermissionList := make([]*ExcelClassifyPermission, 0)
|
|
|
sql = `SELECT * FROM excel_classify_permission WHERE source = ? AND excel_classify_id = ? `
|
|
|
- _, err = o.Raw(sql, excelSource, parentClassifyId).QueryRows(&parentClassifyPermissionList)
|
|
|
+ err = o.Raw(sql, excelSource, parentClassifyId).Scan(&parentClassifyPermissionList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -454,7 +446,7 @@ func InheritParentClassifyByExcelClassifyId(dataSource, excelSource, classifyId,
|
|
|
}
|
|
|
// 添加待配置项
|
|
|
if len(addList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addList)
|
|
|
+ err = o.CreateInBatches(addList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -502,7 +494,7 @@ func AddExcelInfoPermissionNoAuthRecordBySourceAndDataIdList(source, excelSource
|
|
|
if userNum <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -517,7 +509,7 @@ func AddExcelInfoPermissionNoAuthRecordBySourceAndDataIdList(source, excelSource
|
|
|
// 根据指标获取已经存在的未授权记录
|
|
|
var existList []*ExcelInfoPermissionNoAuthRecord
|
|
|
sql := `SELECT * FROM excel_info_permission_no_auth_record WHERE source = ? AND excel_info_id in (` + utils.GetOrmInReplace(num) + `)`
|
|
|
- _, err = o.Raw(sql, excelSource, dataIdList).QueryRows(&existList)
|
|
|
+ err = o.Raw(sql, excelSource, dataIdList).Scan(&existList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -585,7 +577,7 @@ func AddExcelInfoPermissionNoAuthRecordBySourceAndDataIdList(source, excelSource
|
|
|
|
|
|
// 添加消息
|
|
|
if len(addMessageList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addMessageList)
|
|
|
+ err = o.CreateInBatches(addMessageList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -593,7 +585,7 @@ func AddExcelInfoPermissionNoAuthRecordBySourceAndDataIdList(source, excelSource
|
|
|
|
|
|
// 添加记录
|
|
|
if len(addRecordList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addRecordList)
|
|
|
+ err = o.CreateInBatches(addRecordList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -603,7 +595,7 @@ func AddExcelInfoPermissionNoAuthRecordBySourceAndDataIdList(source, excelSource
|
|
|
authUserIdNum := len(authUserIdList)
|
|
|
if authUserIdNum > 0 {
|
|
|
sql = `DELETE FROM excel_info_permission_no_auth_record WHERE source = ? AND sys_user_id in (` + utils.GetOrmInReplace(authUserIdNum) + `) AND excel_info_id in (` + utils.GetOrmInReplace(num) + `)`
|
|
|
- _, err = o.Raw(sql, excelSource, authUserIdList, dataIdList).Exec()
|
|
|
+ err = o.Exec(sql, excelSource, authUserIdList, dataIdList).Error
|
|
|
}
|
|
|
|
|
|
return
|
|
@@ -621,26 +613,23 @@ func DeleteExcelInfoPermissionNoAuthRecordBySourceAndDataIdList(excelSource int,
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
sql := `DELETE FROM excel_info_permission_no_auth_record WHERE source = ? AND excel_info_id in (` + utils.GetOrmInReplace(num) + `)`
|
|
|
- _, err = o.Raw(sql, excelSource, dataIdList).Exec()
|
|
|
+ err = global.DmSQL["data"].Exec(sql, excelSource, dataIdList).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetExcelInfoDataPermissionNoAuthRecordListByUserId(userId, excelSource int32, startSize, pageSize int) (total int, items []*DataPermissionNoAuthRecord, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
-
|
|
|
// 获取总数
|
|
|
sql := `SELECT count(1) AS total FROM excel_info_permission_no_auth_record WHERE sys_user_id = ? AND source = ? `
|
|
|
- err = o.Raw(sql, userId, excelSource).QueryRow(&total)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, userId, excelSource).Scan(&total).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
sql = `SELECT excel_info_permission_no_auth_record_id as data_permission_no_auth_record_id,op_unique_code,source as sub_source,excel_info_id as data_id,excel_name as data_name,sys_user_id,create_time FROM excel_info_permission_no_auth_record WHERE sys_user_id = ? AND source = ? ORDER BY excel_info_permission_no_auth_record_id desc LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, userId, excelSource, startSize, pageSize).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, userId, excelSource, startSize, pageSize).Scan(&items).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -682,10 +671,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(source, excelSour
|
|
|
if userNum <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
_ = o.Rollback()
|
|
@@ -697,7 +683,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(source, excelSour
|
|
|
// 根据分类获取已经存在的未授权记录
|
|
|
var existList []*ExcelInfoClassifyPermissionNoAuthRecord
|
|
|
sql := `SELECT * FROM excel_info_classify_permission_no_auth_record WHERE source = ? AND classify_id in (` + utils.GetOrmInReplace(num) + `)`
|
|
|
- _, err = o.Raw(sql, excelSource, classifyIdList).QueryRows(&existList)
|
|
|
+ err = o.Raw(sql, excelSource, classifyIdList).Scan(&existList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -765,7 +751,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(source, excelSour
|
|
|
|
|
|
// 添加消息
|
|
|
if len(addMessageList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addMessageList)
|
|
|
+ err = o.CreateInBatches(addMessageList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -773,7 +759,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(source, excelSour
|
|
|
|
|
|
// 添加记录
|
|
|
if len(addRecordList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addRecordList)
|
|
|
+ err = o.CreateInBatches(addRecordList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -783,7 +769,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(source, excelSour
|
|
|
authUserIdNum := len(classifyIdList)
|
|
|
if authUserIdNum > 0 {
|
|
|
sql = `DELETE FROM excel_info_classify_permission_no_auth_record WHERE source = ? AND classify_id not in (` + utils.GetOrmInReplace(num) + `)`
|
|
|
- _, err = o.Raw(sql, excelSource, classifyIdList).Exec()
|
|
|
+ err = o.Exec(sql, excelSource, classifyIdList).Error
|
|
|
}
|
|
|
|
|
|
return
|
|
@@ -814,10 +800,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndUserIdList(source, excelSource i
|
|
|
// return
|
|
|
//}
|
|
|
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
+ o := global.DmSQL["data"].Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
_ = o.Rollback()
|
|
@@ -829,7 +812,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndUserIdList(source, excelSource i
|
|
|
// 根据当前配置用户获取已经存在的未授权记录
|
|
|
var existList []*ExcelInfoClassifyPermissionNoAuthRecord
|
|
|
sql := `SELECT * FROM excel_info_classify_permission_no_auth_record WHERE source = ? AND sys_user_id in (` + utils.GetOrmInReplace(configUserNum) + `)`
|
|
|
- _, err = o.Raw(sql, excelSource, configUserIdList).QueryRows(&existList)
|
|
|
+ err = o.Raw(sql, excelSource, configUserIdList).Scan(&existList).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -901,7 +884,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndUserIdList(source, excelSource i
|
|
|
|
|
|
// 添加消息
|
|
|
if len(addMessageList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addMessageList)
|
|
|
+ err = o.CreateInBatches(addMessageList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -909,7 +892,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndUserIdList(source, excelSource i
|
|
|
|
|
|
// 添加记录
|
|
|
if len(addRecordList) > 0 {
|
|
|
- _, err = o.InsertMulti(500, addRecordList)
|
|
|
+ err = o.CreateInBatches(addRecordList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -923,7 +906,7 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndUserIdList(source, excelSource i
|
|
|
delRecordIdList = append(delRecordIdList, v)
|
|
|
}
|
|
|
sql = `DELETE FROM excel_info_classify_permission_no_auth_record WHERE excel_info_classify_permission_no_auth_record_id in (` + utils.GetOrmInReplace(delRecordIdNum) + `) `
|
|
|
- _, err = o.Raw(sql, delRecordIdList).Exec()
|
|
|
+ err = o.Exec(sql, delRecordIdList).Error
|
|
|
}
|
|
|
|
|
|
return
|
|
@@ -937,10 +920,8 @@ func AddExcelInfoClassifyNoAuthRecordBySourceAndUserIdList(source, excelSource i
|
|
|
// @param excelSource int
|
|
|
// @return err error
|
|
|
func DeleteExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(excelSource int) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
-
|
|
|
sql := `DELETE FROM excel_info_classify_permission_no_auth_record WHERE source = ?`
|
|
|
- _, err = o.Raw(sql, excelSource).Exec()
|
|
|
+ err = global.DmSQL["data"].Exec(sql, excelSource).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -958,17 +939,15 @@ func DeleteExcelInfoClassifyNoAuthRecordBySourceAndClassifyIdList(excelSource in
|
|
|
// @return items []*DataPermissionClassifyNoAuthRecord
|
|
|
// @return err error
|
|
|
func GetExcelInfoDataPermissionClassifyNoAuthRecordListByUserId(userId, excelSource int32, startSize, pageSize int) (total int, items []*DataPermissionClassifyNoAuthRecord, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
-
|
|
|
// 获取总数
|
|
|
sql := `SELECT count(1) AS total FROM excel_info_classify_permission_no_auth_record WHERE sys_user_id = ? AND source = ? `
|
|
|
- err = o.Raw(sql, userId, excelSource).QueryRow(&total)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, userId, excelSource).Scan(&total).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
sql = `SELECT excel_info_classify_permission_no_auth_record_id as data_permission_classify_no_auth_record_id,source as sub_source,op_unique_code,classify_id,classify_name,sys_user_id,create_time FROM excel_info_classify_permission_no_auth_record WHERE sys_user_id = ? AND source = ? ORDER BY excel_info_classify_permission_no_auth_record_id desc LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, userId, excelSource, startSize, pageSize).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, userId, excelSource, startSize, pageSize).Scan(&items).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -983,7 +962,6 @@ type ExcelInfoPermissionAdminAuth struct {
|
|
|
|
|
|
// GetAdminAuthExcelInfoPermission 获取用户有权限的表格
|
|
|
func GetAdminAuthExcelInfoPermission(source, adminId int, keywords string) (items []*ExcelInfoPermissionAdminAuth, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT a.*, b.sys_user_id AS create_user_id, b.excel_name, b.unique_code FROM excel_info_permission AS a
|
|
|
JOIN excel_info AS b ON a.excel_info_id = b.excel_info_id
|
|
|
WHERE a.source = ? AND (b.sys_user_id = ? OR a.sys_user_id = ?)`
|
|
@@ -994,7 +972,8 @@ func GetAdminAuthExcelInfoPermission(source, adminId int, keywords string) (item
|
|
|
pars = append(pars, keywords)
|
|
|
}
|
|
|
sql += ` ORDER BY a.create_time ASC`
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, pars).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1002,11 +981,7 @@ func ClearAndSetExcelInfoPermission(source, excelInfoId int, permissions []*Exce
|
|
|
if excelInfoId <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- tx, e := orm.NewOrmUsingDB("data").Begin()
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("orm begin err: %v", e)
|
|
|
- return
|
|
|
- }
|
|
|
+ tx := global.DmSQL["data"].Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
_ = tx.Rollback()
|
|
@@ -1016,15 +991,15 @@ func ClearAndSetExcelInfoPermission(source, excelInfoId int, permissions []*Exce
|
|
|
}()
|
|
|
|
|
|
sql := `DELETE FROM excel_info_permission WHERE excel_info_id = ? AND source = ?`
|
|
|
- _, e = tx.Raw(sql, excelInfoId, source).Exec()
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("clear permission err: %v", e)
|
|
|
+ err = tx.Exec(sql, excelInfoId, source).Error
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("clear permission err: %v", err)
|
|
|
return
|
|
|
}
|
|
|
if len(permissions) > 0 {
|
|
|
- _, e = tx.InsertMulti(500, permissions)
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("insert permissions err: %v", e)
|
|
|
+ err = tx.CreateInBatches(permissions, utils.MultiAddNum).Error
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("insert permissions err: %v", err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -1032,15 +1007,15 @@ func ClearAndSetExcelInfoPermission(source, excelInfoId int, permissions []*Exce
|
|
|
}
|
|
|
|
|
|
func GetExcelPermissionBySourceAndId(excelId, source int) (items []*ExcelInfoPermission, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT * FROM excel_info_permission WHERE source = ? AND excel_info_id = ?`
|
|
|
- _, err = o.Raw(sql, source, excelId).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, source, excelId).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetExcelPermissionByExcelIdAndUserId(excelId, userId int) (items []*ExcelInfoPermission, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT * FROM excel_info_permission WHERE excel_info_id = ? AND sys_user_id = ?`
|
|
|
- _, err = o.Raw(sql, excelId, userId).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, excelId, userId).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
-}
|
|
|
+}
|