package org.springblade.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.tool.api.R;
import org.springblade.party.entity.PartyMember;
import org.springblade.party.feign.IPartyMemberClient;
import org.springblade.party.vo.PartyMemberVO;
import org.springblade.person.feign.IMemberClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lidexi
 * @date 2021/5/13 9:41
 */
@RestController
@RequestMapping("/party")
@RequiredArgsConstructor
public class PartyMemberController {

	private final IPartyMemberClient partyMemberClient;

	/**
	 * 根据员工id获取该员工是否为党员
	 */
	@GetMapping("/member/isPartyMember")
	@ApiOperationSupport(order = 7)
	@ApiOperation(value = "根据员工id获取该员工是否为党员", notes = "传入ids")
	public R isPartyMember(Long id) {
		PartyMember searchMember = new PartyMember();
		searchMember.setPersonId(id);
		searchMember.setPersonType(CommonConstant.PersonType.ENTERPRISESTAFF.getValue());
		List<PartyMemberVO> member = partyMemberClient.list(searchMember);
		if(member.size()>0 ){
			return R.data(member.get(0));
		}else{
			return R.data(null);
		}
	}
}
