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.HouseRevitalizeUtilize;
import com.enterprise.manage.modules.asset.service.IHouseRevitalizeUtilizeService;
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:43
 */
@RestController
@RequestMapping("/asset/house/utilize/v1")
public class HouseRevitalizeUtilizeController extends BaseController {

    private IHouseRevitalizeUtilizeService houseRevitalizeUtilizeService;

    @Autowired
    public HouseRevitalizeUtilizeController(IHouseRevitalizeUtilizeService houseRevitalizeUtilizeService) {
        this.houseRevitalizeUtilizeService = houseRevitalizeUtilizeService;
    }

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

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

    @PostMapping
    @PreAuthorize("hasPermission('','utilize:utilize:add')")
    public Result add(HouseRevitalizeUtilize houseRevitalizeUtilize) {
        return decide(houseRevitalizeUtilizeService.save(houseRevitalizeUtilize));
    }

    @PutMapping
    @PreAuthorize("hasPermission('','utilize:utilize:edit')")
    public Result edit(HouseRevitalizeUtilize houseRevitalizeUtilize) {
        return decide(houseRevitalizeUtilizeService.update(houseRevitalizeUtilize));
    }

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

}
