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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.entity.DriveSchoolAddress;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.jx.core.controller.BaseController;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolGuide;
import cn.iocoder.yudao.module.jx.service.DriveSchoolGuideService;
import cn.iocoder.yudao.module.jx.vo.DlDriveSchoolGuidePageReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 业务办理指南")
@RestController
@RequestMapping("/jx/driveSchool/guide")
@Validated
public class DriveSchoolGuideController extends BaseController{

    @Resource
    private DriveSchoolGuideService driveSchoolGuideService;

    @PostMapping
    @Operation(summary = "新增业务办理指南")
    @PermitAll
    public CommonResult<String> create(@Valid @RequestBody DriveSchoolGuide driveSchoolGuide) {
        return success(driveSchoolGuideService.save(driveSchoolGuide));
    }

    @PutMapping
    @Operation(summary = "更新业务办理指南")
    @PermitAll
    public CommonResult<Boolean> update(@Valid @RequestBody DriveSchoolGuide driveSchoolGuide) {
        return success(driveSchoolGuideService.updateById(driveSchoolGuide));
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除业务办理指南")
    @PermitAll
    public CommonResult<?> delete(@PathVariable("id") String id) {
        return success(driveSchoolGuideService.removeById(id));
    }

    @GetMapping("/{id}")
    @Operation(summary = "获取业务办理指南详情")
    @PermitAll
    public CommonResult<DriveSchoolGuide> getById(@PathVariable("id") String id) {
        return success(driveSchoolGuideService.getById(id));
    }

    @GetMapping("/page")
    @Operation(summary = "分页查询业务办理指南")
    @PermitAll
    public CommonResult<?> page(
            @Valid DriveSchoolGuide pageReqVO,
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<DriveSchoolGuide> page = new Page<>(pageNo, pageSize);
        return success(driveSchoolGuideService.page(page, Wrappers.<DriveSchoolGuide>lambdaQuery()));
    }

    @GetMapping("/list")
    @Operation(summary = "获取所有业务办理指南")
    @PermitAll
    public CommonResult<List<DriveSchoolGuide>> list() {
        return success(driveSchoolGuideService.list());
    }
}
