添加用户缓存及更新,添加配置文件增删改查接口,添加文件功能.添加配置文件添加请求
This commit is contained in:
parent
f22df7f012
commit
5f98ed5651
|
|
@ -22,7 +22,7 @@ func SetUpFileGroup(router *gin.Engine) {
|
|||
func AddConfigFile(c *gin.Context) {
|
||||
id, _ := c.Get("id")
|
||||
user_id := int(id.(float64))
|
||||
var req proto.ConfigFileReq
|
||||
var req proto.AddConfigFileReq
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
err2 := service.CreateConfigFile(&req, user_id)
|
||||
if err2 != nil {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ type ConfigFileReq struct {
|
|||
Content string `json:"content" form:"content"`
|
||||
}
|
||||
|
||||
type AddConfigFileReq struct {
|
||||
FileName string `json:"file_name" form:"file_name" required:"true"`
|
||||
FilePath string `json:"file_path" form:"file_path" required:"true"`
|
||||
}
|
||||
type SearchOneConfigFileResp struct {
|
||||
ID uint `json:"id" form:"id"`
|
||||
CreatedAt time.Time `json:"created_at" form:"created_at"`
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func CheckUploadRequestParameters(req *proto.FileUploadReq) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func CreateConfigFile(req *proto.ConfigFileReq, userId int) error {
|
||||
func CreateConfigFile(req *proto.AddConfigFileReq, userId int) error {
|
||||
var err error
|
||||
user := GetUserByIDWithCache(userId)
|
||||
if user.ID == 0 || user.Role != "admin" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue