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.DictUnitShareMapper;
import cn.tsy.data.idsse.dsds.model.dict.DictUnitShare;
import cn.tsy.idsse.dsds.helper.DSDSWebHelper;
import cn.tsy.idsse.dsds.service.dict.DictUnitShareService;

@RestController
@RequestMapping("dict/unit/share")
public class DictUnitShareControl  extends AjaxControl{

	@Autowired
	private DictUnitShareMapper mUnitShare;

	@Autowired
	private DictUnitShareService sUnitShare;

	@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.mUnitShare.shareWithPage(group, start, limit, query, order, type);
		return new Ajax(page);
	}

	@RequestMapping("edit.htm")
	public Ajax edit(DictUnitShare sail) {
		DSDSWebHelper.getFrameOptr(true);
		this.sUnitShare.editUnitShare(sail);
		return new Ajax(sail);
	}
	
	@RequestMapping("delete.htm")
	public Ajax delete(int tsy_id) {
		DSDSWebHelper.getFrameOptr(true);
		this.sUnitShare.deleteUnitShare(tsy_id);
		return new Ajax();
	}
	

}
