package cn.hmsoft.hmplatform.monitor.control;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hmsoft.application.web.Ajax;
import cn.hmsoft.frame.control.FrameControl;
import cn.hmsoft.hmplatform.identity.data.dao.PStdRegDao;
import cn.hmsoft.hmplatform.identity.data.model.PStdRes;

@RestController
public class StdRegControl extends FrameControl {

	@Autowired
	private PStdRegDao daoStd;
	
	@RequestMapping("platform/monitor/std/page")
	public Ajax page(String query, Integer limit, Integer start, String order, String type) {
		return new Ajax(this.daoStd.pageStd(start, limit, query, getQueryOrder(order, type)));
	}
	
	@RequestMapping("platform/monitor/stdreslog/list")
	public Ajax listStdResLog(Integer std_id) {
		return new Ajax(this.daoStd.listMapBySql("select * from p_std_res_log where std_id=? order by res_type,res_time desc", std_id));
	}
	
	@RequestMapping("platform/monitor/stdres/list")
	public Ajax listStdRes(Integer std_id) {
		return new Ajax(this.daoStd.listMapBySql("select * from p_std_res where std_id=? order by res_type,res_date desc", std_id));
	}
	
	@RequestMapping("platform/monitor/stdres/adjust")
	public Ajax adjust(PStdRes res) {
		this.daoStd.updateBySql("update p_std_res set res_plus=? where res_type=? and res_date=? and std_id=?", res.getRes_plus(), 
				res.getRes_type(), res.getRes_date(), res.getStd_id());
		return new Ajax();
	}
}
