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

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.front.entity.PortalCalendar;
import cn.stylefeng.team.portal.modular.front.pojo.request.PortalCalendarRequest;
import cn.stylefeng.team.portal.modular.front.service.PortalCalendarService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@ApiResource(name = "门户个人日历")
public class PortalCalendarController {

    @Resource
    private PortalCalendarService portalCalendarService;

    @PostResource(name = "添加门户个人日历", path = "/portalCalendar/add")
    public ResponseData<PortalCalendar> add(@RequestBody @Validated(PortalCalendarRequest.add.class) PortalCalendarRequest portalCalendarRequest) {
        portalCalendarService.add(portalCalendarRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "删除门户个人日历", path = "/portalCalendar/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PortalCalendarRequest.delete.class) PortalCalendarRequest portalCalendarRequest) {
        portalCalendarService.del(portalCalendarRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "批量删除门户个人日历", path = "/portalCalendar/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PortalCalendarRequest portalCalendarRequest) {
        portalCalendarService.batchDelete(portalCalendarRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "编辑门户个人日历", path = "/portalCalendar/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PortalCalendarRequest.edit.class) PortalCalendarRequest portalCalendarRequest) {
        portalCalendarService.edit(portalCalendarRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "查看门户个人日历详情", path = "/portalCalendar/detail")
    public ResponseData<PortalCalendar> detail(@Validated(PortalCalendarRequest.detail.class) PortalCalendarRequest portalCalendarRequest) {
        return new SuccessResponseData<>(portalCalendarService.detail(portalCalendarRequest));
    }

    @GetResource(name = "获取门户个人日历列表", path = "/portalCalendar/list")
    public ResponseData<Map<String, List<PortalCalendar>>> list(@Validated(BaseRequest.list.class) PortalCalendarRequest portalCalendarRequest) {
        return new SuccessResponseData<>(portalCalendarService.findList(portalCalendarRequest));
    }

}
