搭建线路mvc实现接口获取数据库数据

搭建线路mvc实现接口获取数据库数据

 

 

BuslineController:
public class BuslineController {

    @Autowired
    private BuslineService buslineService;

    @RequestMapping("/busline")//获取用户接口
    @ResponseBody
    public List<Busline> getAll(){
        return buslineService.getAllBusline();
    }



    @RequestMapping("/busline/delete")
    @ResponseBody
    public int delete(@RequestBody BigInteger ids){

        return buslineService.deleteById(ids);
    }
    @RequestMapping("/busline/create")
    @ResponseBody
    public Response<Busline> create(@RequestBody  Busline busline){
        Response<Busline> response = new Response<>();
        Busline newId = buslineService.create(busline);
        if(newId == null){
            response.setSuccess(false);
            response.setMessage("同名用户已经存在。");
            response.setData(null);
        }else{
            response.setSuccess(true);
            response.setMessage("创建用户成功");
            response.setData(busline);
        }
        return response;
    }
    @RequestMapping("/busline/login")
    @ResponseBody
    public Response<Busline> login(@RequestBody  Busline busline){
        Response<Busline> response = new Response<>();
        return response;
    }
}

  dao的函数

public interface BusMapper {


List<Bus> getAllBus();
}

mapper中:

 

 model中get和set:

 

 

还有server和数据库连接关键文件。。。。不一一讲述

 

 

还有线路到车辆的表格也在搭建中

 
posted @ 2020-03-02 22:17  代码是肥钦喔  阅读(386)  评论(0编辑  收藏  举报