package com.dsh.guns.modular.system.controller.system;
|
|
|
import com.dsh.course.dto.*;
|
import com.dsh.course.feignClient.account.AppUserClient;
|
import com.dsh.course.feignClient.course.CourseStuddentClient;
|
import com.dsh.course.feignClient.course.model.TCoursePackagePayment;
|
import com.dsh.course.feignClient.other.HistoryClient;
|
import com.dsh.course.model.dto.StudentClassInfo;
|
import com.dsh.guns.config.UserExt;
|
import com.dsh.guns.core.base.controller.BaseController;
|
import com.dsh.guns.modular.system.model.TStudent;
|
import com.dsh.guns.modular.system.model.User;
|
import com.dsh.guns.modular.system.model.dto.SelectDto;
|
import com.dsh.guns.modular.system.service.ITStudentService;
|
import com.dsh.guns.modular.system.util.ResultUtil;
|
import org.apache.ibatis.annotations.Param;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2023-09-12 14:51:26
|
*/
|
@Controller
|
@RequestMapping("/tStudent")
|
public class TStudentController extends BaseController {
|
|
private String PREFIX = "/system/tStudent/";
|
@Autowired
|
private ITStudentService itStudentService;
|
|
@Resource
|
private CourseStuddentClient courseStuddentClient;
|
|
@Resource
|
private HistoryClient historyClient;
|
|
|
|
|
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tStudent.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tStudent_add")
|
public String tStudentAdd() {
|
return PREFIX + "tStudent_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tStudent_update/{tStudentId}")
|
public String tStudentUpdate(@PathVariable("tStudentId") Integer tStudentId, Model model) {
|
|
|
System.out.println("======>t"+tStudentId);
|
//查询学员信息
|
TStudentDto tStudentDto = itStudentService.listOne(tStudentId);
|
model.addAttribute("item", tStudentDto);
|
if (tStudentDto.getLateralSurface()!=null) {
|
String[] pics = tStudentDto.getLateralSurface().split(";");
|
model.addAttribute("pic1", pics[0]);
|
System.out.println("=====pic1==" + pics[0]);
|
if (pics.length > 1) {
|
model.addAttribute("pic2", pics[1]);
|
System.out.println("=====pic2==" + pics[1]);
|
}
|
if (pics.length > 3) {
|
model.addAttribute("pic3", pics[2]);
|
System.out.println("=====pic3==" + pics[2]);
|
}
|
}
|
|
|
//查询课时信息
|
StudentClassInfo studentClassInfo = courseStuddentClient.getInfo(tStudentId);
|
model.addAttribute("studentClassInfo", studentClassInfo);
|
|
//查询课程列表
|
List<ClassListDto> classListDtos = courseStuddentClient.listClass(tStudentId);
|
model.addAttribute("classListDtos", classListDtos);
|
|
|
return PREFIX + "tStudentEdit_first.html";
|
}
|
|
@RequestMapping("/tStudent_info/{tStudentId}")
|
public String tStudentInfo(@PathVariable("tStudentId") Integer tStudentId, Model model) {
|
System.out.println("======>t"+tStudentId);
|
//查询学员信息
|
TStudentDto tStudentDto = itStudentService.listOne(tStudentId);
|
model.addAttribute("item", tStudentDto);
|
if (tStudentDto.getLateralSurface()!=null) {
|
String[] pics = tStudentDto.getLateralSurface().split(";");
|
model.addAttribute("pic1", pics[0]);
|
System.out.println("=====pic1==" + pics[0]);
|
if (pics.length > 1) {
|
model.addAttribute("pic2", pics[1]);
|
System.out.println("=====pic2==" + pics[1]);
|
}
|
if (pics.length > 3) {
|
model.addAttribute("pic3", pics[2]);
|
System.out.println("=====pic3==" + pics[2]);
|
}
|
}
|
|
|
//查询课时信息
|
StudentClassInfo studentClassInfo = courseStuddentClient.getInfo(tStudentId);
|
model.addAttribute("studentClassInfo", studentClassInfo);
|
|
|
System.out.println("=======controller====studentClassInfo==="+studentClassInfo);
|
return PREFIX + "tStudentEdit.html";
|
}
|
|
|
|
|
//
|
|
/**
|
* 获取有效期
|
*/
|
@RequestMapping("/getUseTime/{tStudentId}")
|
@ResponseBody
|
public ResultUtil getMax(@PathVariable("tStudentId") Integer tStudentId) {
|
Date useTime = courseStuddentClient.getUseTime(tStudentId);
|
Map<String, Date> map = new HashMap<>();
|
map.put("useTime",useTime);
|
|
return new ResultUtil<>(0,0,null,map,null);
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping("/list")
|
@ResponseBody
|
public List<TStudentDto> list(StudentSearch search) {
|
|
System.out.println("============学员查询接口=========");
|
return itStudentService.listAll(search);
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping("/classList/{tStudentId}")
|
@ResponseBody
|
public ResultUtil listClass(@PathVariable("tStudentId") Integer tStudentId) {
|
List<ClassListDto> classListDtos = courseStuddentClient.listClass(tStudentId);
|
Map<String,List<ClassListDto>> map = new HashMap<>();
|
map.put("items",classListDtos);
|
return new ResultUtil<>(0,0,null,map,null);
|
}
|
|
|
|
@RequestMapping("/ttt")
|
@ResponseBody
|
public ResultUtil list1(StudentSearch search) {
|
|
System.out.println("============学员查询接口=========");
|
return ResultUtil.success();
|
}
|
|
/**
|
* 学员修改
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
|
public ResultUtil update(@RequestBody TStudent tStudent, String image1, String image2, String image3 ) {
|
String lateralSurface = image1+";"+image2+";"+image3;
|
tStudent.setLateralSurface(lateralSurface);
|
System.out.println("学员体测表的值"+lateralSurface);
|
itStudentService.update(tStudent);
|
// appUserClient.updateStudent(tStudent);
|
return new ResultUtil(0,0,"编辑成功");
|
}
|
|
@Resource
|
private AppUserClient appUserClient;
|
/**
|
* 学员详情修改有效期
|
*/
|
|
@RequestMapping("/updateClassTime")
|
@ResponseBody
|
public ResultUtil updateClassTime(@RequestParam("date") String date, @RequestParam("id")Integer id, String passPic, String pleasePic ){
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
Date date1;
|
try {
|
date1 = dateFormat.parse(date);
|
} catch (ParseException e) {
|
// 处理日期转换异常
|
e.printStackTrace();
|
return ResultUtil.error("日期格式错误");
|
}
|
|
|
updateTimeDto updateTimeDto =new updateTimeDto(date1,id);
|
System.out.println("======updateTimeDto=====>"+updateTimeDto);
|
courseStuddentClient.updateUseDate(updateTimeDto);
|
|
|
CreateHistoryDto historyDto = new CreateHistoryDto();
|
historyDto.setPleasePic(pleasePic);
|
historyDto.setPassPic(passPic);
|
User user = UserExt.getUser();
|
historyDto.setCreateBy(user.getId());
|
historyDto.setStudentId(id);
|
|
// appUserClient.createHistory(historyDto);
|
historyClient.createHistory(historyDto);
|
|
|
return ResultUtil.success();
|
|
}
|
|
|
/**
|
* 查询有效期记录
|
*/
|
@RequestMapping(value = "/getHisory/{id}")
|
@ResponseBody
|
public ResultUtil getHisory(@PathVariable("id") Integer studentId) {
|
List<GetHistoryDto> getHistoryDtos = historyClient.getHisory(studentId);
|
Map<String,List<GetHistoryDto>> map = new HashMap<>();
|
map.put("items",getHistoryDtos);
|
|
return new ResultUtil(0,0,"编辑成功",map,"");
|
}
|
|
/**
|
* 查询有效期记录
|
*/
|
@RequestMapping(value = "/getUserSlect/{id}")
|
@ResponseBody
|
public ResultUtil getUserSlect(@PathVariable("id") Integer payId) {
|
|
List<SelectDto> selectDtos = courseStuddentClient.getSelect(payId);
|
Map<String,List<SelectDto>> map = new HashMap<>();
|
map.put("options",selectDtos);
|
return new ResultUtil(0,0,"编辑成功",map,"");
|
}
|
}
|