无关风月
2025-04-10 b74277583bf9b2b89247061bf08c17a03b71c76e
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
package com.dsh.guns.modular.system.controller.code;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.course.feignClient.account.AppUserClient;
import com.dsh.course.feignClient.account.model.TAppUser;
import com.dsh.course.feignClient.activity.IntroduceClient;
import com.dsh.course.feignClient.activity.model.IntroduceRewards;
import com.dsh.course.feignClient.other.model.Banner;
import com.dsh.guns.modular.system.model.*;
import com.dsh.guns.modular.system.service.ICityService;
import com.dsh.guns.modular.system.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.text.SimpleDateFormat;
import java.util.List;
 
/**
 * 介绍有礼 控制器
 */
 
@Controller
@RequestMapping("/introduce")
public class TIntroductionCourtesyController {
 
    private String PREFIX = "/system/introduce/";
 
    @Autowired
    private ICityService cityService;
    @Autowired
    private IntroduceClient introduceClient;
    @Autowired
    private AppUserClient appUserClient;
 
    /**
     * 上/下架 1为上架 2为下架
     *
     * @return
     */
    @RequestMapping("/changeState")
    @ResponseBody
    public Object changeState(@RequestBody IntroduceChangeStateDTO dto){
        introduceClient.changeState(dto);
        return ResultUtil.success();
    }
 
    /**
     * 介绍有礼列表页
     */
    @RequestMapping("")
    public String index(Model model) {
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        return PREFIX + "introduce.html";
    }
    /**
     * 介绍有礼-参与用户列表页
     */
    @RequestMapping("/user/{id}")
    public String index(Model model,@PathVariable("id")Integer id) {
        // 介绍有礼id
        model.addAttribute("id",id);
        return PREFIX + "introduce_user.html";
    }
 
    /**
     * 介绍有礼添加页
     */
    @RequestMapping("/add")
    public String add(Model model) {
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
 
        model.addAttribute("list",list);
        return PREFIX + "introduce_add.html";
    }
    /**
     * 介绍有礼编辑页
     */
    @RequestMapping("/update/{id}")
    public String update(Model model, @PathVariable("id")Integer id) {
        IntroduceRewards data = introduceClient.getInfoById(id);
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        TCity province1 = cityService.getOne(new QueryWrapper<TCity>().eq("name", data.getProvince()));
        List<TCity> city = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, province1.getId()));
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format1 = format.format(data.getStartTime());
        String format2 = format.format(data.getEndTime());
        model.addAttribute("data",data);
        model.addAttribute("startTime",format1);
        model.addAttribute("endTime",format2);
        model.addAttribute("list",list);
        model.addAttribute("city",city);
        return PREFIX + "introduce_edit.html";
    }
 
 
    /**
     * 获取介绍有礼记录列表
     */
    @RequestMapping(value = "/listAll")
    @ResponseBody
    public List<IntroduceVO> listAll(IntroduceQuery query) {
        List<IntroduceVO> list = introduceClient.listAll(query);
        for (IntroduceVO introduceVO : list) {
            Integer activityPeoples = appUserClient.getActivityPeoples(introduceVO.getId());
            introduceVO.setNumber(activityPeoples);
        }
        return list;
    }
 
    /**
     * 获取介绍有礼--参与用户记录列表
     */
    @RequestMapping(value = "/listAllUser")
    @ResponseBody
    public List<IntroduceUser> listAll(IntroduceUserQuery query) {
        return appUserClient.queryIntroduceAll(query);
    }
    /**
     * 新增介绍有礼记录表
     * @return
     */
    @RequestMapping("/addIntroduce")
    @ResponseBody
    public Object addAppUser(@RequestBody IntroduceRewards introduceRewards){
 
        return introduceClient.addIntroduce(introduceRewards);
    }
}