package com.miaxis.pc.controller.school;

import com.miaxis.common.annotation.Log;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.page.ResponsePageInfo;
import com.miaxis.common.enums.BusinessTypeEnum;
import com.miaxis.school.domain.SchoolInfo;
import com.miaxis.school.service.ISchoolInfoService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【驾校信息】Controller
 *
 * @author miaxis
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/school/info")
@Api(tags={"【PC-驾校信息】"})
public class SchoolInfoController extends BaseController{
    @Autowired
    private ISchoolInfoService schoolInfoService;

    /**
     * 查询驾校信息列表
     */
    @GetMapping("/list")
    @ApiOperation("查询驾校信息列表")
        @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<SchoolInfo> list(@ModelAttribute SchoolInfo schoolInfo){
        startPage();
        List<SchoolInfo> list = schoolInfoService.selectSchoolInfoList(schoolInfo);
        return toResponsePageInfo(list);
    }
    

    /**
     * 获取驾校信息详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取驾校信息详细信息")
    public Response<SchoolInfo> getInfo(
            @ApiParam(name = "id", value = "驾校信息参数", required = true)
            @PathVariable("id") Long id
    ){
        return Response.success(schoolInfoService.getById(id));
    }

    /**
     * 新增驾校信息
     */
    @Log(title = "驾校信息", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    @ApiOperation("新增驾校信息")
    public Response<Integer> add(@RequestBody SchoolInfo schoolInfo){
        return toResponse(schoolInfoService.save(schoolInfo) ? 1 : 0);
    }

    /**
     * 修改驾校信息
     */
    @Log(title = "驾校信息", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    @ApiOperation("修改驾校信息")
    public Response<Integer> edit(@RequestBody SchoolInfo schoolInfo){
        return toResponse(schoolInfoService.updateById(schoolInfo) ? 1 : 0);
    }

    /**
     * 删除驾校信息
     */
//    @Log(title = "驾校信息", businessType = BusinessTypeEnum.DELETE)
//	@DeleteMapping("/{ids}")
//    @ApiOperation("删除驾校信息")
//    public  Response<Integer> remove(
//            @ApiParam(name = "ids", value = "驾校信息ids参数", required = true)
//            @PathVariable Long[] ids
//    ){
//        return toResponse(schoolInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
//    }
}
