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.dto.PackInfoDto;
import com.zksy.park.domain.dto.ParkStemScreenDto;
import com.zksy.park.service.ParkInfoService;
import com.zksy.park.service.ParkStemScreenService;
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("/parkStemScreen")
@Api(tags = "园区灯杆大屏", description = "园区灯杆大屏desc")
public class ParkStemScreenController {

    @Autowired
    private ParkStemScreenService 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)));
    }

    @GetMapping("/getListWithImg")
    @ApiOperation(value = "园区灯杆大屏查询所有以及图片")
    public Result getListWithImg(String conditionJson) throws Exception {
        return Result.ok(service.listWithImg(SearchUtil.parseWhereSql(conditionJson)));
    }

    @PostMapping("/save")
    @ApiOperation(value = "园区灯杆大屏新增")
    @Log(title = "新增园区灯杆大屏", businessType = BusinessType.INSERT)
    public Result<Object> save(@ModelAttribute ParkStemScreenDto dto) {
        return service.saveParkStemScreen(dto);
    }

    @PutMapping("/updateById")
    @ApiOperation(value = "园区灯杆大屏修改")
    @Log(title = "修改园区灯杆大屏", businessType = BusinessType.UPDATE)
    public Result<String> updateById(@ModelAttribute ParkStemScreenDto dto) {
        return service.updateByParkStemScreenId(dto);
    }

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

}
