@@ -0,0 +1,54 @@
|
||||
package integralconfigser
|
||||
|
||||
import (
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/v/integralconfigmod"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Add(in *integralconfigmod.AddCond, manager string) stderr.Code {
|
||||
err := integralconfigmod.InsertOne(nil, in.Generate(manager))
|
||||
if err != nil {
|
||||
return stderr.ErrDbInsertError
|
||||
}
|
||||
return stderr.Success
|
||||
}
|
||||
|
||||
func Edit(in *integralconfigmod.EditCond, manager string) error {
|
||||
vp, err := integralconfigmod.FindOneById(in.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vp.ID.IsZero() {
|
||||
return errors.New("integral config is null")
|
||||
}
|
||||
|
||||
if err = integralconfigmod.Edit(in.Filter(), in.Update(manager)); err != nil {
|
||||
log.Error(fmt.Sprintf("integralconfigmod update error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func QueryAll(in *integralconfigmod.QueryAllCond) (*integralconfigmod.QueryAllRes, error) {
|
||||
var out = &integralconfigmod.QueryAllRes{}
|
||||
count, err := integralconfigmod.QueryAllCount(in.Filter())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if count == 0 {
|
||||
out.List = []*integralconfigmod.IntegralConfig{}
|
||||
out.Total = 0
|
||||
return out, nil
|
||||
}
|
||||
out.Total = count
|
||||
out.List, err = integralconfigmod.QueryAllList(in.Filter(), in.Options())
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("integralconfigmod queryAllList error:%+v:", err))
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
Reference in New Issue
Block a user