You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

56 lines
2.2 KiB

package com.fr.plugin.decision.role.auth;
import com.fanruan.api.decision.AuthorityKit;
import com.fanruan.api.decision.role.CustomRoleKit;
import com.fanruan.api.decision.user.UserKit;
import com.fr.decision.webservice.Response;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.RequestBody;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author Zed
* @version 10.0
* Created by Zed on 2020/4/29
*/
@FunctionRecorder
@Controller
public class BatchRoleController {
private static final String DEP = "depost";
private static final String ROLE = "role";
private static final String USER = "user";
private static final String POST = "post";
@RequestMapping(value = "/batch/role", method = RequestMethod.POST)
@ResponseBody
public Response batch(HttpServletRequest req,
HttpServletResponse res,
@RequestBody RequestBean bean) throws Exception {
String id = UserKit.getCurrentUserId(req);
List<String> roleIds = CustomRoleKit.getCustomRoleIds(id, bean.getKeyword());
String roleType = bean.getRoleType();
for (String roleId : roleIds) {
if (DEP.equals(roleType)) {
AuthorityKit.setDepAuth(bean.getRoleId(), bean.getAuthValue(), roleId, bean.getAuthType());
} else if (USER.equals(roleType)) {
AuthorityKit.setUserAuth(bean.getRoleId(), bean.getAuthValue(), roleId, bean.getAuthType());
} else if (ROLE.equals(roleType)) {
AuthorityKit.setCustomRoleAuth(bean.getRoleId(), bean.getAuthValue(), roleId, bean.getAuthType());
} else if (POST.equals(roleType)) {
AuthorityKit.setPostAuth(bean.getRoleId(), bean.getAuthValue(), roleId, bean.getAuthType());
}
}
return Response.success();
}
}