xuhy
2023-03-28 dea785f9fab25a7c68ea890628a39c973c96a935
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
package com.stylefeng.guns.modular.system.controller.general;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.controller.util.LabelReplaceUtil;
import com.stylefeng.guns.modular.system.enums.HtmlTypeEnum;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.THtml;
import com.stylefeng.guns.modular.system.service.ITHtmlService;
 
import java.util.Objects;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2023-03-24 10:50:08
 */
@Controller
@RequestMapping("/tHtml")
public class THtmlController extends BaseController {
 
    private String PREFIX = "/system/tHtml/";
 
    @Autowired
    private ITHtmlService tHtmlService;
 
    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tHtml.html";
    }
 
    /**
     * 跳转到添加
     */
    @RequestMapping("/tHtml_add")
    public String tHtmlAdd() {
        return PREFIX + "tHtml_add.html";
    }
 
    /**
     * 跳转到修改
     */
    @RequestMapping("/tHtml_update/{tHtmlId}")
    public String tHtmlUpdate(@PathVariable Integer tHtmlId, Model model) {
        THtml tHtml = tHtmlService.selectById(tHtmlId);
        model.addAttribute("item",tHtml);
        LogObjectHolder.me().set(tHtml);
        return PREFIX + "tHtml_edit.html";
    }
 
    /**
     * 跳转到积分说明
     */
    @RequestMapping("/integralExplain")
    public String integralExplain(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.INTEGRAL_EXPLAIN.getCode());
        model.addAttribute("html",html);
        return PREFIX + "integralExplain.html";
    }
 
    /**
     * 跳转到佣金规则说明
     */
    @RequestMapping("/commissionRuleExplain")
    public String commissionRuleExplain(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.COMMISSION_RULE_EXPLAIN.getCode());
        model.addAttribute("html",html);
        return PREFIX + "commissionRuleExplain.html";
    }
 
    /**
     * 跳转到行程录音说明
     */
    @RequestMapping("/tripRecordingExplain")
    public String tripRecordingExplain(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.TRIP_RECORDING_EXPLAIN.getCode());
        model.addAttribute("html",html);
        return PREFIX + "tripRecordingExplain.html";
    }
 
    /**
     * 跳转到预估价格说明
     */
    @RequestMapping("/estimatedPriceExplain")
    public String estimatedPriceExplain(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.ESTIMATED_PRICE_EXPLAIN.getCode());
        model.addAttribute("html",html);
        return PREFIX + "estimatedPriceExplain.html";
    }
 
    /**
     * 跳转到起步价说明
     */
    @RequestMapping("/startingFareExplain")
    public String startingFareExplain(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.SPECIFICATION_STARTING_PRICE.getCode());
        model.addAttribute("html",html);
        return PREFIX + "estimatedPriceExplain.html";
    }
 
    /**
     * 跳转到注销协议
     */
    @RequestMapping("/cancellationAgreement")
    public String cancellationAgreement(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.CANCELLATION_AGREEMENT.getCode());
        model.addAttribute("html",html);
        return PREFIX + "cancellationAgreement.html";
    }
 
    /**
     * 跳转到关于我们
     */
    @RequestMapping("/aboutUs")
    public String aboutUs(Model model) {
        THtml html = queryHtmlByType(HtmlTypeEnum.ABOUT_US.getCode());
        model.addAttribute("html",html);
        return PREFIX + "aboutUs.html";
    }
 
    /**
     * 跳转到代驾服务协议与隐私政策保护,法律条款,个人信息处理规则
     */
    @RequestMapping("/agreementExplain")
    public String agentDrivingServiceExplain(Integer type,Model model) {
        THtml one = queryHtmlByType(HtmlTypeEnum.AGENT_DRIVING_SERVICE_EXPLAIN.getCode());
        model.addAttribute("one",one);
        THtml two = queryHtmlByType(HtmlTypeEnum.CLAUSE.getCode());
        model.addAttribute("two",two);
        THtml three = queryHtmlByType(HtmlTypeEnum.PERSONAL_INFORMATION_RULES.getCode());
        model.addAttribute("three",three);
        return PREFIX + "agreementExplain.html";
    }
 
    /**
     * 跳转到加盟基本要求
     */
    @RequestMapping("/requirementsJoinExplain")
    public String requirementsJoinExplain(Model model) {
        THtml tHtml = queryHtmlByType(HtmlTypeEnum.BASIC_REQUIREMENTS_JOINING.getCode());
        JSONObject jsonObject = JSONObject.parseObject(tHtml.getHtml());
        JSONArray rules = jsonObject.getJSONArray("rules");
        JSONArray objects = new JSONArray();
        for (int i = 0; i < rules.size(); i++) {
            JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(rules.get(i)));
            if(i == 0){
                jsonObject1.put("key",0);
            }else {
                jsonObject1.put("key",1);
            }
            objects.add(jsonObject1);
        }
        model.addAttribute("array",objects);
        model.addAttribute("id",tHtml.getId());
        return PREFIX + "requirementsJoinExplain.html";
    }
 
    /**
     * 跳转到代驾服务协议与隐私政策保护,法律条款,个人信息处理规则
     */
    @RequestMapping("/agreement")
    @ResponseBody
    public Object agreement(Integer type) {
        return queryHtmlByType(type);
    }
 
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return tHtmlService.selectList(null);
    }
 
    /**
     * 通过类型查询配置
     */
    @RequestMapping(value = "/queryHtmlByType")
    @ResponseBody
    public THtml queryHtmlByType(Integer type) {
        return tHtmlService.selectOne(new EntityWrapper<THtml>().eq("type", type).last("LIMIT 1"));
    }
 
    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(THtml tHtml) {
        tHtmlService.insert(tHtml);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tHtmlId) {
        tHtmlService.deleteById(tHtmlId);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(THtml tHtml) {
        tHtml.setHtml(LabelReplaceUtil.replace(tHtml.getHtml()));
        tHtmlService.updateById(tHtml);
        return SUCCESS_TIP;
    }
 
    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{tHtmlId}")
    @ResponseBody
    public Object detail(@PathVariable("tHtmlId") Integer tHtmlId) {
        return tHtmlService.selectById(tHtmlId);
    }
}