首页>代码>基于springboot+layui实现的医院信息管理系统>/src/main/java/com/aaa/controller/AreaController.java
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 "删除失败";
        }
    }
}
最近下载更多
d3834632  LV2 7月14日
zhaopb  LV8 5月17日
zhaorrr  LV2 2024年11月7日
yyhrhv  LV8 2024年8月31日
叁卍石  LV5 2024年8月21日
TY0165  LV20 2024年6月21日
pxc1994  LV9 2024年5月14日
微信网友_6927932988952576  LV12 2024年3月31日
提灯寻白鹿  LV3 2024年3月27日
qqttuu  LV3 2024年3月4日
最近浏览更多
d3834632  LV2 7月14日
短巷拥猫  LV12 6月18日
潜心小白来到  LV3 6月10日
2225906816 5月26日
暂无贡献等级
zxdfdcfffddssd 5月21日
暂无贡献等级
123456789x  LV1 5月19日
zhaopb  LV8 5月17日
TaoTaot 4月7日
暂无贡献等级
小宋敲代码 3月25日
暂无贡献等级
gxyhk666 3月25日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友