liujie
2023-09-20 d09828cdec78a160f4530a8ab245216ed8671c27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
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,"");
    }
}