package com.uas.finance.controller;

import com.uas.finance.model.AccountApplyAttach;
import com.uas.finance.service.AccountApplyAttachService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 应收账款转让控制层
 * created by shicr on 2018/1/30
 **/
@RequestMapping("/accountapply")
@RestController
public class AccountApplyAttachController {

    private Logger logger = LoggerFactory.getLogger(AccountApplyAttachController.class);

    @Autowired
    private AccountApplyAttachService accountApplyAttachService;

    /**
     * 应收账款附件保存
     *
     * @param attach
     * @return
     */
    @RequestMapping(value = "/attachsave", method = RequestMethod.POST)
    public AccountApplyAttach save(MultipartFile file, AccountApplyAttach attach) {
        logger.info("应收账款附件保存","success");
        return accountApplyAttachService.save(file, attach);
    }

    /**
     * 删除附件
     * @param id
     */
    @RequestMapping(value = "/attachdelete",method = RequestMethod.POST)
    public void delete(Long id){
        logger.info("删除附件","success");
        accountApplyAttachService.delete(id);
    }

    /**
     * 查找某出账单下所有附件
     *
     * @param aaid
     * @return
     */
    @RequestMapping(value = "/findByAaid", method = RequestMethod.GET)
    public List<AccountApplyAttach> findByAaid(Long aaid) {
        logger.info("查找出某账单下所有附件", "success");
        List<AccountApplyAttach> list = accountApplyAttachService.findByAaid(aaid);
        return list;
    }


}
