package com.dgtly.member.controller;

import com.dgtly.common.annotation.ApiNoCheckSign;
import com.dgtly.common.annotation.ApiPassToken;
import com.dgtly.common.core.controller.ApiBaseController;
import com.dgtly.common.core.domain.AjaxResult;
import com.dgtly.common.core.domain.ParameterObject;
import com.dgtly.notice.domain.NoticeSupply;
import com.dgtly.notice.service.INoticeSupplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

 /**
  * @descption: 供应管理相关API接口
  * @author LiuLingChao
  * @version 1.0
  * @company 神州数码通用软件（洛阳）有限公司
  * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
  * @date 2020-2-25 11:08
  * @since JDK1.8
  */
@RestController
@RequestMapping("/supply/info")
@ApiPassToken/* 不用验证token  方法上可用*/
@ApiNoCheckSign/* 不用验证 签名 方法上可用*/
public class SupplyInfoController extends ApiBaseController {

    @Autowired
    private INoticeSupplyService iNoticeSupplyService;

    /**
     * @descption: 获取全部供应信息分页列表
     * @param:
     * @return: List集合
     * @auther: LiuLingChao
     * @date: 2020-2-25 11:09
     */
    @PostMapping("/getSupplyInfoAllList")
    public Object getSupplyInfoAllList(){
        ParameterObject obj =  getParameterObject();
        NoticeSupply noticeSupply = obj.parseBean(NoticeSupply.class);
        startPage(obj);/*向分页传递 分页参数*/
        List<NoticeSupply> noticeSupplyList = iNoticeSupplyService.getSupplyInfoAllList(noticeSupply);
        return AjaxResult.success(getDataTable(noticeSupplyList));
    }

    /**
     * @descption: 根据供应id获取供应详细信息
     * @param: 供应id
     * @return: 供应信息实体
     * @auther: LiuLingChao
     * @date: 2020-2-25 11:11
     */
    @PostMapping("/getSupplyInfo")
    public Object getSupplyInfo(){
        ParameterObject obj =  getParameterObject();
        NoticeSupply noticeSupply = obj.parseBean(NoticeSupply.class);
        NoticeSupply noticeSupply1 = iNoticeSupplyService.selectNoticeSupplyById(noticeSupply.getId());
        return AjaxResult.success().putKV("noticeSupply",noticeSupply1);
    }

    /**
     * @descption: 获取最新的供应信息前10条
     * @param:
     * @return: List集合
     * @auther: LiuLingChao
     * @date: 2020-2-25 11:12
     */
    @PostMapping("/getSupplyInfoTenLsit")
    public Object getSupplyInfoTenLsit(){

        List<NoticeSupply> noticeSupplyList = iNoticeSupplyService.getSupplyInfoTenList();
        return AjaxResult.success().putKV("supplyList",noticeSupplyList);
    }
}


