WebReportDataSourceController.java 4.32 KB
package com.lhcredit.project.webbusiness.controller;

import java.util.Date;
import java.util.List;

import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.framework.aspectj.lang.enums.OperatorType;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lhcredit.framework.aspectj.lang.annotation.Log;
import com.lhcredit.framework.aspectj.lang.enums.BusinessType;
import com.lhcredit.project.business.reportDataSource.domain.ReportDataSource;
import com.lhcredit.project.business.reportDataSource.service.IReportDataSourceService;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;


/**
 * 报告数据源信息对外接口
 *
 * @author lhcredit
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/web/reportDataSource")
public class WebReportDataSourceController extends BaseController {
    @Autowired
    private IReportDataSourceService reportDataSourceService;

    /**
     * 查询报告数据源列表接口
     */
    @ApiOperation("查询报告数据源列表")
    @Log(title = "报告数据源", businessType = BusinessType.LIST, operatorType = OperatorType.WEB)
    @GetMapping
    public AjaxResult list(ReportDataSource reportDataSource) {
        startPage();
        reportDataSource.setDelFlag("0");
        List<ReportDataSource> list = reportDataSourceService.changeModel(reportDataSourceService.selectReportDataSourceList(reportDataSource));
        return toAjax(list);
    }

    /**
     * 查询报告数据源详情接口
     */
    @ApiOperation("查询报告数据源详情")
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "int", paramType = "path")
    @Log(title = "报告数据源", businessType = BusinessType.DETAIL, operatorType = OperatorType.WEB)
    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Integer id) {
        ReportDataSource reportDataSource =reportDataSourceService.changeModel(reportDataSourceService.selectReportDataSourceById(id));
        if (StringUtils.isNull(reportDataSource)) {
            return AjaxResult.error("该信息不存在");
        }
        return toAjax(reportDataSource);
    }

    /**
     * 新增保存报告数据源接口
     */
    @ApiOperation("新增报告数据源")
    @ApiImplicitParam(name = "reportDataSource", value = "报告数据源", dataType = "ReportDataSource")
    @Log(title = "报告数据源", businessType = BusinessType.INSERT, operatorType = OperatorType.WEB)
    @PostMapping
    public AjaxResult addSave(ReportDataSource reportDataSource) {
        reportDataSource.setCreateBy(ShiroUtils.getLoginName());
        reportDataSource.setCreateTime(new Date());
        reportDataSource.setUpdateBy(ShiroUtils.getLoginName());
        reportDataSource.setUpdateTime(new Date());
        return toAjax(reportDataSourceService.insertReportDataSource(reportDataSource));
    }

    /**
     * 修改保存报告数据源接口
     */
    @ApiOperation("修改报告数据源")
    @ApiImplicitParam(name = "reportDataSource", value = "报告数据源", dataType = "ReportDataSource")
    @Log(title = "报告数据源", businessType = BusinessType.UPDATE, operatorType = OperatorType.WEB)
    @PutMapping
    public AjaxResult update(ReportDataSource reportDataSource) {
        if (StringUtils.isNull(reportDataSource) || StringUtils.isNull(reportDataSource.getId())){
            return AjaxResult.error("主键id不能为空");
        }
        reportDataSource.setUpdateBy(ShiroUtils.getLoginName());
        reportDataSource.setUpdateTime(new Date());
        return toAjax(reportDataSourceService.updateReportDataSource(reportDataSource));
    }

    /**
     * 删除报告数据源接口
     */
    @ApiOperation("删除报告数据源")
    @ApiImplicitParam(name = "ids", value = "主键id,多条以英文逗号分隔", required = true, dataType = "String", paramType = "path")
    @Log(title = "报告数据源", businessType = BusinessType.DELETE, operatorType = OperatorType.WEB)
    @DeleteMapping("/{ids}")
    public AjaxResult delete(@PathVariable String ids) {
        return toAjax(reportDataSourceService.deleteReportDataSourceByIds(ids));
    }

}