/**
* 文件：RoleAuthController.java
* 版本：1.0.0
* 日期：
* Copyright &reg; 
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;


import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.service.RoleAuthService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>Title: 角色资源权限</p>
 * <p>Description: RoleAuthController  </p>
 * <p>Copyright: Copyright &reg;  </p>
 * <p>Company: </p>
 * @author 
 * @version 1.0.0
 */
@RestController
@RequestMapping("role/auth")
public class RoleAuthController extends BaseCRUDJsonMappingController<RoleAuthService,RoleAuthForm,RoleAuthEntity,Long> {

	public RoleAuthController(){
		super.setFormClass(RoleAuthForm.class);
		super.setModuleDesc("角色资源权限");
	}

	/**
	 * 分配资源
	 */
	@PostMapping(value = "distributionSource")
	public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleAuthForm form) {
		try {
			service.doDistributionSource(form.getQuery());
			JSONObject ret = new JSONObject();
			ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
			return ret.toJSONString();
		} catch (Exception e) {
			log.error("分配角色资源错误", e);
			JSONObject ret = new JSONObject();
			ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
			ret.put(KEY_RESULT_MSG, super.convertException(e));
			return ret.toJSONString();
		}
	}
	
}