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.builder.DirectionEnum;
import cn.hme.framework.jdbc.provider.builder.OrderBuilder;
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.DictPlatformMapper;
import cn.tsy.data.idsse.dsds.model.dict.DictPlatform;
import cn.tsy.idsse.dsds.helper.DSDSWebHelper;
import cn.tsy.idsse.dsds.service.dict.DictPlatformService;

@RestController
@RequestMapping("dict/platform")
public class DictPlatformControl  extends AjaxControl {

	@Autowired
	private DictPlatformMapper mPlatform;

	@Autowired
	private DictPlatformService sPlatform;

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

	@RequestMapping("all.htm")
	public Ajax all() {
		return new Ajax(this.mPlatform.allByOrder(OrderBuilder.create().addOrderBy("platform_order",DirectionEnum.DESC)));
	}
	
	@RequestMapping("edit.htm")
	public Ajax edit(DictPlatform platform) {
		DSDSWebHelper.getFrameOptr(true);
		this.sPlatform.editPlatform(platform);
		return new Ajax(platform);
	}
	
	@RequestMapping("delete.htm")
	public Ajax delete(int tsy_id) {
		DSDSWebHelper.getFrameOptr(true);
		this.sPlatform.deletePlatform(tsy_id);
		return new Ajax();
	}
	
	
	
	
	

	
	

}
