package com.stylefeng.guns.modular.system.controller.general; import com.baomidou.mybatisplus.plugins.Page; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.base.tips.ErrorTip; import com.stylefeng.guns.core.common.constant.factory.PageFactory; import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.modular.system.model.TDriverTeam; import com.stylefeng.guns.modular.system.service.ITDriverTeamService; 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.Date; import java.util.Map; /** * 车队管理控制器 * @author yxh * @date 2021年04月12日 13:58 */ @Controller @RequestMapping("/tDriverTeam") public class TDriverTeamController extends BaseController { private String PREFIX = "/system/tDriverTeam/"; @Autowired private ITDriverTeamService tDriverTeamService; /** * 跳转到车队管理首页 */ @RequestMapping("") public String index() { return PREFIX + "tDriverTeam.html"; } /** * 跳转到添加车队管理 */ @RequestMapping("/driverTeam_add") public String driverTeamAdd() { return PREFIX + "tDriverTeam_add.html"; } /** * 跳转到修改车队管理 */ @RequestMapping("/driverTeam_update/{driverTeamId}") public String driverTeamUpdate(@PathVariable Integer driverTeamId, Model model) { TDriverTeam tDriverTeam = tDriverTeamService.selectById(driverTeamId); model.addAttribute("item",tDriverTeam); LogObjectHolder.me().set(tDriverTeam); return PREFIX + "tDriverTeam_edit.html"; } /** * 获取车队管理列表 */ @RequestMapping(value = "/list") @ResponseBody public Object list(String teamName) { Page> page = new PageFactory>().defaultPage(); page.setRecords(tDriverTeamService.findPage(page,teamName)); return super.packForBT(page); } /** * 新增车队管理 */ @RequestMapping(value = "/add") @ResponseBody public Object add(TDriverTeam tDriverTeam) { //检查车队名称是否被使用 TDriverTeam oldTDriverTem=tDriverTeamService.findByTeamName(tDriverTeam.getTeamName()); if(null!=oldTDriverTem){ return new ErrorTip(400,"当前车队已经存在!"); } tDriverTeam.setState(1); tDriverTeam.setInsertTime(new Date()); tDriverTeam.setInsertUser(ShiroKit.getUser().getId()); tDriverTeamService.insert(tDriverTeam); return SUCCESS_TIP; } /** * 删除车队管理 */ @RequestMapping(value = "/delete") @ResponseBody public Object delete(@RequestParam Integer driverTeamId) { //逻辑删除 TDriverTeam old=tDriverTeamService.selectById(driverTeamId); old.setState(3); old.setUpdateUser(ShiroKit.getUser().getId()); tDriverTeamService.updateById(old); return SUCCESS_TIP; } /** * 修改车队管理 */ @RequestMapping(value = "/update") @ResponseBody public Object update(TDriverTeam driverTeam) { //检查车队名称是否被使用 TDriverTeam oldTDriverTem=tDriverTeamService.findByTeamName(driverTeam.getTeamName()); if(null!=oldTDriverTem && !oldTDriverTem.getId().equals(driverTeam.getId())){ return new ErrorTip(400,"当前车队名已经存在!"); } driverTeam.setUpdateTime(new Date()); driverTeam.setUpdateUser(ShiroKit.getUser().getId()); driverTeam.setState(2); tDriverTeamService.updateById(driverTeam); return SUCCESS_TIP; } /** * 车队管理详情 */ @RequestMapping(value = "/detail/{driverTeamId}") @ResponseBody public Object detail(@PathVariable("driverTeamId") Integer driverTeamId) { return tDriverTeamService.selectById(driverTeamId); } /** * 查询所有的车队 * @author yxh * @date 2021/4/13 14:04 * @return java.lang.Object */ @RequestMapping(value = "/findAllList") @ResponseBody public Object findAllList(){ return tDriverTeamService.findAllList(); } }