CompanyInvestigationController.java
4.81 KB
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
package com.project.demo.web;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.demo.domain.DataTablePageUtil;
import com.project.demo.domain.Investigate;
import com.project.demo.domain.Result;
import com.project.demo.domain.Users;
import com.project.demo.service.InvestigateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by bert on 2018/7/5.
*/
@Controller
@RequestMapping("investigate")
public class CompanyInvestigationController {
@Autowired
private InvestigateService investigateService;
@RequestMapping(method = RequestMethod.GET)
public String findAll() {
return "/investigate/index";
}
@RequestMapping(value = "/investigateList",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String investigateList(final HttpSession session, final HttpServletRequest request){
Users currentUser = (Users) session.getAttribute("users");
final Map<String,Object> params = new HashMap<>();
DataTablePageUtil<Investigate> dataTable = new DataTablePageUtil<Investigate>(request);
PageHelper.startPage(dataTable.getPage_num(), dataTable.getPage_size());//分页
List<Investigate> investigates = investigateService.search();
PageInfo<Investigate> pageInfo = new PageInfo<>(investigates);
//封装数据给DataTables
dataTable.setDraw(dataTable.getDraw());
dataTable.setData(pageInfo.getList());
dataTable.setRecordsTotal((int)pageInfo.getTotal());
dataTable.setRecordsFiltered(dataTable.getRecordsTotal());
//返回数据到页面
String jsonObject = JSONObject.toJSONString(dataTable);
return jsonObject;
}
@RequestMapping(value = "/create")
public String create() {
return "/investigate/new";
}
// id companyName name job mobile personnelMatters finance information marketing administration customerManager managerMobile managerEmail
@RequestMapping(value = "/new", method = RequestMethod.POST)
public String save(final HttpSession session, @RequestParam String companyName,@RequestParam String name,
@RequestParam String job,@RequestParam String mobile,@RequestParam String personnelMatters,
@RequestParam String finance, @RequestParam String information, @RequestParam String marketing,
@RequestParam String administration){
Users users = (Users)session.getAttribute("users");
Investigate investigate = new Investigate();
investigate.setCompanyName(companyName);
investigate.setName(name);
investigate.setJob(job);
investigate.setMobile(mobile);
investigate.setPersonnelMatters(personnelMatters);
investigate.setFinance(finance);
investigate.setInformation(information);
investigate.setMarketing(marketing);
investigate.setAdministration(administration);
investigate.setCustomerManager(users.getName());
investigate.setManagerMobile(users.getMobile());
// investigate.setManagerEmail(managerEmail);
investigate.setUserId(users.getId());
investigateService.save(investigate);
return "redirect:/investigate";
}
@RequestMapping(value = "/isExist",method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public Result isExist(Model model, @RequestParam String mobile){
Result result = new Result();
result.setMessage("<font color='green'>添加成功</font>");
result.setSuccess(true);
return result;
}
@RequestMapping(value = "/{companyId}/details", method = RequestMethod.GET)
public String showDetails(final HttpSession session, @PathVariable Integer companyId, Model model)
{
//通过companyId查询相关信息
System.out.println("details:" + companyId);
Investigate investigate = investigateService.searchDetails(companyId);
System.out.println("investigate:"+investigate);
model.addAttribute("personnelMatters",investigate.getPersonnelMatters());//人事
model.addAttribute("finance",investigate.getFinance());
model.addAttribute("information",investigate.getInformation());
model.addAttribute("marking",investigate.getMarketing());
model.addAttribute("administration",investigate.getAdministration());
return "/investigate/details";
}
}