AgentAction.java
2.75 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
package com.cjs.cms.action.admin;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.cjs.cms.dao.admin.AgentRoleDao;
import com.cjs.cms.dao.user.AgentInfoDao;
import com.cjs.cms.model.admin.AgentRoleInfo;
import com.cjs.cms.model.user.AgentInfo;
import com.cjs.cms.util.lang.JsonUtil;
import com.cjs.cms.util.lang.PageUtils;
/**
* 代理商
*
* @author tongyufu
*
*/
@RestController
@RequestMapping("/admin/agent")
public class AgentAction {
@Autowired
private AgentInfoDao agentInfoDao;
@Autowired
private AgentRoleDao agentRoleDao;
/**查询*/
@RequestMapping("/search")
public String search(@RequestParam Map<String, Object> params) {
PageUtils.processPage(params);
List<AgentRoleInfo> agentrole = agentRoleDao.search(params);
for (AgentRoleInfo agentRoleInfo : agentrole) {
params.put("agentNo", agentRoleInfo.getAgentNo());
AgentInfo agentInfo = agentInfoDao.search(params);
if (agentInfo != null) {
agentRoleInfo.setAgentCode(agentInfo.getFundAccount());
agentRoleInfo.setAgentName(agentInfo.getAgentName());
}
}
return JsonUtil.toPageJson(agentrole, agentRoleDao.searchTotal(params));
}
/**添加*/
@RequestMapping("/addAndUpdateAgentRole")
public String addAndUpdateAgentRole(AgentRoleInfo agentRole) {
String resultCode = "0";
if (agentRole.getId() != null && agentRole.getId() != 0) {
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("agentNo", agentRole.getAgentNo());
AgentInfo agentInfo = agentInfoDao.search(params);
if (agentInfo != null) {
agentRoleDao.updateAgentRole(agentRole);
} else {
resultCode = "-2";
}
} catch (Exception e) {
resultCode = "1";
}
} else {
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("agentNo", agentRole.getAgentNo());
AgentInfo agentInfo = agentInfoDao.search(params);
if (agentInfo != null) {
agentRoleDao.addAgentRole(agentRole);
} else {
resultCode = "-2";
}
} catch (Exception e) {
resultCode = "1";
}
}
return resultCode;
}
}