package com.rf.psychological.plan.service;

import com.alibaba.fastjson.JSONArray;
import com.rf.psychological.plan.dao.model.TestPlanUserEntity;
import com.rf.psychological.utils.Result;
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.Optional;

/**
 * @author lpf
 * @description:
 * @date 2022/1/614:35
 */
public interface TestPlanUserService {

    void deleteById(String id);

    void deleteByUIdAndTestPlanId(String uId, String testPlanId);

    Page<TestPlanUserEntity> findTestPlanUserByTestId(String testId, String searchKey, int beginNum, int pageSize);


    Optional<TestPlanUserEntity> findTestPlanUserByTestIdAndUserId(String testPlanId, String userId);

    int countByTestId(String testId);

    List<TestPlanUserEntity> findTestPlanByUId(String uId, int beginNum, int pageSize, String status, String isComplete);

    void deleteAllByTestPlanId(String testPlanId);

    void save(TestPlanUserEntity testPlanUserEntity);

    void saveInBatch(List<TestPlanUserEntity> testPlanUserEntities);

    /**
     * 通过组保存测试
     *
     * @param jsonArray
     * @return
     */
    Result saveByGroup(JSONArray jsonArray);


    /**
     * 更改测试计划完成情况
     *
     * @param testPlanId
     * @param userId
     */
    void updateIsComplete(String testPlanId, String userId, String isComplete);

    /**
     * 更改测试计划下的所有用户的状态
     *
     * @param testPlanId
     * @param isComplete
     */
    void updateIsComplete(String testPlanId, String isComplete);


    void deletePlanIdAndGroupId(String planId, String groupId);

    /**
     * planId---->List<UserId>
     * @param planId
     * @return
     */
    List<String> findUserIdByPlanId(String planId);

    /**
     * userId&planId ----> entry
     * @param userId
     * @param planId
     */
    TestPlanUserEntity findByUserIdAndPlanId(String userId, String planId);

    List<TestPlanUserEntity> findUncompletedUser(String id);
}
