package com.cyksj.web.controller.user;

import com.cyksj.dto.Result;
import com.cyksj.enums.GatewayResponse;
import com.cyksj.service.station.CollegeStudentStationFService;
import com.cyksj.web.util.StpUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目名: yhlxj2
 * 文件名: CollegeStudentStationController
 * 创建者: JavaZou
 * 创建时间:2024/5/28 11:50
 */
@Slf4j
@RestController
@RequestMapping("/applet/college/student")
@RequiredArgsConstructor
public class CollegeStudentStationController {
	private final CollegeStudentStationFService collegeStudentStationService;


	/**
	 * 大学生 扫码记录
	 */
	@PostMapping("/post")
	public Result<String> saveCollegeStudent(Integer type) {
		long userId = StpUserUtil.getLoginIdAsLong();
		collegeStudentStationService.saveCollegeStudent(userId, type);
		return GatewayResponse.SUCCESS.newBuilder().toResult();
	}


	/**
	 * 体验车票id
	 */
	@GetMapping("/get")
	public Result<Long> getExperienceTicket() {
		long userId = StpUserUtil.getLoginIdAsLong();
		Long relationId = collegeStudentStationService.getExperienceTicket(userId);
		return GatewayResponse.SUCCESS.newBuilder().toResult(relationId);
	}
}
