package com.srs.web.controller.dormitory;

import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.core.page.TableDataInfo;
import com.srs.dormitory.domain.Dto.ParkDto;
import com.srs.dormitory.service.IDmsDormitoryParkService;
import com.srs.dormitory.utils.DmsOperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 园区表 前端控制器
 * </p>
 *
 * @author 猪油骨
 * @since 2023-07-14
 */
@Api(tags = "园区管理")
@RestController
@RequestMapping("/dormitory/dms-dormitory-park")
public class DmsDormitoryParkController extends BaseController {
    @Autowired
    private IDmsDormitoryParkService dmsDormitoryParkService;

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-dormitory-park:add')")
    @ApiOperation("添加园区")
    @PostMapping("/add")
    public AjaxResult addDmsDormitoryPark(@RequestBody ParkDto parkDto){
        return dmsDormitoryParkService.addDmsDormitoryPark(parkDto,getUsername());
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-dormitory-park:query')")
    @ApiOperation("查看园区详细信息")
    @GetMapping("/{id}")
    public AjaxResult getDmsDormitoryPark(@PathVariable Long id){
        return dmsDormitoryParkService.getDmsDormitoryPark(id);
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-dormitory-park:list')")
    @ApiOperation("查看园区列表")
    @PostMapping("/list")
    public TableDataInfo getDmsDormitoryParkList(@RequestBody ParkDto parkDto){
        startPage();
        return getDataTable(dmsDormitoryParkService.getDmsDormitoryParkList(parkDto));
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-dormitory-park:edit')")
    @ApiOperation("修改园区信息")
    @PostMapping("/update")
    public AjaxResult updateDmsDormitoryPark(@RequestBody ParkDto parkDto){
        return dmsDormitoryParkService.updateDmsDormitoryPark(parkDto,getUsername());
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-dormitory-park:remove')")
    @ApiOperation("删除园区")
    @PostMapping("/delete/{id}")
    public AjaxResult deleteDmsDormitoryPark(@PathVariable Long id){
        List<Long> ids = new ArrayList<>();
        ids.add(id);
        return dmsDormitoryParkService.deleteDmsDormitoryPark(ids);
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-dormitory-park:remove')")
    @ApiOperation("批量删除园区")
    @PostMapping("/delete")
    public AjaxResult batchDeleteDmsDormitoryPark(@RequestBody List<Long> ids){
        return dmsDormitoryParkService.deleteDmsDormitoryPark(ids);
    }
}
