Преглед изворни кода

[增加]查看我的电影票接口

liying пре 7 година
родитељ
комит
8f6f7fe2d6

+ 5 - 3
src/main/java/com/example/cinema/blImpl/TicketServiceImpl.java

@@ -1,6 +1,5 @@
 package com.example.cinema.blImpl;
 
-import com.example.cinema.bl.CouponService;
 import com.example.cinema.bl.TicketService;
 import com.example.cinema.data.CouponMapper;
 import com.example.cinema.data.ScheduleMapper;
@@ -15,7 +14,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -97,7 +95,11 @@ public class TicketServiceImpl implements TicketService {
     @Override
     public ResponseVO getTicketByUser(int userId) {
         try {
-            List<TicketVO> vos = ticketMapper.selectTicketByUser(userId).stream().map(ticket -> ticket.getVO()).collect(Collectors.toList());
+            List<TicketWithScheduleVO> vos = ticketMapper.selectTicketByUser(userId).stream().map(ticket -> {
+                TicketWithScheduleVO vo=ticket.getWithScheduleVO();
+                vo.setSchedule(scheduleMapper.selectScheduleById(ticket.getScheduleId()));
+                return vo;
+            }).collect(Collectors.toList());
             return ResponseVO.buildSuccess(vos);
         } catch (Exception e) {
             e.printStackTrace();

+ 26 - 0
src/main/java/com/example/cinema/po/Ticket.java

@@ -1,6 +1,7 @@
 package com.example.cinema.po;
 
 import com.example.cinema.vo.TicketVO;
+import com.example.cinema.vo.TicketWithScheduleVO;
 
 /**
  * Created by liying on 2019/4/16.
@@ -63,6 +64,31 @@ public class Ticket {
         return vo;
 
     }
+    public TicketWithScheduleVO getWithScheduleVO() {
+        TicketWithScheduleVO vo = new TicketWithScheduleVO();
+        vo.setRowIndex(this.getRowIndex());
+        vo.setColumnIndex(this.getColumnIndex());
+        vo.setId(this.getId());
+        vo.setUserId(this.getUserId());
+        String stateString;
+        switch (state) {
+            case 0:
+                stateString = "未完成";
+                break;
+            case 1:
+                stateString = "已完成";
+                break;
+            case 2:
+                stateString = "已失效";
+                break;
+            default:
+                stateString = "未完成";
+        }
+        vo.setState(stateString);
+        return vo;
+
+    }
+
 
     public int getId() {
         return id;

+ 84 - 0
src/main/java/com/example/cinema/vo/TicketWithScheduleVO.java

@@ -0,0 +1,84 @@
+package com.example.cinema.vo;
+
+/**
+ * Created by liying on 2019/4/16.
+ */
+public class TicketWithScheduleVO {
+
+    /**
+     * 电影票id
+     */
+    private int id;
+    /**
+     * 用户id
+     */
+    private int userId;
+    /**
+     * 排片id
+     */
+    private ScheduleItem schedule;
+    /**
+     * 列号
+     */
+    private int columnIndex;
+    /**
+     * 排号
+     */
+    private int rowIndex;
+
+    /**
+     * 订单状态
+     */
+    private String state;
+
+    public TicketWithScheduleVO() {
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public int getUserId() {
+        return userId;
+    }
+
+    public void setUserId(int userId) {
+        this.userId = userId;
+    }
+
+    public ScheduleItem getSchedule() {
+        return schedule;
+    }
+
+    public void setSchedule(ScheduleItem scheduleId) {
+        this.schedule = schedule;
+    }
+
+    public int getColumnIndex() {
+        return columnIndex;
+    }
+
+    public void setColumnIndex(int columnIndex) {
+        this.columnIndex = columnIndex;
+    }
+
+    public int getRowIndex() {
+        return rowIndex;
+    }
+
+    public void setRowIndex(int rowIndex) {
+        this.rowIndex = rowIndex;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+}