package com.njzscloud.dispose.cst.project.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.project.pojo.entity.ProjectEntity;
import com.njzscloud.dispose.cst.project.pojo.param.ProjectQueryParam;
import com.njzscloud.dispose.cst.project.pojo.result.ProjectResult;
import com.njzscloud.dispose.cst.project.service.ProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目信息
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/project")
@RequiredArgsConstructor
public class ProjectController {

    private final ProjectService projectService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody ProjectEntity projectEntity) {
        projectService.add(projectEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody ProjectEntity projectEntity) {
        projectService.modify(projectEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<ProjectResult>> paging(PageParam pageParam, ProjectQueryParam queryParam) {
        return R.success(projectService.paging(pageParam, queryParam));
    }
}


