2022-02-25 17:11:17 +08:00
|
|
|
// =================================================================================
|
|
|
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|
|
|
// =================================================================================
|
|
|
|
|
|
|
|
package dao
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
2022-11-24 23:37:34 +08:00
|
|
|
"hotgo/internal/consts"
|
|
|
|
"hotgo/internal/dao/internal"
|
|
|
|
"hotgo/internal/model/entity"
|
2022-02-25 17:11:17 +08:00
|
|
|
)
|
|
|
|
|
2022-11-24 23:37:34 +08:00
|
|
|
// internalAdminDeptDao is internal type for wrapping internal DAO implements.
|
|
|
|
type internalAdminDeptDao = *internal.AdminDeptDao
|
|
|
|
|
2022-02-25 17:11:17 +08:00
|
|
|
// adminDeptDao is the data access object for table hg_admin_dept.
|
|
|
|
// You can define custom methods on it to extend its functionality as you wish.
|
|
|
|
type adminDeptDao struct {
|
2022-11-24 23:37:34 +08:00
|
|
|
internalAdminDeptDao
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2022-11-24 23:37:34 +08:00
|
|
|
// AdminDept is globally common accessible object for table hg_admin_dept operations.
|
2022-02-25 17:11:17 +08:00
|
|
|
AdminDept = adminDeptDao{
|
|
|
|
internal.NewAdminDeptDao(),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-11-24 23:37:34 +08:00
|
|
|
// IsUniqueName 判断名称是否唯一
|
2022-02-25 17:11:17 +08:00
|
|
|
func (dao *adminDeptDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
|
|
|
var data *entity.AdminDept
|
|
|
|
m := dao.Ctx(ctx).Where("name", name)
|
|
|
|
|
|
|
|
if id > 0 {
|
|
|
|
m = m.WhereNot("id", id)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.Scan(&data); err != nil {
|
|
|
|
err = gerror.Wrap(err, consts.ErrorORM)
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if data == nil {
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, nil
|
|
|
|
}
|