go_dreamfactory/modules/web/api_createnotify.go
2023-06-06 13:55:33 +08:00

56 lines
1.4 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 (
errdata *pb.ErrorData
data interface{}
)
defer func() {
c.JSON(http.StatusOK, &Respond{Code: errdata.Code, Message: errdata.Message, 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)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SignError,
Title: pb.ErrorCode_SignError.ToString(),
}
return
}
if len(req.Title) == 0 {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil {
this.module.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
errdata = &pb.ErrorData{
Code: pb.ErrorCode_Success,
Title: pb.ErrorCode_Success.ToString(),
}
}