优化全局变量

This commit is contained in:
2023-01-18 17:10:16 +08:00
parent 6dbdeb7145
commit c44203b176
25 changed files with 428 additions and 429 deletions
+8 -8
View File
@@ -1,19 +1,19 @@
package dao
import (
"cutego/modules"
"cutego/modules/core/dataobject"
"cutego/modules/core/entity"
"cutego/pkg/common"
"cutego/refs"
)
type UserPostDao struct {
}
// BatchInsert 批量新增用户岗位信息
func (d UserPostDao) BatchInsert(posts []dataobject.SysUserPost) {
session := modules.SqlDB.NewSession()
func (d UserPostDao) BatchInsert(posts []entity.SysUserPost) {
session := refs.SqlDB.NewSession()
session.Begin()
_, err := session.Table(dataobject.SysUserPost{}.TableName()).Insert(&posts)
_, err := session.Table(entity.SysUserPost{}.TableName()).Insert(&posts)
if err != nil {
common.ErrorLog(err)
session.Rollback()
@@ -24,10 +24,10 @@ func (d UserPostDao) BatchInsert(posts []dataobject.SysUserPost) {
// Delete 删除用户和岗位关系
func (d UserPostDao) Delete(id int64) {
post := dataobject.SysUserPost{
post := entity.SysUserPost{
UserId: id,
}
session := modules.SqlDB.NewSession()
session := refs.SqlDB.NewSession()
session.Begin()
_, err := session.Delete(&post)
if err != nil {
@@ -39,7 +39,7 @@ func (d UserPostDao) Delete(id int64) {
// CountById 通过岗位ID查询岗位使用数量
func (d UserPostDao) CountById(id int64) int64 {
count, err := modules.SqlDB.NewSession().Table("sys_user_post").Cols("post_id").Where("post_id = ?", id).Count()
count, err := refs.SqlDB.NewSession().Table("sys_user_post").Cols("post_id").Where("post_id = ?", id).Count()
if err != nil {
common.ErrorLog(err)
return 0