package com.zksy.park.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zksy.common.annotation.Log;
import com.zksy.common.core.domain.Result;
import com.zksy.common.enums.BusinessType;
import com.zksy.common.utils.SearchUtil;
import com.zksy.park.domain.ParkInfo;
import com.zksy.park.domain.dto.PackInfoDto;
import com.zksy.park.service.ParkInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * @version 1.0
 * @project dh-server-micro
 * @description 园区信息
 * @date 2024/12/23 08:42:12
 */
@RestController
@RequestMapping("/parkInfo")
@Api(tags = "园区信息", description = "园区信息desc")
public class ParkInfoController {

    @Autowired
    private ParkInfoService service;

    @GetMapping("/getById")
    @ApiOperation(value = "园区信息搜索getById")
    public Result getById(String id) {
        return service.getByIdWithFile(id);
    }

    @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 Result getList(String conditionJson) throws Exception {
        return Result.ok(service.list(SearchUtil.parseWhereSql(conditionJson)));
    }

    @PostMapping("/save")
    @ApiOperation(value = "园区信息新增")
    @Log(title = "新增园区信息", businessType = BusinessType.INSERT)
    public Result<Object> save(@ModelAttribute PackInfoDto dto) {
        return service.saveParkInfo(dto);
    }

    @PutMapping("/updateById")
    @ApiOperation(value = "园区信息修改")
    @Log(title = "修改园区信息", businessType = BusinessType.UPDATE)
    public Result<String> updateById(@ModelAttribute PackInfoDto dto) {
        return service.updateByParkInfoId(dto);
    }

    @DeleteMapping("/deleteById")
    @ApiOperation(value = "园区信息删除")
    @Log(title = "修改园区信息", businessType = BusinessType.DELETE)
    public Result<String> deleteById(String id) {
        return service.deleteById(id);
    }

}
