实现的是⼀个⼩程序预约时间功能 ,开始接到这个需求的时候觉得,是写在前端好呢,还是后端,后来我的⽇历呈现实现⽅式是放在了后端,因为产品设计的需求呢每次进⼊预约时间页⾯,规定都要读⼀遍后台设置数据,对当前时间于预约时间进⾏对⽐判断,确保数据的实时性。
记录下弄完的全过程把 ,我后端使⽤的是JAVA开发的
1.建了个POJO类,主要⽤于返回到前端的数据
public class YuYueVo {
private int id;//咨询师安排时间id
private String date;
台湾有哪些旅游胜地private int day;
你不爱我 歌词private int month;
private String status;
private List<TimePart> timeList;
private int is_display;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
女生网名可爱}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
刘端端配音毒液}
public int getMonth() {
return month;
}
public void setMonth(int month) {
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<TimePart> getTimeList() {
return timeList;
}
public void setTimeList(List<TimePart> timeList) { this.timeList = timeList;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getIs_display() {
return is_display;
}
public void setIs_display(int is_display) {
this.is_display = is_display;
}
2.建⽴了MyCalendar映射的是数据库表public class MyCalendar implements Serializable{
private static final long serialVersionUID = 1L;
private String id;
private String title; // 事件标题
private String starttime; // 事件开始时间
private String endtime; // 事件结束时间
private String adllDay; // 是否为全天时间
private String color; // 时间的背景⾊
private int hunterid;
private int hunterid;
private int isbook;//0默认未预定,1是已预定
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public MyCalendar() {
super();
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getStarttime() {
return starttime;
}
public void setStarttime(String starttime) { this.starttime = starttime;
}
public String getEndtime() {
return endtime;
}
public void setEndtime(String endtime) {
}
public String getAdllDay() {
return adllDay;
}
public void setAdllDay(String adllDay) {
this.adllDay = adllDay;
}
public String getColor() {
皇甫圣华是男是女return color;
}
public void setColor(String color) {
}
public int getHunterid() {
return hunterid;
}
public void setHunterid(int hunterid) {
this.hunterid = hunterid;
}
public int getIsbook() {
return isbook;
}
public void setIsbook(int isbook) {
this.isbook = isbook;
}
3.在controller⾥写了个这个测试的⽅法
@RequestMapping(value = "getOrderTime")
private void testYuYue(HttpServletResponse response,Integer hunterid){
int monthtmp=0;
Date currDay=new Date();
int WeekOfDate(currDay);
Date firstDay=null;
if(tempNum==0){
//表⽰现在是周⽇,那么第⼀个时间就是现在
firstDay=currDay;
}else{
firstDay=DateUtil.dateAddDay(-tempNum,currDay);
}
Calendar cal = Instance();
营口纽约纽约SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
int tmpMonth = Month();
//计算周天开始的第⼀天
List<YuYueVo> dataList=new ArrayList<YuYueVo>();
YuYueVo first=new YuYueVo();
first.setDate(format.format(firstDay));
cal.setTime(firstDay);
first.(Calendar.DAY_OF_MONTH));
first.(Calendar.MONTH));
first.setIs_display(1);
first.setStatus("已满");
dataList.add(first);
for(int i=1;i<21;i++){
Date time =DateUtil.dateAddDay(i,firstDay);
cal.setTime(time);
YuYueVo vo=new YuYueVo();
vo.setDate(format.format(time));
vo.(Calendar.DAY_OF_MONTH));
vo.(Calendar.MONTH));
if(tmpMonth!=vo.getMonth()&&monthtmp==0){
vo.setIs_display(1);
monthtmp=1;
}
List<MyCalendar> TimePart(hunterid,format.format(time),0);
List<MyCalendar> TimePart(hunterid,format.format(time),1);
if(myCalendars.size()!=0){
List<TimePart> tmpTime=new ArrayList<TimePart>();
for (MyCalendar myCalendar : myCalendars) {
if(Starttime(),DateUtil.currentTime())==1){
vo.setStatus("未满");
tmpTime.add(new Id(),Starttime().substring(11, 16),Endtime().substring(11, 16))); vo.setTimeList(tmpTime);
}else{
vo.setStatus("已满");
}
}
}else if(booked.size()!=0){
vo.setStatus("已满");
}else{
vo.setStatus("未开放");
}
dataList.add(vo);
}
this.successJson(dataList, "预约时间", response);
}
4.⼩程序端的wxml
发布评论