package com.xintong.visualinspection.controller;

import javax.validation.Valid;

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

import com.xintong.system.err.BusinessException;
import com.xintong.visualinspection.bean.CheckItem;
import com.xintong.visualinspection.service.CheckRuleItemService;

/**
 * 文件名：CheckRuleIem
 * 版本信息：日期：2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
 */
@RestController
@RequestMapping("/checkRuleItem")
public class CheckRuleItemController extends BaseController {

	@Autowired
	private CheckRuleItemService checkRuleItemService ;
	
	/**
     * 增加考核项
     * @return
     * String
     * @exception
     * @since  1.0.0
     */
    @RequestMapping(value = "/add")
    public String add(@Valid @RequestBody CheckItem checkItem){
    	if(checkItem.getId()==null && checkItem.getRule_id()==null){
    		throw new BusinessException(20002);
    	}
    	checkRuleItemService.insert(checkItem);
    	return super.returnSuccessResult("增加成功");
    }
    
    /**
     * 删除考核项
     * @return
     * String
     * @exception
     * @since  1.0.0
     */
    @RequestMapping(value = "/delete")
    public String delete(@RequestBody CheckItem checkItem){
    	if(checkItem.getId() ==null && checkItem.getRule_id()==null){
    		throw new BusinessException(20002);
    	}
    	checkRuleItemService.delete(checkItem);
    	return super.returnSuccessResult("删除成功");
    }
}
