mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-23 19:00:24 +08:00
72 lines
1.7 KiB
Go
72 lines
1.7 KiB
Go
// =================================================================================
|
|
// 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"
|
|
"hotgo/internal/consts"
|
|
"hotgo/internal/dao/internal"
|
|
"hotgo/internal/model/entity"
|
|
)
|
|
|
|
// internalAdminRoleDao is internal type for wrapping internal DAO implements.
|
|
type internalAdminRoleDao = *internal.AdminRoleDao
|
|
|
|
// adminRoleDao is the data access object for table hg_admin_role.
|
|
// You can define custom methods on it to extend its functionality as you wish.
|
|
type adminRoleDao struct {
|
|
internalAdminRoleDao
|
|
}
|
|
|
|
var (
|
|
// AdminRole is globally common accessible object for table hg_admin_role operations.
|
|
AdminRole = adminRoleDao{
|
|
internal.NewAdminRoleDao(),
|
|
}
|
|
)
|
|
|
|
// IsUniqueName 判断名称是否唯一
|
|
func (dao *adminRoleDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
|
|
var data *entity.AdminRole
|
|
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
|
|
}
|
|
|
|
// IsUniqueCode 判断编码是否唯一
|
|
func (dao *adminRoleDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) {
|
|
var data *entity.AdminRole
|
|
m := dao.Ctx(ctx).Where("key", code)
|
|
|
|
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
|
|
}
|