go_dreamfactory/modules/web/api_createnotify.go
2022-07-25 16:35:35 +08:00

46 lines
1.2 KiB
Go

package web
import (
"go_dreamfactory/lego/sys/gin"
"go_dreamfactory/lego/sys/gin/engine"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"net/http"
)
type CreateNotifyReq struct {
pb.DBSystemNotify
Sign string `json:"sign"`
}
//创建公告
func (this *Api_Comp) CreateNotify(c *engine.Context) {
req := &CreateNotifyReq{}
err := c.BindJSON(&req)
this.module.Debugf("CreateNotify:%+v err:%v", req, err)
var (
code pb.ErrorCode
msg string
data interface{}
)
defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"Title": req.Title, "Ctime": req.Ctime, "Rtime": req.Rtime}); sign != req.Sign {
log.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
code = pb.ErrorCode_SignError
msg = pb.GetErrorCodeMsg(code)
return
}
if len(req.Title) == 0 {
code = pb.ErrorCode_ReqParameterError
msg = pb.GetErrorCodeMsg(code)
return
}
if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil {
log.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err)
code = pb.ErrorCode_DBError
msg = pb.GetErrorCodeMsg(code)
return
}
msg = pb.GetErrorCodeMsg(code)
}