package com.dayou.controller;

import com.dayou.dto.TaskRecordDTO;
import com.dayou.entity.Personal;
import com.dayou.workflow.annotation.FinishTask;
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.IPersonalSceneService;
import com.dayou.entity.PersonalScene;
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;

import javax.validation.Valid;

/**
 * 个贷实勘表
 *
 * @author wucl
 * @since 2024-03-01
 */
@RestController
@RequestMapping("personalScene")
@Slf4j
public class PersonalSceneController extends BaseController {
    @Autowired
    private IPersonalSceneService personalSceneService;

    /**
    * 个贷实勘表列表
    */
    @GetMapping("")
    public RestResponse<Page<PersonalScene>> page(PersonalScene personalScene, Page page){
        Page<PersonalScene> pages=personalSceneService.selectPage(page,personalScene);
        return RestResponse.data(pages);
    }

    /**
     * 个贷实勘表详情
     */
    @GetMapping("/{personalId}")
    public RestResponse<PersonalScene> detail(@PathVariable Long personalId){
        PersonalScene xPersonalScene =personalSceneService.detail(personalId);
        return RestResponse.data(xPersonalScene);
     }

    /**
     * 个贷实勘表新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody PersonalScene personalScene) {
        Boolean ret = personalSceneService.add(personalScene);
        return RestResponse.data(ret);
    }

    /**
     * 个贷实勘表更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody PersonalScene personalScene) {
        Boolean ret = personalSceneService.update(personalScene);
        return RestResponse.data(ret);
    }

    /**
     * 个贷实勘表删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = personalSceneService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 个贷业务订单更新
     */
    @FinishTask
    @PutMapping("/scene")
    public RestResponse<Boolean> saveSceneInfo(@RequestBody @Valid TaskRecordDTO<PersonalScene> taskRecordDTO) {
        Boolean ret = personalSceneService.saveSceneInfo(taskRecordDTO);
        return RestResponse.data(ret);
    }

}

