package com.dsk.web.controller.business;

import java.util.List;

import com.dsk.common.core.domain.entity.BusinessInfo;
import com.dsk.common.dtos.BusinessInfoDto;
import com.dsk.system.domain.BusinessAddDto;
import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.vo.BusinessBrowseVo;
import com.dsk.system.domain.vo.BusinessListVo;
import com.dsk.system.service.IBusinessInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dsk.common.annotation.Log;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.enums.BusinessType;
import com.dsk.common.core.page.TableDataInfo;

/**
 * 项目详情Controller
 *
 * @author lxl
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/business/info")
public class BusinessInfoController extends BaseController
{
    @Autowired
    private IBusinessInfoService businessInfoService;


    /**
     * 查询所有项目名称(支持模糊查询)
     */
//    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @PostMapping("/query/project")
    public AjaxResult queryprojectName(@RequestBody BusinessListDto dto){
        return AjaxResult.success(businessInfoService.selectProjectName(dto));
    }

    /**
     * 查询项目列表
     */
//    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestBody BusinessListDto dto)
    {
        startPage();
        List<BusinessListVo> list = businessInfoService.selectBusinessInfoList(dto);
        return getDataTable(list);
    }

    /**
     * 查询项目速览
     */
//    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/browse/{businessId}")
    public AjaxResult browse(@PathVariable Integer businessId)
    {
        return success(businessInfoService.browse(businessId));
    }

    /**
     * 获取项目建设内容
     */
//    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/construction/{id}")
    public AjaxResult getConstruction(@PathVariable("id") Integer id)
    {
        return success(businessInfoService.getConstruction(id));
    }

    /**
     * 删除项目
     */
//    @PreAuthorize("@ss.hasPermi('system:info:remove')")
//    @Log(title = "项目详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable(value = "ids",required=false) Long id)
    {
        return toAjax(businessInfoService.deleteBusinessInfoById(id));
    }

    /**
     * 新增项目详情
     */
//    @PreAuthorize("@ss.hasPermi('system:info:add')")
//    @Log(title = "项目详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusinessAddDto dto)
    {
        return businessInfoService.insertBusinessInfo(dto);
    }

    /**
     * 修改项目详情
     */
//    @PreAuthorize("@ss.hasPermi('system:info:edit')")
//    @Log(title = "项目详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusinessInfo businessInfo)
    {
        return toAjax(businessInfoService.updateBusinessInfo(businessInfo));
    }

//    /**
//     * 获取项目详情详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:info:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Integer id)
//    {
//        return success(businessInfoService.selectBusinessInfoById(id));
//    }

//    /**
//     * 导出项目详情列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:info:export')")
//    @Log(title = "项目详情", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BusinessInfo businessInfo)
//    {
//        List<BusinessInfo> list = businessInfoService.selectBusinessInfoList(businessInfo);
//        ExcelUtil<BusinessInfo> util = new ExcelUtil<BusinessInfo>(BusinessInfo.class);
//        util.exportExcel(response, list, "项目详情数据");
//    }

}
