RoleAction.java
2.29 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
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.RoleDao;
import com.cjs.cms.model.admin.RoleInfo;
import com.cjs.cms.util.lang.JsonUtil;
import com.cjs.cms.util.lang.PageUtils;
/**
* 角色操作
*
* @author kongmingke
*
*/
@RestController
@RequestMapping("/role")
public class RoleAction {
@Autowired
private RoleDao roleDao;
/** 查询角色 */
@RequestMapping("/search")
public String searchRoleAll(@RequestParam Map<String, Object> params) {
PageUtils.processPage(params);
return JsonUtil.toPageJson(roleDao.search(params), roleDao.searchCount());
}
/**查询所有角色名称*/
@RequestMapping("/searchRoleName")
public List<RoleInfo> searchRoleName() {
return roleDao.searchRoleName();
}
/**查询机构会员角色*/
@RequestMapping("/searchAgentRole")
public List<RoleInfo> searchAgentRole() {
return roleDao.searchRoleByName();
}
/** 添加/修改角色 */
@RequestMapping("add")
public void addRole(RoleInfo roleInfo, String fid) {
// 修改
if (roleInfo.getId() != null) {
roleDao.updateRole(roleInfo);
roleDao.deleteRole_function(roleInfo.getId());
} else {
// 添加
roleDao.addRole(roleInfo);
}
Map<String, Integer> map = new HashMap<String, Integer>();
String[] f = fid.split(",");
if (f.length > 0) {
roleDao.deleteRole_function(roleInfo.getId());
for (int j = 0; j < f.length; j++) {
map.put("functionId", Integer.parseInt(f[j]));
map.put("roleId", roleInfo.getId());
roleDao.addRole_function(map);
}
}
}
/**删除角色*/
@RequestMapping("/delete")
public void deleteRole(String ids) {
for (String id : ids.split(",")) {
roleDao.deleteRole(Integer.parseInt(id));
roleDao.deleteRole_function(Integer.parseInt(id));
}
}
}