package com.dayou.controller;

import com.dayou.dto.AETargetListSelectDTO;
import com.dayou.dto.TaskRecordDTO;
import com.dayou.vo.AssetsEvaluationTargetVO;
import com.dayou.workflow.annotation.FinishTask;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IAssetsEvaluationTargetService;
import com.dayou.entity.AssetsEvaluationTarget;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;
/**
 * 资产评估对象表
 *
 * @author GouGengquan
 * @since 2024-03-28
 */
@RestController
@RequestMapping("assetsEvaluationTarget")
@Slf4j
public class AssetsEvaluationTargetController extends BaseController {
    @Autowired
    private IAssetsEvaluationTargetService assetsEvaluationTargetService;

    /**
     * 根据资产业务id获取资产业务评估对象集合
     * @param dto 查询dto
     * @return RestResponse<List<AssetsEvaluationTargetVO>>
     */
    @GetMapping("/getAETargetListByAssetsId")
    public RestResponse<List<AssetsEvaluationTargetVO>> getAETargetListByAssetsId(AETargetListSelectDTO dto) {
        return RestResponse.data(assetsEvaluationTargetService.getAETargetListByAssetsId(dto.getBusinessId(), dto.getStatementNo(), dto.getReportNo()));
    }

    /**
    * 资产评估对象表列表
    */
    @GetMapping("")
    public RestResponse<Page<AssetsEvaluationTarget>> page(AssetsEvaluationTarget assetsEvaluationTarget, Page page){
        Page<AssetsEvaluationTarget> pages=assetsEvaluationTargetService.selectPage(page,assetsEvaluationTarget);
        return RestResponse.data(pages);
    }

    /**
     * 资产评估对象表详情
     */
    @GetMapping("detail/{id}")
    public RestResponse<AssetsEvaluationTarget> detail(@PathVariable Long id){
        AssetsEvaluationTarget xAssetsEvaluationTarget =assetsEvaluationTargetService.detail(id);
        return RestResponse.data(xAssetsEvaluationTarget);
     }

    /**
     * 资产评估对象表新增
     */
    @FinishTask
    @PostMapping("/save")
    public RestResponse<Boolean> save(@RequestBody TaskRecordDTO<AssetsEvaluationTarget> taskRecordDTO) {
        Boolean ret = assetsEvaluationTargetService.add(taskRecordDTO.getTaskData());
        return RestResponse.data(ret);
    }

    /**
     * 资产评估对象表更新
     */
    @PutMapping("/update")
    public RestResponse<Boolean> update(@RequestBody AssetsEvaluationTarget assetsEvaluationTarget) {
        Boolean ret = assetsEvaluationTargetService.update(assetsEvaluationTarget);
        return RestResponse.data(ret);
    }

    /**
     * 资产评估对象表删除
     */
    @DeleteMapping("delete/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = assetsEvaluationTargetService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 评估对象审核定价
     * @param assetsEvaluationTarget 审核定价信息
     * @return RestResponse<Boolean>
     */
    @PutMapping("/checkValue")
    public RestResponse<Boolean> checkValue(@RequestBody AssetsEvaluationTarget assetsEvaluationTarget) {
        return RestResponse.data(assetsEvaluationTargetService.checkValue(assetsEvaluationTarget));
    }

}

