hotgo/hotgo-server/app/service/internal/dao/sys_dict_data.go
2022-02-25 17:11:17 +08:00

63 lines
1.5 KiB
Go
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"context"
"github.com/bufanyun/hotgo/app/consts"
"github.com/bufanyun/hotgo/app/model/entity"
"github.com/bufanyun/hotgo/app/service/internal/dao/internal"
"github.com/gogf/gf/v2/errors/gerror"
)
// sysDictDataDao is the data access object for table hg_sys_dict_data.
// You can define custom methods on it to extend its functionality as you wish.
type sysDictDataDao struct {
*internal.SysDictDataDao
}
var (
// SysDictData is globally public accessible object for table hg_sys_dict_data operations.
SysDictData = sysDictDataDao{
internal.NewSysDictDataDao(),
}
)
//
//  @Title  判断字典类型是否唯一
//  @Description
//  @Author  Ms <133814250@qq.com>
//  @Param   ctx
//  @Param   id
//  @Param   dictType
//  @Return  bool
//  @Return  error
//
func (dao *sysDictDataDao) IsUnique(ctx context.Context, id int64, dictType string, dictValue string) (bool, error) {
var (
data *entity.SysDictData
err error
)
m := dao.Ctx(ctx).Where("type", dictType).Where("value", dictValue)
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
}
// Fill with you ideas below.