package cn.stylefeng.team.portal.modular.management.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.team.portal.modular.management.entity.PortalDesignManager;
import cn.stylefeng.team.portal.modular.management.pojo.request.ManagerUpdateRequest;
import cn.stylefeng.team.portal.modular.management.pojo.request.PortalDesignManagerRequest;
import cn.stylefeng.team.portal.modular.management.service.PortalDesignManagerService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiResource(name = "门户设计管理员")
public class PortalDesignManagerUserController {

    @Resource
    private PortalDesignManagerService portalDesignManagerService;

    @PostResource(name = "更新门户设计管理员", path = "/portalDesignManager/updateManagerList")
    public ResponseData<PortalDesignManager> updateManagerList(@RequestBody @Validated ManagerUpdateRequest managerUpdateRequest) {
        portalDesignManagerService.updateManagerList(managerUpdateRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "删除门户设计管理员", path = "/portalDesignManager/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PortalDesignManagerRequest.delete.class) PortalDesignManagerRequest portalDesignManagerRequest) {
        portalDesignManagerService.del(portalDesignManagerRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "批量删除门户设计管理员", path = "/portalDesignManager/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PortalDesignManagerRequest portalDesignManagerRequest) {
        portalDesignManagerService.batchDelete(portalDesignManagerRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "获取门户设计管理员列表（带分页）", path = "/portalDesignManager/page")
    public ResponseData<PageResult<PortalDesignManager>> page(PortalDesignManagerRequest portalDesignManagerRequest) {
        return new SuccessResponseData<>(portalDesignManagerService.findPage(portalDesignManagerRequest));
    }

}
