package com.enterprise.manage.modules.asset.controller;

import com.enterprise.manage.common.base.BaseController;
import com.enterprise.manage.common.web.request.PageDomain;
import com.enterprise.manage.common.web.response.Result;
import com.enterprise.manage.common.web.response.module.ResultTable;
import com.enterprise.manage.modules.asset.domain.LandRevitalizeUtilize;
import com.enterprise.manage.modules.asset.service.ILandRevitalizeUtilizeService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 土地盘活利用信息 Controller
 *
 * @author QingLi Wang
 * @version 1.0.0
 * 2023-11-28 09:56
 */
@RestController
@RequestMapping("/asset/land/utilize/v1")
public class LandRevitalizeUtilizeController extends BaseController {

    private ILandRevitalizeUtilizeService landRevitalizeUtilizeService;

    @Autowired
    public LandRevitalizeUtilizeController(ILandRevitalizeUtilizeService landRevitalizeUtilizeService) {
        this.landRevitalizeUtilizeService = landRevitalizeUtilizeService;
    }

    @GetMapping
    @PreAuthorize("hasPermission('','asset:utilize:list')")
    public ResultTable list(PageDomain pageDomain, LandRevitalizeUtilize param) {
        PageInfo<LandRevitalizeUtilize> landRevitalizeUtilizePage = landRevitalizeUtilizeService.page(pageDomain, param);
        return pageTable(landRevitalizeUtilizePage.getList(), landRevitalizeUtilizePage.getTotal());
    }

    @GetMapping("{id}")
    @PreAuthorize("hasPermission('','asset:utilize:list')")
    public Result get(@PathVariable Long id) {
        return success(landRevitalizeUtilizeService.queryById(id));
    }

    @PostMapping
    @PreAuthorize("hasPermission('','asset:utilize:add')")
    public Result add(LandRevitalizeUtilize landRevitalizeUtilize) {
        return decide(landRevitalizeUtilizeService.save(landRevitalizeUtilize));
    }

    @PutMapping
    @PreAuthorize("hasPermission('','asset:utilize:edit')")
    public Result edit(LandRevitalizeUtilize landRevitalizeUtilize) {
        return decide(landRevitalizeUtilizeService.update(landRevitalizeUtilize));
    }

    @DeleteMapping("{id}")
    @PreAuthorize("hasPermission('','asset:utilize:del')")
    public Result remove(@PathVariable Integer id) {
        return decide(landRevitalizeUtilizeService.removeById(id));
    }

}
