|
|
@@ -1,10 +1,9 @@
|
|
|
package com.xintong.visualinspection.controller;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -14,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.xintong.visualinspection.bean.Role;
|
|
|
-import com.xintong.visualinspection.bean.User;
|
|
|
import com.xintong.visualinspection.err.BusinessException;
|
|
|
import com.xintong.visualinspection.service.RoleService;
|
|
|
|
|
|
@@ -100,39 +98,68 @@ public class RoleController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // TODO 待完成
|
|
|
@RequestMapping(value = "/roleBindPermission/{roleId}/{permissions}", method = RequestMethod.PUT, produces = "application/json;charset=UTF-8")
|
|
|
public String roleBindPermission(@PathVariable Integer roleId, @PathVariable String permissions) {
|
|
|
+ String[] permissionids = permissions.split(",");
|
|
|
+ List<Integer> pids = new ArrayList<>();
|
|
|
+ for (String id : permissionids) {
|
|
|
+ if (!id.isEmpty()) {
|
|
|
+ try {
|
|
|
+ Integer idt = Integer.parseInt(id);
|
|
|
+ pids.add(idt);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException(20001);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Integer id : pids) {
|
|
|
+ roleService.roleBindPermission(roleId, id);
|
|
|
+ }
|
|
|
|
|
|
- return returnResult(0, "获取成功", null);
|
|
|
+ return returnResult(0, "绑定成功", null);
|
|
|
}
|
|
|
|
|
|
- // TODO 待完成
|
|
|
@RequestMapping(value = "/roleBindUser/{roleId}/{users}", method = RequestMethod.PUT, produces = "application/json;charset=UTF-8")
|
|
|
public String roleBindUser(@PathVariable Integer roleId, @PathVariable String users) {
|
|
|
-
|
|
|
- return returnResult(0, "获取成功", null);
|
|
|
+ String[] userids = users.split(",");
|
|
|
+ List<Integer> uids = new ArrayList<>();
|
|
|
+ for (String id : userids) {
|
|
|
+ if (!id.isEmpty()) {
|
|
|
+ try {
|
|
|
+ Integer idt = Integer.parseInt(id);
|
|
|
+ uids.add(idt);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException(20001);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Integer id : uids) {
|
|
|
+ roleService.roleBindUser(roleId, id);
|
|
|
+ }
|
|
|
+ return returnResult(0, "绑定成功", null);
|
|
|
}
|
|
|
|
|
|
- // TODO 待完成
|
|
|
@RequestMapping(value = "/getRoleByDept/{deptId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
public String getRoleByDept(@PathVariable Integer deptId) {
|
|
|
|
|
|
- return returnResult(0, "获取成功", null);
|
|
|
+ List<Role> roles = roleService.getRoleByDept(deptId);
|
|
|
+
|
|
|
+ return returnResult(0, "获取成功", roles);
|
|
|
}
|
|
|
|
|
|
- // TODO 待完成
|
|
|
@RequestMapping(value = "/getRoleByUser/{userId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
public String getRoleByUser(@PathVariable Integer userId) {
|
|
|
|
|
|
- return returnResult(0, "获取成功", null);
|
|
|
+ List<Role> roles = roleService.getRoleByUser(userId);
|
|
|
+
|
|
|
+ return returnResult(0, "获取成功", roles);
|
|
|
}
|
|
|
|
|
|
- // TODO 待完成
|
|
|
@RequestMapping(value = "/getRoleByPosition/{positionId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
public String getRoleByPosition(@PathVariable Integer positionId) {
|
|
|
+ List<Role> roles = roleService.getRoleByPosition(positionId);
|
|
|
|
|
|
- return returnResult(0, "获取成功", null);
|
|
|
+ return returnResult(0, "获取成功", roles);
|
|
|
}
|
|
|
|
|
|
}
|