import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
public class UpdateTimeController {
@Autowired
TimeMapper timeMapper;
public String queryEndTime(@RequestBody String id){//传入后端为json对象{"id":"12345678"}
TimeDO timeBean = JSON.parseObject(id,TimeDO.class);
TimeDO time = TimeMapper.getTimeByReqId(timeBean.getId());
return JSON.toJSONString(time);
}
}
public class TimeDo {
private String id;
private String endTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}
new Vue({
el:'#app',
data(){
return{
time:{
id:'',
endTime:''
}
}
},
methods:{
queryEndTime:function(){
axios({
url:'/queryEndTime',
method:'post',
data:{
id:this.time.id //输入框输入的id值
}
}).then(response=>{
this.time = response.data;
console.log(this.time.endTime);
});
}
}
});
requestId