123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package data_api
- import (
- "context"
- "gd_management/apis"
- "gd_management/errors"
- "time"
- "github.com/astaxie/beego/orm"
- )
- func DataApiReleaseApi(ctx context.Context, req *apis.ManagementDataApiReleaseApiReq, reply *apis.ManagementDataApiReleaseApiReply) error {
- if req.DataApiId == 0 {
- return errors.ArgsError
- }
- o := orm.NewOrm()
- var dataApiInfo apis.DataApi
- err := o.QueryTable("t_gd_data_api").Filter("id", req.DataApiId).One(&dataApiInfo)
- if err != nil {
- if err != orm.ErrNoRows {
- return errors.DataBaseError
- } else {
- return errors.DataApiNotExist
- }
- }
- var timeLayout = "2006-01-02 15:04:05"
- timeNow := time.Now().Format(timeLayout)
- dataApiInfo.ReleaseTime = timeNow
- dataApiInfo.IsRelease = true
- if req.Status == 0 {
- dataApiInfo.IsRelease = false
- }
- _, err = o.Update(&dataApiInfo)
- if err != nil {
- return errors.DataBaseError
- }
- return nil
- }
|