mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
优化hgorm.dao方法
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/library/hgorm/handler"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/adminin"
|
||||
@@ -218,12 +217,7 @@ func (s *sAdminCreditsLog) List(ctx context.Context, in adminin.CreditsLogListIn
|
||||
return
|
||||
}
|
||||
|
||||
fields, err := hgorm.GenSelect(ctx, adminin.CreditsLogListModel{}, dao.AdminCreditsLog)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = mod.Fields(fields).Page(in.Page, in.PerPage).OrderDesc(dao.AdminCreditsLog.Columns().Id).Scan(&list)
|
||||
err = mod.Fields(adminin.CreditsLogListModel{}).Page(in.Page, in.PerPage).OrderDesc(dao.AdminCreditsLog.Columns().Id).Scan(&list)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -58,11 +58,11 @@ func (s *sAdminDept) Delete(ctx context.Context, in adminin.DeptDeleteInp) (err
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err error) {
|
||||
if err = hgorm.IsUnique(ctx, dao.AdminDept, g.Map{dao.AdminDept.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
if err = hgorm.IsUnique(ctx, &dao.AdminDept, g.Map{dao.AdminDept.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.AdminDept, in.Pid); err != nil {
|
||||
if in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, &dao.AdminDept, in.Pid); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -380,7 +380,7 @@ func (s *sAdminMember) VerifyUnique(ctx context.Context, in adminin.VerifyUnique
|
||||
err = gerror.Newf("字段 [ %v ] 未配置唯一属性验证", k)
|
||||
return
|
||||
}
|
||||
if err = hgorm.IsUnique(ctx, dao.AdminMember, g.Map{k: v}, message, in.Id); err != nil {
|
||||
if err = hgorm.IsUnique(ctx, &dao.AdminMember, g.Map{k: v}, message, in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -599,7 +599,6 @@ func (s *sAdminMember) List(ctx context.Context, in adminin.MemberListInp) (list
|
||||
list[i].PostIds = append(list[i].PostIds, v.Int64())
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -294,8 +294,8 @@ func (s *sAdminOrder) List(ctx context.Context, in adminin.OrderListInp) (list [
|
||||
}
|
||||
|
||||
//关联表select
|
||||
fields, err := hgorm.GenJoinSelect(ctx, adminin.OrderListModel{}, dao.AdminOrder, []*hgorm.Join{
|
||||
{Dao: dao.PayLog, Alias: "payLog"},
|
||||
fields, err := hgorm.GenJoinSelect(ctx, adminin.OrderListModel{}, &dao.AdminOrder, []*hgorm.Join{
|
||||
{Dao: &dao.PayLog, Alias: "payLog"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
@@ -171,15 +171,15 @@ func (s *sAdminRole) UpdatePermissions(ctx context.Context, in adminin.UpdatePer
|
||||
}
|
||||
|
||||
func (s *sAdminRole) Edit(ctx context.Context, in adminin.RoleEditInp) (err error) {
|
||||
if err = hgorm.IsUnique(ctx, dao.AdminRole, g.Map{dao.AdminRole.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
if err = hgorm.IsUnique(ctx, &dao.AdminRole, g.Map{dao.AdminRole.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = hgorm.IsUnique(ctx, dao.AdminRole, g.Map{dao.AdminRole.Columns().Key: in.Key}, "编码已存在", in.Id); err != nil {
|
||||
if err = hgorm.IsUnique(ctx, &dao.AdminRole, g.Map{dao.AdminRole.Columns().Key: in.Key}, "编码已存在", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.AdminRole, in.Pid); err != nil {
|
||||
if in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, &dao.AdminRole, in.Pid); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/library/hgorm/handler"
|
||||
"hotgo/internal/library/location"
|
||||
"hotgo/internal/library/payment"
|
||||
@@ -188,12 +187,7 @@ func (s *sPayRefund) List(ctx context.Context, in payin.PayRefundListInp) (list
|
||||
return
|
||||
}
|
||||
|
||||
fields, err := hgorm.GenSelect(ctx, payin.PayRefundListModel{}, dao.PayRefund)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = mod.Fields(fields).Page(in.Page, in.PerPage).OrderDesc(dao.PayRefund.Columns().Id).Scan(&list)
|
||||
err = mod.Fields(payin.PayRefundListModel{}).Page(in.Page, in.PerPage).OrderDesc(dao.PayRefund.Columns().Id).Scan(&list)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -83,8 +83,8 @@ func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list
|
||||
}
|
||||
|
||||
//关联表select
|
||||
fields, err := hgorm.GenJoinSelect(ctx, sysin.CurdDemoListModel{}, dao.SysGenCurdDemo, []*hgorm.Join{
|
||||
{Dao: dao.TestCategory, Alias: "testCategory"},
|
||||
fields, err := hgorm.GenJoinSelect(ctx, sysin.CurdDemoListModel{}, &dao.SysGenCurdDemo, []*hgorm.Join{
|
||||
{Dao: &dao.TestCategory, Alias: "testCategory"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
@@ -82,7 +82,7 @@ func (s *sSysDictType) Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysDictType) Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error) {
|
||||
if err = hgorm.IsUnique(ctx, dao.SysDictType, g.Map{dao.SysDictType.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
if err = hgorm.IsUnique(ctx, &dao.SysDictType, g.Map{dao.SysDictType.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -84,8 +84,8 @@ func (s *sSysLoginLog) List(ctx context.Context, in sysin.LoginLogListInp) (list
|
||||
}
|
||||
|
||||
//关联表select
|
||||
fields, err := hgorm.GenJoinSelect(ctx, sysin.LoginLogListModel{}, dao.SysLoginLog, []*hgorm.Join{
|
||||
{Dao: dao.SysLog, Alias: "sysLog"},
|
||||
fields, err := hgorm.GenJoinSelect(ctx, sysin.LoginLogListModel{}, &dao.SysLoginLog, []*hgorm.Join{
|
||||
{Dao: &dao.SysLog, Alias: "sysLog"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
@@ -79,7 +79,7 @@ func (s *sSysProvinces) Delete(ctx context.Context, in sysin.ProvincesDeleteInp)
|
||||
// Edit 修改/新增省市区数据
|
||||
func (s *sSysProvinces) Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error) {
|
||||
// 关系树
|
||||
in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.SysProvinces, in.Pid)
|
||||
in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, &dao.SysProvinces, in.Pid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -202,7 +202,7 @@ func (s *sSysProvinces) UniqueId(ctx context.Context, in sysin.ProvincesUniqueId
|
||||
return
|
||||
}
|
||||
|
||||
if err = hgorm.IsUnique(ctx, dao.SysProvinces, g.Map{dao.SysProvinces.Columns().Id: in.NewId}, "", in.OldId); err != nil {
|
||||
if err = hgorm.IsUnique(ctx, &dao.SysProvinces, g.Map{dao.SysProvinces.Columns().Id: in.NewId}, "", in.OldId); err != nil {
|
||||
res.IsUnique = false
|
||||
return
|
||||
}
|
||||
|
@@ -73,8 +73,8 @@ func (s *sSysServeLog) List(ctx context.Context, in sysin.ServeLogListInp) (list
|
||||
}
|
||||
|
||||
//关联表select
|
||||
fields, err := hgorm.GenJoinSelect(ctx, sysin.ServeLogListModel{}, dao.SysServeLog, []*hgorm.Join{
|
||||
{Dao: dao.SysLog, Alias: "sysLog"},
|
||||
fields, err := hgorm.GenJoinSelect(ctx, sysin.ServeLogListModel{}, &dao.SysServeLog, []*hgorm.Join{
|
||||
{Dao: &dao.SysLog, Alias: "sysLog"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user