package com.aaa.controller; import com.aaa.entity.Area; import com.aaa.service.AreaService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.HashMap; import java.util.List; import java.util.Map; @Controller @RequestMapping("area") public class AreaController { @Autowired private AreaService areaService; /* * 查询生产地址 * */ @RequestMapping("findAllArea") @ResponseBody public Object AreaList(Area Area, Integer page, Integer limit){ PageHelper.startPage(page, limit); List<Area> listAll = areaService.findAllArea(Area); PageInfo pageInfo = new PageInfo(listAll); Map<String, Object> tableData = new HashMap<String, Object>(); //这是layui要求返回的json数据格式 tableData.put("code", 0); tableData.put("msg", ""); //将全部数据的条数作为count传给前台(一共多少条) tableData.put("count", pageInfo.getTotal()); //将分页后的数据返回(每页要显示的数据) tableData.put("data", pageInfo.getList()); return tableData; } /* * 添加生产地址 * */ @RequestMapping("addArea") @ResponseBody public Object addArea(Area Area){ int count = areaService.count(Area); if(count==0){ int i = areaService.addArea(Area); if(i==1){ return "添加成功"; }else{ return "添加失败"; } }else { return Area.getAreaName()+"已存在"; } } /* * 删除生产地址 * */ @RequestMapping("deleteArea") @ResponseBody public Object deleteArea(Integer areaId){ int i = areaService.deleteArea(areaId); if(i==1){ return "删除成功"; }else{ return "删除失败"; } } }
最近下载更多
qqttuu LV3
3月4日
Hopu2024 LV2
2月22日
xk16675552250 LV33
1月5日
小安同学 LV7
2023年12月30日
阿桐吖 LV2
2023年12月29日
牛Bgtp LV1
2023年12月22日
lllxxxwofhoa LV2
2023年12月10日
2010160433 LV3
2023年12月7日
lvhongquan LV11
2023年9月19日
yqyqyqyqy LV4
2023年7月23日
最近浏览更多
ggjkvyj
3月16日
暂无贡献等级
微信网友_6909455156350976 LV2
3月16日
棒棒糖123
3月14日
暂无贡献等级
miku007
3月13日
暂无贡献等级
谢谢谢谢谢谢你 LV6
2月28日
Hopu2024 LV2
2月22日
FF加菲猫 LV4
2月15日
khhuyvhgcd LV1
2月11日
ljhgff LV1
2月10日
Gin19960217 LV3
1月22日