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);
|
}
|
}
|