package io.renren.modules.business.controller;

        import io.renren.common.utils.PageUtils;
        import io.renren.common.utils.R;
        import io.renren.modules.business.entity.BusinessDictEntity;
        import io.renren.modules.business.entity.BusinessProjectEntity;
        import io.renren.modules.business.service.*;
        import org.apache.shiro.authz.annotation.RequiresPermissions;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.PathVariable;
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.bind.annotation.RequestParam;
        import org.springframework.web.bind.annotation.RestController;

        import java.util.List;
        import java.util.Map;

/**
 * @author lsr
 * @version 2022/8/24
 * 合同跟踪
 */
@RestController
@RequestMapping("business/businesssearchbyhtgz")
public class BusinessSearchByHTGZcontroller {

    @Autowired
    private BusinessSearchByLxService businessSearchByLxService;
    @Autowired
    private BusinessSearchByHTGZService businessSearchByHTGZService;
    @Autowired
    private BusinessContractService businessContractService;
    @Autowired
    private BusinessProjectService businessProjectService;
    @Autowired
    private BusinessDictService businessDictService;

    /**
     * 列表
     * @param params
     * @return
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:businesssearchbyhtgz:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = businessContractService.queryList(params);
        return R.ok().put("page", page);
    }

    /**
     * 列表
     * @return
     */
    @RequestMapping("/contractInfo/{contractId}")
    @RequiresPermissions("business:businesssearchbyhtgz:list")
    public R contractInfo(@PathVariable("contractId") Integer contractId) {
        Map<String, Object> page = businessSearchByHTGZService.getAllInfoByConId(contractId);
        return R.ok().put("page", page);
    }

    /**
     * 获取字典信息
     */
    @RequestMapping("/dictList")
    @RequiresPermissions("business:businesssearchbyhtgz:list")
    public R dictList(@RequestParam Map<String, Object> params){
        // PageUtils page = businessDictService.queryPage(params);
        List<BusinessDictEntity> businessDictEntity = businessDictService.listWithTree();
        return R.ok().put("data", businessDictEntity);
    }

    /**
     * 根据立项Id  获取所有相关的数据
     */
    @RequestMapping("/projectInfo/{projectId}")
    @RequiresPermissions("business:businesssearchbyhtgz:list")
    public R projectInfo(@PathVariable("projectId") Integer projectId){
        Map<String, Object> page = businessSearchByLxService.getAllInfoById(projectId);
        return R.ok().put("page", page);
    }

    /**
     * 根据传入的ids查询ids含有的所有的项目信息
     */
    @RequestMapping("/peojectList/{ids}")
    @RequiresPermissions("business:businesssearchbyhtgz:list")
    public R peojectList(@PathVariable("ids") String ids){
        //System.out.println(params);
        List<BusinessProjectEntity> page = businessProjectService.queryPerojectList(ids);
        return R.ok().put("page", page);
    }
}
