package com.red.circle.console.adapter.app.team;

import com.red.circle.common.business.enums.OperationUserOrigin;
import com.red.circle.console.app.dto.clienobject.team.TeamApplicationProcessCO;
import com.red.circle.console.app.service.app.team.TeamApplicationProcessBackService;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.team.TeamProcessBackQryCmd;
import com.red.circle.other.inner.model.cmd.team.TeamProcessChangeBackCmd;
import com.red.circle.other.inner.enums.team.TeamApplicationType;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 团队申请流程.
 *
 * @author pengshigang on 2022/12/19
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/team/application/process")
public class TeamApplicationProcessRestController extends BaseController {

  private final TeamApplicationProcessBackService teamApplicationProcessBackService;

  /**
   * 团队申请列表.
   */
  @GetMapping("/list")
  public List<TeamApplicationProcessCO> listByCondition(TeamProcessBackQryCmd query) {
    query.setType(TeamApplicationType.TEAM);
    query.setSysOrigin("TWO_FUN");
    return teamApplicationProcessBackService.listByCondition(query);
  }

  /**
   * 修改团队成员申请状态.
   */
  @PostMapping("/change/status")
  public void changeStatus(@RequestBody @Validated TeamProcessChangeBackCmd param) {

    param.setUpdateUserId(param.getReqUserId());
    param.setUpdateUserOrigin(OperationUserOrigin.BACK.getValue());
    teamApplicationProcessBackService.changeStatus(param);
  }

}
