优化
This commit is contained in:
@@ -23,7 +23,7 @@ type parameterPO struct {
|
||||
|
||||
func (parameterPO) TableName() string { return "sys_params" }
|
||||
|
||||
func (r *settingsRepo) CreateParameter(ctx context.Context, v *biz.SystemParameter) error {
|
||||
func (r *parameterRepo) CreateParameter(ctx context.Context, v *biz.SystemParameter) error {
|
||||
po := parameterPO{Name: v.Name, Key: v.Key, Value: v.Value, Desc: v.Desc}
|
||||
if err := r.data.gormDB.WithContext(ctx).Create(&po).Error; err != nil {
|
||||
return err
|
||||
@@ -31,13 +31,13 @@ func (r *settingsRepo) CreateParameter(ctx context.Context, v *biz.SystemParamet
|
||||
v.ID = po.ID
|
||||
return nil
|
||||
}
|
||||
func (r *settingsRepo) UpdateParameter(ctx context.Context, v *biz.SystemParameter) error {
|
||||
func (r *parameterRepo) UpdateParameter(ctx context.Context, v *biz.SystemParameter) error {
|
||||
return r.data.gormDB.WithContext(ctx).Model(¶meterPO{}).Where("id = ?", v.ID).Updates(map[string]any{"name": v.Name, "key": v.Key, "value": v.Value, "desc": v.Desc}).Error
|
||||
}
|
||||
func (r *settingsRepo) DeleteParameters(ctx context.Context, ids []uint) error {
|
||||
func (r *parameterRepo) DeleteParameters(ctx context.Context, ids []uint) error {
|
||||
return r.data.gormDB.WithContext(ctx).Delete(¶meterPO{}, ids).Error
|
||||
}
|
||||
func (r *settingsRepo) FindParameter(ctx context.Context, id uint, key string) (*biz.SystemParameter, error) {
|
||||
func (r *parameterRepo) FindParameter(ctx context.Context, id uint, key string) (*biz.SystemParameter, error) {
|
||||
var po parameterPO
|
||||
db := r.data.gormDB.WithContext(ctx)
|
||||
var err error
|
||||
@@ -51,7 +51,7 @@ func (r *settingsRepo) FindParameter(ctx context.Context, id uint, key string) (
|
||||
}
|
||||
return parameterFromPO(po), nil
|
||||
}
|
||||
func (r *settingsRepo) ListParameters(ctx context.Context, page, size int, q *biz.SystemParameter) ([]*biz.SystemParameter, int64, error) {
|
||||
func (r *parameterRepo) ListParameters(ctx context.Context, page, size int, q *biz.SystemParameter) ([]*biz.SystemParameter, int64, error) {
|
||||
db := r.data.gormDB.WithContext(ctx).Model(¶meterPO{})
|
||||
if q != nil {
|
||||
if q.StartCreatedAt != nil && q.EndCreatedAt != nil {
|
||||
|
||||
Reference in New Issue
Block a user