package com.dsh.activity.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.dsh.activity.entity.BenefitsVideoClassification; import com.dsh.activity.entity.BenefitsVideos; import com.dsh.activity.entity.BodySideAppointment; import com.dsh.activity.feignclient.other.StoreClient; import com.dsh.activity.feignclient.other.model.Store; import com.dsh.activity.model.*; import com.dsh.activity.service.BenefitsVideosService; import com.dsh.activity.service.BodySideAppointmentService; import com.dsh.activity.service.IBenefitsVideoClassificationService; import com.dsh.activity.util.ResultUtil; import com.dsh.activity.util.TokenUtil; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.models.auth.In; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; /** * 体测预约管理控制器 */ @RestController @RequestMapping("") public class BodySideAppointmentsController { @Autowired private BodySideAppointmentService bodySideAppointmentService; @Autowired private StoreClient storeClient; /** * 获取所有体测预约记录 * @return */ @RequestMapping("/base/bodySideAppointments/listAll") public List listAll(@RequestBody QueryBodySideAppointment vo){ List queryBodySideAppointmentVOS = bodySideAppointmentService.listAll(vo); List list = new ArrayList<>(); for (QueryBodySideAppointmentVO queryBodySideAppointmentVO : queryBodySideAppointmentVOS) { list.add(queryBodySideAppointmentVO.getStoreId()); } List stores = storeClient.queryStoreByIds(list); for (QueryBodySideAppointmentVO queryBodySideAppointmentVO : queryBodySideAppointmentVOS) { for (Store store : stores) { if (queryBodySideAppointmentVO.getStoreId() == store.getId()){ queryBodySideAppointmentVO.setStoreName(store.getName()); break; } } } return queryBodySideAppointmentVOS; } /** * 增加/修改体测预约记录 * @return */ @RequestMapping("/base/bodySideAppointments/addBodySideAppointments") public Object addBodySideAppointments(@RequestBody QueryBodySideAppointmentVO vo){ BodySideAppointment bodySideAppointment = new BodySideAppointment(); BeanUtils.copyProperties(vo,bodySideAppointment); bodySideAppointment.setStatus(1); bodySideAppointment.setState(1); bodySideAppointment.setInsertTime(new Date()); if (vo.getId() != null){ return bodySideAppointmentService.updateById(bodySideAppointment); }else { return bodySideAppointmentService.save(bodySideAppointment); } } /** * 手动标记用户已经到店并完成体测 * @return */ @RequestMapping("/base/bodySideAppointments/changeState") public Object changeState(@RequestBody List ids){ return bodySideAppointmentService.changeState(ids); } /** * 通过id获取体测预约记录 * @return */ @RequestMapping("/base/bodySideAppointments/getInfoById") public BodySideAppointment getInfoById(@RequestBody Integer id){ return bodySideAppointmentService.getById(id); } }