package org.springblade.person.feign;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springblade.estate.entity.ApplyUser;
import org.springblade.estate.feign.IApplyUserClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.person.entity.Member;
import org.springblade.person.vo.MemberVO;
import org.springblade.person.wrapper.MemberWrapper;
import org.springblade.person.service.IMemberService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 会员表--小程序端，app端注册的会员信息 client
 *
 * @author lianghanqiang
 * @since 2021-04-23
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/member")

public class MemberClient implements IMemberClient {

    private final IMemberService memberService;

    /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public MemberVO detail(@SpringQueryMap Member member) {
        Member detail = memberService.getOne(Condition.getQueryWrapper(member));
        return MemberWrapper.build().entityVO(detail);
        }

    /**
     * 查询 会员表--小程序端，app端注册的会员信息
     */
    @Override
    @GetMapping("/list")
    public List<MemberVO> list(Member member) {
        return MemberWrapper.build().listVO(memberService.list(Condition.getQueryWrapper(member)));
        }



    /**
     * 新增 会员表--小程序端，app端注册的会员信息
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Member member) {
        return memberService.save(member);
        }

    /**
     * 修改 会员表--小程序端，app端注册的会员信息
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Member member) {
        return memberService.updateById(member);
        }

    /**
     * 新增或修改 会员表--小程序端，app端注册的会员信息
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody Member member) {
        return memberService.saveOrUpdate(member);
        }


    /**
     * 删除 会员表--小程序端，app端注册的会员信息
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return memberService.deleteLogic(Func.toLongList(ids));
        }

	@Override
	@GetMapping("/getById")
	public Member getById(@RequestParam Long id) {
		return memberService.getById(id);
	}


}
