| | |
| | | } |
| | | paramBody := util.Struct2Map(model) |
| | | if api.AreaAdd(paramBody) { |
| | | util.ResponseFormat(c,code.Success,"保存成功") |
| | | util.ResponseFormat(c,code.AddSuccess,"添加成功") |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"保存失败") |
| | | util.ResponseFormat(c,code.ComError,"添加失败") |
| | | } |
| | | } |
| | | |
| | |
| | | // @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/{id} [put] |
| | | // @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,"更新成功") |
| | | util.ResponseFormat(c,code.UpdateSuccess,"更新成功") |
| | | }else { |
| | | util.ResponseFormat(c,code.ComError,"更新失败") |
| | | } |
| | |
| | | // @Param id 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/del [get] |
| | | // @Router /data/api-v/area/del [post] |
| | | func (ac AreaController) AreaDelete(c *gin.Context) { |
| | | var api dbapi.AreaApi |
| | | id := c.Query("id") |
| | | id := c.PostForm("id") |
| | | areaId, err := strconv.Atoi(id) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.ComError, "传入非整形无法解析") |
| | | util.ResponseFormat(c, code.ComError, "参数有误") |
| | | return |
| | | } |
| | | |
| | | if api.AreaDelete(areaId) { |
| | | util.ResponseFormat(c, code.Success, "删除成功") |
| | | util.ResponseFormat(c, code.DelSuccess, "删除成功") |
| | | } else { |
| | | util.ResponseFormat(c, code.ComError,"删除失败") |
| | | } |