feat: 新增账号编码和HTTP连接功能
This commit is contained in:
60
dao/account_user_dialog_dao.go
Normal file
60
dao/account_user_dialog_dao.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"customer-server/consts/public"
|
||||
"customer-server/model/dto"
|
||||
"customer-server/model/entity"
|
||||
|
||||
"gitea.com/red-future/common/db/gfdb"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var AccountUserDialog = new(accountUserDialog)
|
||||
|
||||
type accountUserDialog struct{}
|
||||
|
||||
func (d *accountUserDialog) Insert(ctx context.Context, req *dto.AddAccountUserDialogReq) (id int64, err error) {
|
||||
var e *entity.AccountUserDialog
|
||||
if err = gconv.Struct(req, &e); err != nil {
|
||||
return
|
||||
}
|
||||
result, err := gfdb.DB(ctx).Model(ctx, public.TableNameAccountUserDialog).Insert(e)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return result.LastInsertId()
|
||||
}
|
||||
|
||||
func (d *accountUserDialog) Update(ctx context.Context, req *dto.UpdateAccountUserDialogReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAccountUserDialog).Data(&req).Where(entity.AccountUserDialogCol.Id, req.Id).OmitEmpty().
|
||||
Data(entity.AccountUserDialogCol.DialogCount, &gdb.Counter{
|
||||
Field: entity.AccountUserDialogCol.DialogCount,
|
||||
Value: gconv.Float64(req.DialogCount),
|
||||
}).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return r.RowsAffected()
|
||||
}
|
||||
|
||||
func (d *accountUserDialog) Delete(ctx context.Context, req *dto.DeleteAccountUserDialogReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAccountUserDialog).Where(entity.AccountUserDialogCol.Id, req.Id).Delete()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return r.RowsAffected()
|
||||
}
|
||||
|
||||
func (d *accountUserDialog) Get(ctx context.Context, req *dto.GetAccountUserDialogReq) (res *entity.AccountUserDialog, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAccountUserDialog).OmitEmpty().
|
||||
Where(entity.AccountUserDialogCol.UserId, req.UserId).
|
||||
Where(entity.AccountUserDialogCol.AccountId, req.AccountId).
|
||||
One()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = gconv.Struct(r, &res)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user