package com.dgtis.dorm.manager.admin.web;

import java.util.Map;

import javax.annotation.Resource;

import com.dgtis.dorm.manager.admin.annotation.LoginAdmin;
import com.dgtis.dorm.manager.db.service.UserMessageService;
import com.dgtis.dorm.manager.db.util.ResponseUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/message")
public class UserMessageController {
	private final Log logger = LogFactory.getLog(UserMessageController.class);

	@Resource UserMessageService messageService;
	
	@RequestMapping("list")
	public Object list (@LoginAdmin Integer adminId,
			String id,
			@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "limit", defaultValue = "10") Integer limit,
			String sort, String order){
		if(adminId == null || id == null)
			return ResponseUtil.fail401();
		Map<String, Object> data = messageService.findUserMessageList(id, page, limit, sort, order);
		return ResponseUtil.ok(data);
	}
}
