package cn.tsy.idsse.dsds.control.dict;

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

import cn.hme.framework.helper.lang.StringHelper;
import cn.hme.framework.jdbc.provider.page.Pageable;
import cn.hme.framework.web.control.Ajax;
import cn.hme.framework.web.control.AjaxControl;
import cn.tsy.data.idsse.dsds.mapper.dict.DictUnitSailMapper;
import cn.tsy.data.idsse.dsds.model.dict.DictUnitSail;
import cn.tsy.idsse.dsds.helper.DSDSWebHelper;
import cn.tsy.idsse.dsds.service.dict.DictUnitSailService;

@RestController
@RequestMapping("dict/unit/sail")
public class DictUnitSailControl  extends AjaxControl{

	@Autowired
	private DictUnitSailMapper mUnitSail;

	@Autowired
	private DictUnitSailService sUnitSail;

	@RequestMapping("page.htm")
	public Ajax page(Integer group, Integer limit, Integer start, String query, String order, String type) {
		order = StringHelper.hasValue(order) ? order : "unit_name";
		Pageable page = this.mUnitSail.sailWithPage(group, start, limit, query, order, type);
		return new Ajax(page);
	}

	@RequestMapping("edit.htm")
	public Ajax edit(DictUnitSail sail) {
		DSDSWebHelper.getFrameOptr(true);
		this.sUnitSail.editUnitSail(sail);
		return new Ajax(sail);
	}
	
	@RequestMapping("delete.htm")
	public Ajax delete(int tsy_id) {
		DSDSWebHelper.getFrameOptr(true);
		this.sUnitSail.deleteUnitSail(tsy_id);
		return new Ajax();
	}
	

}
