package com.zksy.web.controller.basicData;


import com.zksy.common.core.controller.BaseController;
import com.zksy.system.basicData.domain.CrmFile;
import com.zksy.system.basicData.service.CrmFileService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zksy.utils.SearchUtil;
import com.zksy.common.annotation.Log;
import com.zksy.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 文件管理Controller
 *
 * @author sy
 * @date 2024-05-20
 */
@RestController
@RequestMapping("/crmFile")
@Api(tags = "文件管理", description = "文件管理desc")
public class CrmFileController extends BaseController {

    @Autowired
    private CrmFileService service;

    @GetMapping("/getById/{borrowId}")
    @ApiOperation(value = "文件管理搜索getById")
    public CrmFile getById(@PathVariable String borrowId) {
        return service.getById(borrowId);
    }

    @GetMapping("/findByPage")
    @ApiOperation(value = "文件管理分页")
    public Page findByPage(long pageNum, long pageSize, String conditionJson) throws Exception {
        return service.page(new Page<>(pageNum, pageSize), SearchUtil.parseWhereSql(conditionJson));
    }

    @GetMapping("/getList")
    @ApiOperation(value = "文件管理根据条件查询所有")
    public List<CrmFile> getList(String conditionJson) throws Exception {
        return service.list(SearchUtil.parseWhereSql(conditionJson));
    }

    /**
     * 新增文件管理
     */
    @PostMapping("/save")
    @ApiOperation(value = "文件管理新增")
    @Log(title = "新增文件管理", businessType = BusinessType.INSERT)
    public boolean save(@RequestBody CrmFile crmFile) {
        return service.save(crmFile);
    }

    /**
     * 修改文件管理
     */
    @PostMapping("/updateById")
    @ApiOperation(value = "文件管理修改")
    @Log(title = "修改文件管理", businessType = BusinessType.UPDATE)
    public boolean updateById(@RequestBody CrmFile crmFile) {
        return service.updateById(crmFile);
    }

}

