码迷,mamicode.com
首页 > 其他好文 > 详细

SprinBoot整合SSM之添加

时间:2018-06-24 12:57:26      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:public   class   cep   pm2   air   etc   his   rri   div   

上一篇博客已经把所需要用到的依赖,分层,配置文件都已经书写好了,这里我们直接说明添加的代码

从dao层开始:

  //添加
    public int addair(Air air);

service:

 public int addair(Air air);
  @Override

//事务的参与 @Transactional
public int addair(Air air) { return dao.addair(air); }

Controller:

   //先跳转到添加页面
    @RequestMapping("/goAddPage")
    public String goAddPage(){
        return "add";
    }
    //添加功能
    @RequestMapping("/addAir")
    public String addAir(Air air){
        try{
            int addair = iairService.addair(air);
        }catch (Exception e){
            e.printStackTrace();
        }
        return "forward:/gohome";
    }

实体层:

public class Air {
    private Integer id;
    private String district;
    @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @JsonSerialize(using = JsonDateSerializer.class)
    private Date monitorTime;
    private Integer pm10;
    private Integer pm25;
    private String monitoringStation;
    private Date createDate;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public Date getMonitorTime() {
        return monitorTime;
    }

    public void setMonitorTime(Date monitorTime) {
        this.monitorTime = monitorTime;
    }

    public Integer getPm10() {
        return pm10;
    }

    public void setPm10(Integer pm10) {
        this.pm10 = pm10;
    }

    public Integer getPm25() {
        return pm25;
    }

    public void setPm25(Integer pm25) {
        this.pm25 = pm25;
    }

    public String getMonitoringStation() {
        return monitoringStation;
    }

    public void setMonitoringStation(String monitoringStation) {
        this.monitoringStation = monitoringStation;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
}

以上就是全部添加的代码,忽略前台页面哈,太。。。。。

在添加的时候,会涉及到一个日期类型转换的问题,具体详情请看下一篇博客

SprinBoot整合SSM之添加

标签:public   class   cep   pm2   air   etc   his   rri   div   

原文地址:https://www.cnblogs.com/1234AAA/p/9220019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!