package com.blueland.ebpm.rest;

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

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.blueland.ebpm.home.dao.HomePageDao;

@RestController
@RequestMapping({ "" })
public class HomePageController {
	@Autowired
	HomePageDao homePageDao;

	/**
	 * 为门户首页星标集成使用
	 * @param owner
	 * @return
	 */
	@RequestMapping(value = "/{owner}/task/count", method=RequestMethod.GET, produces = "application/json;charset=UTF-8")
	public Map<String,Object> getAppTaskCount(@PathVariable String owner,@RequestParam(required=false) String state){
		if(StringUtils.isEmpty(state)) {
			state="1";
		}
		Map<String,Object> result=new HashMap<String,Object>();
		try {
			List tasks=homePageDao.getAppTaskCount(owner,state);
			result.put("returnMsg", "操作成功");
			result.put("returnCode", "200");
			result.put("result", tasks);
		}catch(Exception e) {
			result.put("returnMsg", "操作失败："+e.getMessage());
			result.put("returnCode", "404");
			result.put("result", null);
		}
		return result;
	}
	
	
}
