package com.five.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.five.bean.Company;
import com.five.bean.MoneyDTO;
import com.five.mapper.CompanyMapper;
import com.five.vo.JsonResult;

@CrossOrigin()
@Controller
@Transactional
@RequestMapping(value="five")
public class TestController {
	
	@Resource(name="companyMapper")
    private CompanyMapper companyMapper;
	
    @RequestMapping(value = "/list",method=RequestMethod.GET)
    @ResponseBody
    public List<Company> listAllCompay(HttpServletRequest request) {
    	List<Company> list = companyMapper.listAll();
    	System.out.println(list.size());
        return list;
    }
    
    @RequestMapping(value="/saveCompany",method=RequestMethod.POST)
    @ResponseBody
    public JsonResult saveCompany(@ModelAttribute MoneyDTO dto) {
    	System.out.println(dto.getMoney()+dto.getMoneyType());
    	return JsonResult.sMsg("保存成功");
    }

}
