package com.xintong.visualinspection.controller;

import javax.validation.Valid;

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

import com.xintong.visualinspection.bean.Constant;
import com.xintong.visualinspection.service.ConstantService;

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

    @Autowired
    private ConstantService constantService;

   
    /**
     * 添加常量
     * @return
     * String
     * @exception
     * @since  1.0.0
     */
    @RequestMapping(value = "/addConstant")
    public String addConstant(@Valid @RequestBody Constant constant, BindingResult result){
    	constantService.insert(constant);
    	return super.returnSuccessResult("添加成功");
    }
    
    /**
     * 修改常量
     * @return
     * String
     * @exception
     * @since  1.0.0
     */
    @RequestMapping(value = "/updateConstant")
    public String updateConstant(@RequestBody Constant constant){
    	constantService.update(constant);
    	return super.returnSuccessResult("修改成功");
    }
    
    /**
     * 删除常量
     * @return
     * String
     * @exception
     * @since  1.0.0
     */
    @RequestMapping(value = "/deleteConstant")
    public String deleteConstant(@RequestBody String id){
    	constantService.delete(Long.parseLong(id));
    	return super.returnSuccessResult("删除成功");
    }
}
