package org.springblade.business.feignClient;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.business.entity.AssessmentUser;
import org.springblade.business.feign.OpinionUserClient;
import org.springblade.business.service.IAssessmentUserService;
import org.springblade.business.service.IUserOpinionFlowService;
import org.springblade.business.vo.AssessmentUserVOS;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RestController;

import org.springblade.core.mp.support.Query;

import java.util.List;

@RestController
@AllArgsConstructor
public class OpinionUserClientImpl implements OpinionUserClient {

    private final IUserOpinionFlowService userOpinionFlowService;

    private final IAssessmentUserService assessmentUserService;

    @Override
    public List<AssessmentUser> queryUserAssessmentByUserId(String userId) {
        return this.assessmentUserService.list(Wrappers.<AssessmentUser>lambdaQuery().eq(AssessmentUser::getIsDeleted, 0).eq(AssessmentUser::getAssessmentUser, userId));
    }

    @Override
    public Boolean cancelAssessment(String id) {
        return this.assessmentUserService.update(Wrappers.<AssessmentUser>lambdaUpdate().set(AssessmentUser::getIsDeleted, 1).eq(AssessmentUser::getId, id));
    }

    @Override
    public AssessmentUser getById(String id) {
        return this.assessmentUserService.getById(id);
    }

    @Override
    public Boolean updateUserAssessment(AssessmentUser assessmentUser) {
        return this.assessmentUserService.update(Wrappers.<AssessmentUser>lambdaUpdate().set(AssessmentUser::getAssessmentContent, assessmentUser.getAssessmentContent()).set(AssessmentUser::getAssessmentMoney, assessmentUser.getAssessmentMoney()).eq(AssessmentUser::getId, assessmentUser.getId()));
    }

    @Override
    public Boolean saveUserAssessment(AssessmentUser assessmentUser) {
        return this.assessmentUserService.save(assessmentUser);
    }

    @Override
    public List<AssessmentUserVOS> queryUserAssessmentPageList(AssessmentUserVOS vo) {
        return this.userOpinionFlowService.queryUserAssessmentPage(vo);
    }

    public Integer countUserAssessmentPageList(AssessmentUserVOS vo){
        return this.userOpinionFlowService.countUserAssessmentPageList(vo);
    }

}
