修复需要从前端传新增人修改人的问题
This commit is contained in:
@@ -18,15 +18,16 @@ var DatasourcePlatform = new(datasourcePlatformDao)
|
||||
type datasourcePlatformDao struct{}
|
||||
|
||||
// Insert 插入数据源平台
|
||||
func (d *datasourcePlatformDao) Insert(ctx context.Context, req *dto.CreateDatasourcePlatformReq) (ID int64, err error) {
|
||||
func (d *datasourcePlatformDao) Insert(ctx context.Context, req *dto.CreateDatasourcePlatformReq, createdBy string) (ID int64, err error) {
|
||||
var res *entity.DatasourcePlatform
|
||||
if err = gconv.Struct(req, &res); err != nil {
|
||||
return
|
||||
}
|
||||
// 设置创建时间
|
||||
// 设置创建时间和更新时间
|
||||
// 设置创建人和时间(服务端生成,不依赖前端入参)
|
||||
now := time.Now()
|
||||
res.CreatedBy = createdBy
|
||||
res.CreatedAt = &now
|
||||
res.UpdatedBy = createdBy
|
||||
res.UpdatedAt = &now
|
||||
|
||||
r, err := gfdb.DB(ctx).Model(ctx, consts.DatasourcePlatformTable).Data(&res).Insert()
|
||||
@@ -37,9 +38,10 @@ func (d *datasourcePlatformDao) Insert(ctx context.Context, req *dto.CreateDatas
|
||||
}
|
||||
|
||||
// Update 更新数据源平台
|
||||
func (d *datasourcePlatformDao) Update(ctx context.Context, req *dto.UpdateDatasourcePlatformReq) (rows int64, err error) {
|
||||
// 设置更新时间
|
||||
func (d *datasourcePlatformDao) Update(ctx context.Context, req *dto.UpdateDatasourcePlatformReq, updatedBy string) (rows int64, err error) {
|
||||
// 设置更新人和更新时间(服务端生成,不依赖前端入参)
|
||||
data := gconv.Map(req)
|
||||
data[entity.DatasourcePlatformCols.UpdatedBy] = updatedBy
|
||||
data[entity.DatasourcePlatformCols.UpdatedAt] = time.Now()
|
||||
|
||||
r, err := gfdb.DB(ctx).Model(ctx, consts.DatasourcePlatformTable).
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"gitea.redpowerfuture.com/red-future/common/db/gfdb"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
@@ -17,11 +18,18 @@ var ApiInterface = new(apiInterfaceDao)
|
||||
type apiInterfaceDao struct{}
|
||||
|
||||
// Insert 插入接口
|
||||
func (d *apiInterfaceDao) Insert(ctx context.Context, req *dto.CreateApiInterfaceReq) (id int64, err error) {
|
||||
func (d *apiInterfaceDao) Insert(ctx context.Context, req *dto.CreateApiInterfaceReq, creator string) (id int64, err error) {
|
||||
var res *entity.ApiInterface
|
||||
if err = gconv.Struct(req, &res); err != nil {
|
||||
return
|
||||
}
|
||||
// 设置创建人和时间(服务端生成,不依赖前端入参)
|
||||
now := gtime.Now()
|
||||
res.Creator = creator
|
||||
res.CreatedAt = now
|
||||
res.Updater = creator
|
||||
res.UpdatedAt = now
|
||||
|
||||
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).Data(&res).Insert()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -30,8 +38,17 @@ func (d *apiInterfaceDao) Insert(ctx context.Context, req *dto.CreateApiInterfac
|
||||
}
|
||||
|
||||
// Update 更新接口
|
||||
func (d *apiInterfaceDao) Update(ctx context.Context, req *dto.UpdateApiInterfaceReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).Data(&req).OmitEmpty().Where(entity.ApiInterfaceCols.Id, req.Id).Update()
|
||||
func (d *apiInterfaceDao) Update(ctx context.Context, req *dto.UpdateApiInterfaceReq, updater string) (rows int64, err error) {
|
||||
// 设置更新人和更新时间(服务端生成,不依赖前端入参)
|
||||
data := gconv.Map(req)
|
||||
data[entity.ApiInterfaceCols.Updater] = updater
|
||||
data[entity.ApiInterfaceCols.UpdatedAt] = gtime.Now()
|
||||
|
||||
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).
|
||||
Data(data).
|
||||
OmitEmpty().
|
||||
Where(entity.ApiInterfaceCols.Id, req.Id).
|
||||
Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -96,9 +113,13 @@ func (d *apiInterfaceDao) buildListFilter(ctx context.Context, req *dto.ListApiI
|
||||
}
|
||||
|
||||
// UpdateStatus 更新接口状态
|
||||
func (d *apiInterfaceDao) UpdateStatus(ctx context.Context, id int64, status string) (rows int64, err error) {
|
||||
func (d *apiInterfaceDao) UpdateStatus(ctx context.Context, id int64, status string, updater string) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).
|
||||
Data(map[string]interface{}{"status": status}).
|
||||
Data(map[string]interface{}{
|
||||
entity.ApiInterfaceCols.Status: status,
|
||||
entity.ApiInterfaceCols.Updater: updater,
|
||||
entity.ApiInterfaceCols.UpdatedAt: gtime.Now(),
|
||||
}).
|
||||
Where(entity.ApiInterfaceCols.Id, id).
|
||||
Update()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user