44323
2023-10-07 e6ee956618b3c1a6371a6c22dfbb70868dbd3f17
cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java
@@ -1,11 +1,12 @@
package com.dsh.account.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.account.dto.CreateHistoryDto;
import com.dsh.account.dto.GetHistoryDto;
import com.dsh.account.dto.StudentSearch;
import com.dsh.account.dto.TStudentDto;
import com.dsh.account.dto.*;
import com.dsh.account.entity.Coach;
import com.dsh.account.entity.GiftSearchDto;
import com.dsh.account.entity.TStudent;
import com.dsh.account.feignclient.course.CoursePaymentClient;
import com.dsh.account.feignclient.course.model.TCoursePackagePayment;
import com.dsh.account.model.StudentVo;
import com.dsh.account.service.TStudentService;
import com.dsh.account.util.ResultUtil;
@@ -15,7 +16,9 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.mappers.ModelMapper;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -35,7 +38,16 @@
    @Autowired
    private TokenUtil tokenUtil;
    /**
     * 添加学员
     * @return
     */
    @RequestMapping("/base/student/addStudent")
    public Object addStudent(@RequestBody TStudent student){
        student.setInsertTime(new Date());
        student.setIsDefault(1);
       return studentService.save(student);
    }
    /**
     * 获取用户学员列表
     * @param appUserId
@@ -59,7 +71,7 @@
    @PostMapping("/student/queryDefaultStudent")
    public TStudent queryDefaultStudent(@RequestBody Integer appUserId){
        try {
            TStudent one = studentService.getOne(new QueryWrapper<TStudent>().eq("appUserId", appUserId).eq("isDefault", 1).eq("state", 1));
            TStudent one = studentService.getOne(new QueryWrapper<TStudent>().eq("appUserId", appUserId).eq("isDefault", 1).eq("state", 1).last("limit 1"));
            return one;
        }catch (Exception e){
            e.printStackTrace();
@@ -130,6 +142,8 @@
    }
    /**
     * 根据名称模糊搜索学员
     * @param name
@@ -138,6 +152,15 @@
    @ResponseBody
    @PostMapping("/student/queryStudentListByName")
    public List<TStudent> queryStudentListByName(@RequestBody String name){
        return studentService.list(new QueryWrapper<TStudent>().eq("state", 1).like("name", name));
    }
    /**
     * 根据名称模糊搜索学员
     * @param name
     * @return
     */
    @PostMapping("/student/queryTStudentListByName")
    public List<TStudent> queryTStudentListByName(@RequestBody String name){
        return studentService.list(new QueryWrapper<TStudent>().eq("state", 1).like("name", name));
    }
@@ -180,4 +203,32 @@
        List<GetHistoryDto> getHistoryDtos =  studentService.getHistory();
        return getHistoryDtos;
    }
    @Resource
    private CoursePaymentClient paymentClient;
    @ResponseBody
    @PostMapping("/student/giftSelect")
    public  List<SelectDto> giftSelect(@RequestBody GiftSearchDto giftSearchDto){
        System.out.println("======giftSelect=========giftSearchDto===="+giftSearchDto);
//       Integer appId = studentService.getGiftSelect(giftSearchDto);
        TCoursePackagePayment1 coursePackagePaymentById = paymentClient.getCoursePackagePaymentById1(giftSearchDto.getId());
//        System.out.println("=======giftSelect======appId====>"+appId);
        List<TStudent> selectDtos =  studentService.list(new QueryWrapper<TStudent>()
                .select("name, id")
                .eq("state", 1)
                .eq("name", giftSearchDto.getName()).eq("phone",giftSearchDto.getPhone()).ne("appUserId",coursePackagePaymentById.getAppUserId()));
        List<SelectDto> list = new ArrayList<>();
        for (TStudent student : selectDtos) {
            SelectDto selectDto = new SelectDto();
            selectDto.setValue(student.getName());
            selectDto.setId(student.getId());
            list.add(selectDto);
        }
        System.out.println("=======giftSelect======selectDtos====>"+list);
        return list;
    }
}