liuxiaolong
2019-07-03 1214326cbf8111b5819c0473e57b0ecb293fd6eb
fix bug
1个文件已修改
26 ■■■■■ 已修改文件
controllers/area.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/area.go
@@ -83,21 +83,31 @@
// @Accept  json
// @Produce json
// @Tags menu
// @Param id path int true "区域id"
// @Param area body controllers.AreaVo true "区域结构"
// @Param id query int true "区域id"
// @Param name query string true "区域名字"
// @Param parentId query int true "上一级父id"
// @Success 200 {string} json "{"code":200, data:"",msg:"请求成功", success:true}"
// @Failure 200 {string} json "{"code":"错误码", data:"出错信息",msg:"请求失败", success:false}"
// @Router /data/api-v/area/update [post]
func (ac AreaController) AreaUpdate(c *gin.Context) {
    var api dbapi.AreaApi
    var model AreaVo
    if err := c.BindJSON(&model);err !=nil {
        util.ResponseFormat(c, code.ComError, "参数有误")
    id,err := strconv.Atoi(c.PostForm("id"))
    if err !=nil{
        util.ResponseFormat(c, code.RequestParamError, "参数错误")
        return
    }
    name := c.PostForm("name")
    parentId, err := strconv.Atoi(c.PostForm("parentId"))
    if err !=nil {
        util.ResponseFormat(c, code.RequestParamError, "parentId参数错误")
        return
    }
    var model = AreaVo{
        Id:id,
        ParentId:parentId,
        Name:name,
    }
    paramBody := util.Struct2Map(model)
    var api dbapi.AreaApi
    if api.AreaUpdate(paramBody) {
        util.ResponseFormat(c,code.Success,"更新成功")
    }else {