首页>代码>基于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 "删除失败";
        }
    }
}
最近下载更多
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日
Hopu2024  LV2 2024年2月22日
xk16675552250  LV33 2024年1月5日
最近浏览更多
TaoTaot 4月7日
暂无贡献等级
小宋敲代码 3月25日
暂无贡献等级
gxyhk666 3月25日
暂无贡献等级
blanknb 3月18日
暂无贡献等级
尼可曲奇 3月3日
暂无贡献等级
yvimib  LV3 3月2日
暂无贡献等级
苯科仔 2024年12月16日
暂无贡献等级
之祠____ 2024年12月15日
暂无贡献等级
sjwc88  LV3 2024年12月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友