package com.jeeplus.modules.API.works.moduleChoose;

import java.util.List;

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

import com.jeeplus.modules.utils.ErrorCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.modules.dao.ModuleChooseDao;
import com.jeeplus.modules.modules.entity.ModuleChoose;
import com.jeeplus.modules.sys.entity.User;

@Controller
@RequestMapping(value = "${frontPath}/moduleChoose")
public class moduleChooseInterfaceCortroller extends BaseController {

	@Autowired
	private ModuleChooseDao moduleChooseDao;

	@ResponseBody
	@RequestMapping(value = "getModuleChoose", method = RequestMethod.GET)
	public AjaxJson getModuleChoose(String userId, HttpServletRequest request, HttpServletResponse response) {
		AjaxJson json = new AjaxJson();
		User user = new User();
		user.setId(userId);
		ModuleChoose mc = new ModuleChoose();
		mc.setUser(user);
		List<ModuleChoose> list = moduleChooseDao.findList(mc);
		json.put("data", list);
		json.setErrorCode(ErrorCode.code_1004);
		return json;
	}

	@ResponseBody
	@RequestMapping(value = "modifyModuleChoose", method = RequestMethod.GET)
	public AjaxJson modifyModuleChoose(String userId, String moduleId,HttpServletRequest request, HttpServletResponse response) {
		AjaxJson json = new AjaxJson();
		User user = new User();
		user.setId(userId);
		ModuleChoose mc = new ModuleChoose();
		mc.setUser(user);
		mc.setModuleId(moduleId);
		moduleChooseDao.update(mc);
		json.setMsg("修改模块成功");
		json.setErrorCode(ErrorCode.code_1004);
		return json;
	}

}
