package com.mandi.fendan.controller; import com.mandi.common.Jacksonmethod; import com.mandi.common.SessionMethod; import com.mandi.dao.common.ObjectResult; import com.mandi.dao.common.PageRequest; import com.mandi.dao.common.PageResult; import com.mandi.fendan.mapper.BusinessVehiclePersonMapper; import com.mandi.fendan.persist.BusinessVehiclePerson; import com.sun.org.apache.xpath.internal.operations.Bool; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.stereotype.Controller; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestMapping; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @Controller @RequestMapping("/businessVehiclePerson") public class BusinessVehiclePersonController { @Resource BusinessVehiclePersonMapper businessVehiclePersonMapper; @RequestMapping("/listAll.htm") void listAll(int page, int pageSize, HttpServletResponse re){ Map map = new HashMap(); map.put("pageSize",50); List list = businessVehiclePersonMapper.selectPage(map); PageResult prr= new PageResult<>(); prr.setList(list); String str= Jacksonmethod.tojson(prr, false); SessionMethod.writeresp(re, str); } @RequestMapping("/list.htm") void list(String businessNo, String vehicleId, HttpServletRequest r, HttpServletResponse re){ List list = businessVehiclePersonMapper.selectList(businessNo,vehicleId); PageResult prr= new PageResult<>(); prr.setList(list); String str= Jacksonmethod.tojson(prr, false); SessionMethod.writeresp(re, str); } @RequestMapping("/get.htm") void getById(Long id, HttpServletResponse re){ BusinessVehiclePerson businessVehiclePerson = businessVehiclePersonMapper.selectById(id); ObjectResult prr= new ObjectResult<>(); prr.setItem(businessVehiclePerson); String str= Jacksonmethod.tojson(prr, false); SessionMethod.writeresp(re, str); } @RequestMapping("/update.htm") void update(BusinessVehiclePerson businessVehiclePerson,HttpServletResponse re){ ObjectResult objectResult = new ObjectResult<>(); try { BusinessVehiclePerson old = businessVehiclePersonMapper.selectById(businessVehiclePerson.getId()); businessVehiclePerson.setCreateTime(old.getCreateTime()); businessVehiclePerson.setUpdateTime(DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss")); businessVehiclePersonMapper.update(businessVehiclePerson); objectResult.setCode(0); } catch (Exception e) { objectResult.setCode(1); objectResult.setErrmsg("系统繁忙,请稍后再试!"); } String str= Jacksonmethod.tojson(objectResult, false); SessionMethod.writeresp(re, str); } @RequestMapping("/add.htm") void add(BusinessVehiclePerson businessVehiclePerson,HttpServletResponse re){ ObjectResult objectResult = new ObjectResult<>(); try { businessVehiclePerson.setCreateTime(DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss")); businessVehiclePersonMapper.insert(businessVehiclePerson); objectResult.setCode(0); } catch (Exception e) { objectResult.setCode(1); objectResult.setErrmsg("系统繁忙,请稍后再试!"); } String str= Jacksonmethod.tojson(objectResult, false); SessionMethod.writeresp(re, str); } @RequestMapping("/del.htm") void del(Long id,HttpServletResponse re){ ObjectResult objectResult = new ObjectResult<>(); try { businessVehiclePersonMapper.delete(id); objectResult.setCode(0); } catch (Exception e) { objectResult.setCode(1); objectResult.setErrmsg("系统繁忙,请稍后再试!"); } String str= Jacksonmethod.tojson(objectResult, false); SessionMethod.writeresp(re, str); } }