package org.cs.web.message;

import java.util.List;
import java.util.Map;

import org.cs.core.ctl.BaseCtl;
import org.cs.mgr.user.model.MgmMessage;
import org.cs.mgr.user.service.IMgmMessageService;
import org.cs.util.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;


/** 
 * 
 * @ClassName:  
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:28:55
 */
@Controller
@RequestMapping("web/messageWebCtl")
public class MessageWebCtl extends BaseCtl {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	public IMgmMessageService mgmMessageService;
	
	/**
	 * 
	 * <p>消息列表</p>
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("message")
	public String message(@RequestParam(required=false)String userId,ModelMap mm){
		List<MgmMessage> lists=mgmMessageService.getMgmMessageList(userId);
		mm.put("lists", lists);
		mm.put("USER_ID", userId);
		return "app/message";	
	} 

	/**
	 * 
	 * <p>修改消息状态为已读</p>
	 * @return
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping("/updateMgmMessageState")
	public JSONObject updateMgmMessageState(String id){
		JSONObject json = new JSONObject();
		try {
			json = mgmMessageService.updateMgmMessageState(id);
		} catch (Exception e) {
			json = getJson(0, "","修改失败");
		}
		return json;
	}
}

