package com.ruoyi.web.controller.system.count;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdPropertyInfo;
import com.ruoyi.system.domain.TdPropertyManager;
import com.ruoyi.system.service.ITdPropertyInfoService;
import com.ruoyi.system.service.ITdPropertyManagerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/system/propertynum")
public class SysPropertynumController extends BaseController {
    private String prefix = "system/property/propertynum";
    @Autowired
    private ITdPropertyManagerService tdPropertyManagerService;
    @Autowired
    private ITdPropertyInfoService tdPropertyInfoService;

    @RequiresPermissions("system:propertynum:view")
    @GetMapping()
    public String property()
    {
        return prefix + "/propertynum";
    }

    /**
     * 查询资产登记列表
     */
    @RequiresPermissions("system:propertynum:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TdPropertyManager tdPropertyManager)
    {
        startPage();
        List<TdPropertyManager> list = tdPropertyManagerService.selectTdPropertyManagerList(tdPropertyManager);
        return getDataTable(list);
    }

    /**
     * 打印界面
     */
    @RequiresPermissions("system:propertynum:print")
    @GetMapping("/print/{useId}")
    @Log(title = "资产设备统计", businessType = BusinessType.PRINT)
    public String print(@PathVariable("useId") String useId, ModelMap mmap)
    {
        List<TdPropertyInfo> tdPropertyInfos = tdPropertyInfoService.selectTdPropertyInfoByUseId(useId);
        TdPropertyManager tdPropertyManager = tdPropertyManagerService.selectTdPropertyManagerByUseId(useId);
        mmap.put("tdPropertyInfos", tdPropertyInfos);
        mmap.put("tdPropertyManager", tdPropertyManager);
        mmap.put("sysuser", getSysUser());
        return prefix + "/print";
    }
}
