hotgo/server/internal/dao/admin_menu.go

72 lines
1.7 KiB
Go
Raw Normal View History

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
// internalAdminMenuDao is internal type for wrapping internal DAO implements.
type internalAdminMenuDao = *internal.AdminMenuDao
// adminMenuDao is the data access object for table hg_admin_menu.
// You can define custom methods on it to extend its functionality as you wish.
2022-02-25 17:11:17 +08:00
type adminMenuDao struct {
2022-11-24 23:37:34 +08:00
internalAdminMenuDao
2022-02-25 17:11:17 +08:00
}
var (
2022-11-24 23:37:34 +08:00
// AdminMenu is globally common accessible object for table hg_admin_menu operations.
2022-02-25 17:11:17 +08:00
AdminMenu = adminMenuDao{
internal.NewAdminMenuDao(),
}
)
2022-11-24 23:37:34 +08:00
// IsUniqueTitle 判断标题是否唯一
func (dao *adminMenuDao) IsUniqueTitle(ctx context.Context, id int64, title string) (bool, error) {
2022-02-25 17:11:17 +08:00
var data *entity.AdminMenu
2022-11-24 23:37:34 +08:00
m := dao.Ctx(ctx).Where("title", title)
2022-02-25 17:11:17 +08:00
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
}
2022-11-24 23:37:34 +08:00
// IsUniqueName 判断编码是否唯一
func (dao *adminMenuDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
2022-02-25 17:11:17 +08:00
var data *entity.AdminMenu
2022-11-24 23:37:34 +08:00
m := dao.Ctx(ctx).Where("name", name)
2022-02-25 17:11:17 +08:00
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
}