package com.microservices.pms.project.controller;

import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.Logical;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.pms.project.domain.vo.PmsProjectMembersDetailVo;
import com.microservices.pms.project.domain.vo.PmsProjectMembersInputVo;
import com.microservices.pms.project.domain.vo.PmsProjectMembersSearchVo;
import com.microservices.pms.project.service.IPmsProjectMembersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 项目-成员Controller
 * 
 * @author wanjia
 * @date 2023-10-11
 */
@RestController
@RequestMapping("/{enterpriseIdentifier}/pmsProjectMembers")
@Api(tags = "项目管理-项目成员接口")
@ApiImplicitParams({
        @ApiImplicitParam(name = "enterpriseIdentifier", value = "企业标识", paramType = "path", dataType = "String")
})
public class PmsProjectMembersController extends BaseController
{
    @Autowired
    private IPmsProjectMembersService pmsProjectMembersService;

    /**
     * 查询项目-成员列表
     */
    @RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe"}, logical = Logical.OR)
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "orderByColumn", value = "排序列（更新时间：updateTime，创建时间：createTime）", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "isAsc", value = "排序的方向desc或者asc,默认asc", paramType = "query", dataType = "String")
    })
    public GenericsTableDataInfo<PmsProjectMembersDetailVo> list(PmsProjectMembersSearchVo pmsProjectMembersSearchVo)
    {
        startPage();
        return pmsProjectMembersService.selectPmsProjectMembersList(pmsProjectMembersSearchVo.toPmsProjectMembers());
    }

    /**
     * 获取项目-成员详细信息
     */
    @RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe"}, logical = Logical.OR)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pmsProjectMembersService.selectPmsProjectMembersById(id));
    }

    /**
     * 新增项目-成员
     */
    @RequiresPermissions(value = {"pms:pmsProject:add", "pms:pmsProject:edit"}, logical = Logical.OR)
    @Log(title = "项目-成员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsProjectMembersInputVo pmsProjectMembersInputVo)
    {
        return toAjax(pmsProjectMembersService.insertPmsProjectMembers(pmsProjectMembersInputVo.toPmsProjectMembers()));
    }

    /**
     * 删除项目-成员
     */
    @RequiresPermissions(value = {"pms:pmsProject:add", "pms:pmsProject:edit"}, logical = Logical.OR)
    @Log(title = "项目-成员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmsProjectMembersService.deletePmsProjectMembersByIds(ids));
    }
}
