package com.njzscloud.dispose.cst.org.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.cst.org.pojo.entity.OrgApplyEntity;
import com.njzscloud.dispose.cst.org.pojo.param.SearchOrgApplyParam;
import com.njzscloud.dispose.cst.org.pojo.result.SearchOrgApplyResult;
import com.njzscloud.dispose.cst.org.service.OrgApplyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 加入组织申请
 */
@Slf4j
@RestController
@RequestMapping("/org_apply")
@RequiredArgsConstructor
public class OrgApplyController {
    private final OrgApplyService orgApplyService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody OrgApplyEntity orgApplyEntity) {
        orgApplyService.add(orgApplyEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody OrgApplyEntity orgApplyEntity) {
        orgApplyService.modify(orgApplyEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        orgApplyService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<OrgApplyEntity> detail(@RequestParam Long id) {
        return R.success(orgApplyService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchOrgApplyResult>> paging(PageParam pageParam, SearchOrgApplyParam searchOrgApplyParam) {
        return R.success(orgApplyService.paging(pageParam, searchOrgApplyParam));
    }
}
