package cn.axzo.msg.center.inside.notices.service;

import cn.axzo.msg.center.MsgCenterApplication;
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
import cn.axzo.msg.center.api.response.MessageNewRes;
import cn.axzo.msg.center.message.service.GeneralMessageOldService;
import cn.axzo.msg.center.service.general.request.OldMsgStatWithMultiIdentifiesRequest;
import cn.azxo.framework.common.model.Page;
import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @author yanglin
 */
@SpringBootTest(classes = MsgCenterApplication.class)
public class GeneralMessageOldServiceTest {

    @Autowired
    private GeneralMessageOldService generalMessageOldService;

    @Test
    void count() {
        String jsonStr = "{\n" +
                "  \"identities\": [\n" +
                "    {\n" +
                "      \"id\": 2002172,\n" +
                "      \"type\": \"WORKER_LEADER\",\n" +
                "      \"valid\": true\n" +
                "    },\n" +
                "    {\n" +
                "      \"id\": 1593,\n" +
                "      \"type\": \"PRACTITIONER\",\n" +
                "      \"valid\": true\n" +
                "    }\n" +
                "  ],\n" +
                "  \"personId\": 2849\n" +
                "}";
        OldMsgStatWithMultiIdentifiesRequest req = JSON.parseObject(jsonStr, OldMsgStatWithMultiIdentifiesRequest.class);
        int count = generalMessageOldService.countUnreadWithIdentities(req.getPersonId(), req.getIdentities());

        List<MessageNewRes> page = page();
        System.out.println();
    }

    List<MessageNewRes> page() {
        String jsonStr = "{\n" +
                "  \"identities\": [\n" +
                "    {\n" +
                "      \"id\": 2002172,\n" +
                "      \"type\": \"WORKER_LEADER\",\n" +
                "      \"valid\": true\n" +
                "    },\n" +
                "    {\n" +
                "      \"id\": 1593,\n" +
                "      \"type\": \"PRACTITIONER\",\n" +
                "      \"valid\": true\n" +
                "    }\n" +
                "  ],\n" +
                "  \"msgType\": 1,\n" +
                "  \"page\": 1,\n" +
                "  \"pageSize\": 600,\n" +
                "  \"personId\": 2849\n" +
                "}";
        CmsMsgQueryReq request = JSON.parseObject(jsonStr, CmsMsgQueryReq.class);
        Page<MessageNewRes> messageNewResPage = generalMessageOldService.pageMsgInfo(request);
        return messageNewResPage.getList();
    }
}
