package cn.iocoder.yudao.module.jx.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.jx.core.controller.BaseController;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolDynamic;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolDynamicService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 行业动态Controller
 *
 * @author ruoyi
 * @date 2024-05-10
 */
@RestController
@RequestMapping("/drivingSchool/system/dynamic")
public class DriveSchoolDynamicController extends BaseController
{
    @Autowired
    private IDriveSchoolDynamicService driveSchoolDynamicService;

    /**
     * 查询行业动态列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolDynamic driveSchoolDynamic)
    {
        if(null == driveSchoolDynamic.getPageNum()){
            driveSchoolDynamic.setPageNum(1);
        }
        if (null == driveSchoolDynamic.getPageSize()){
            driveSchoolDynamic.setPageSize(100);
        }
        Page<DriveSchoolDynamic> page = new Page<>(driveSchoolDynamic.getPageNum(), driveSchoolDynamic.getPageSize());
            IPage<DriveSchoolDynamic> driveSchoolDynamicIPage = driveSchoolDynamicService.selectDriveSchoolDynamicList(driveSchoolDynamic, page);
            return CommonResult.success(driveSchoolDynamicIPage);
        //return getDataTable(list);
    }

    /**
     * 查询行业动态列表
     */
    @GetMapping("/applist")
    public CommonResult applist(DriveSchoolDynamic driveSchoolDynamic)
    {
        List<DriveSchoolDynamic> list = driveSchoolDynamicService.selectDriveSchoolDynamicListAll(driveSchoolDynamic);
        return CommonResult.success(list);
    }

    /**
     * 导出行业动态列表
     */
    //@Log(title = "行业动态", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolDynamic driveSchoolDynamic)
//    {
//        List<DriveSchoolDynamic> list = driveSchoolDynamicService.selectDriveSchoolDynamicList(driveSchoolDynamic);
//        ExcelUtil<DriveSchoolDynamic> util = new ExcelUtil<DriveSchoolDynamic>(DriveSchoolDynamic.class);
//        util.exportExcel(response, list, "行业动态数据");
//    }

    /**
     * 获取行业动态详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolDynamicService.selectDriveSchoolDynamicById(id));
    }

    /**
     * 新增行业动态
     */
    //@Log(title = "行业动态", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolDynamic driveSchoolDynamic)
    {
        return toAjax(driveSchoolDynamicService.insertDriveSchoolDynamic(driveSchoolDynamic));
    }

    /**
     * 修改行业动态
     */
    //@Log(title = "行业动态", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolDynamic driveSchoolDynamic)
    {
        return toAjax(driveSchoolDynamicService.updateDriveSchoolDynamic(driveSchoolDynamic));
    }

    /**
     * 删除行业动态
     */
    //@Log(title = "行业动态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolDynamicService.deleteDriveSchoolDynamicByIds(ids));
    }
}
