hjg
2023-11-17 3780c5e65b05bf23020810798babc6d20311fa79
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
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<BusinessVehiclePerson> list = businessVehiclePersonMapper.selectPage(map);
        PageResult<BusinessVehiclePerson> 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<BusinessVehiclePerson> list = businessVehiclePersonMapper.selectList(businessNo,vehicleId);
        PageResult<BusinessVehiclePerson> 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<BusinessVehiclePerson> 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<Boolean> 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<Boolean> 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<Boolean> 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);
    }
}