liujie
9 天以前 536ef422b4f3d8bd0179fa664444a467913616c1
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.stylefeng.guns.modular.shunfeng.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.modular.shunfeng.model.AppParamRide;
import com.stylefeng.guns.modular.shunfeng.service.IAppParamRideService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 顺风车设置控制器
 * @Date 2020-04-26 10:14:53
 */
@Controller
@RequestMapping("/appParamRide")
public class AppParamRideController extends BaseController {
 
    private String PREFIX = "/shunfeng/appParamRide/";
 
    @Autowired
    private IAppParamRideService appParamRideService;
 
    /**
     * 跳转到顺风车设置首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "appParamRide.html";
    }
 
    /**
     * 跳转到添加顺风车设置
     */
    @RequestMapping("/appParamRide_add")
    public String appParamRideAdd() {
        return PREFIX + "appParamRide_add.html";
    }
 
    /**
     * 跳转到修改顺风车设置
     */
    @RequestMapping("/appParamRide_update/{appParamRideId}")
    public String appParamRideUpdate(@PathVariable Integer appParamRideId, Model model) {
        AppParamRide appParamRide = appParamRideService.selectById(appParamRideId);
        model.addAttribute("item",appParamRide);
        LogObjectHolder.me().set(appParamRide);
        return PREFIX + "appParamRide_edit.html";
    }
    /**
     * 获取设置列表
     * @param type 1价格设置,2平台抽成,3乘客退单,4司机退单
     */
    @RequestMapping(value = "/getContentByType")
    @ResponseBody
    public Object list(Integer type) {
        List<AppParamRide> paramList=new ArrayList<>();
        if(type==1){//价格设置
            paramList= appParamRideService.selectList(new EntityWrapper<AppParamRide>().in("type","1"));
        }else if(type==2){//平台抽成
            paramList= appParamRideService.selectList(new EntityWrapper<AppParamRide>().in("type","2"));
        }else if(type==3){//乘客退单
            paramList= appParamRideService.selectList(new EntityWrapper<AppParamRide>().in("type","3"));
        }else if(type==4){//司机退单
            paramList= appParamRideService.selectList(new EntityWrapper<AppParamRide>().in("type","4"));
        }
        return paramList;
    }
    /**
     * 获取顺风车设置列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return appParamRideService.selectList(null);
    }
 
    /**
     * 新增顺风车设置
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(AppParamRide appParamRide) {
        appParamRideService.insert(appParamRide);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除顺风车设置
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer appParamRideId) {
        appParamRideService.deleteById(appParamRideId);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改顺风车设置
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(AppParamRide appParamRide) {
        if(appParamRide.getType()==1){//价格设置需要单独设置
            String[] contexts=appParamRide.getContext().split("-");
            for(int i = 1;i<6;i++){
                appParamRide.setId(i);
                appParamRide.setDistanceType(i);
                appParamRide.setContext(contexts[i-1]);
                appParamRideService.updateById(appParamRide);
            }
        }else {
            appParamRide.setId(appParamRide.getType()+4);
            appParamRideService.updateById(appParamRide);
        }
 
        return SUCCESS_TIP;
    }
 
    /**
     * 顺风车设置详情
     */
    @RequestMapping(value = "/detail/{appParamRideId}")
    @ResponseBody
    public Object detail(@PathVariable("appParamRideId") Integer appParamRideId) {
        return appParamRideService.selectById(appParamRideId);
    }
}