go_dreamfactory/modules/web/api_createnotify.go
2023-06-06 09:56:12 +08:00

50 lines
1.3 KiB
Go

package web
import (
"go_dreamfactory/lego/sys/gin"
"go_dreamfactory/lego/sys/gin/engine"
"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 func() {
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 {
this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
code = pb.ErrorCode_SignError
msg = pb.GetErrorCodeMsg(code)
return
}
if len(req.Title) == 0 {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
msg = pb.GetErrorCodeMsg(code)
return
}
if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil {
this.module.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err)
code = pb.ErrorCode_DBError
msg = pb.GetErrorCodeMsg(code)
return
}
msg = pb.GetErrorCodeMsg(code)
}