package com.bonus.zlpt.bigscreen.controller;

import com.bonus.zlpt.common.core.web.controller.BaseController;
import com.bonus.zlpt.common.core.web.domain.AjaxResult;
import com.bonus.zlpt.bigscreen.domain.MaLeaseInfo;
import com.bonus.zlpt.bigscreen.domain.vo.MaLeaseInfoVo;
import com.bonus.zlpt.bigscreen.service.MaLeaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 租赁信息表(MaLeaseInfo)表控制层
 *
 * @author makejava
 * @since 2023-11-30 15:55:23
 */
@RestController
@RequestMapping("maLeaseInfo")
public class MaLeaseInfoController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private MaLeaseInfoService maLeaseInfoService;

    /**
     * 根据求出租信息查询对应的数量
     * @param maLeaseInfo
     * @return
     */
    @GetMapping("/type-list")
    public AjaxResult typeList(MaLeaseInfo maLeaseInfo)
    {
        List<MaLeaseInfoVo> list = maLeaseInfoService.selectTypeList(maLeaseInfo);
        HashMap<String, Object> map = new HashMap<>();
        for (MaLeaseInfoVo leaseInfoVo : list) {
            if (leaseInfoVo.getType().equals("出租")) {
                map.put("rent", leaseInfoVo);
            } else {
                map.put("wantRent", leaseInfoVo);
            }
        }
        return success(map);
    }
}

