五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

黑馬程序員Redis入門到實(shí)戰(zhàn)教程,深度透析redis底層原理+redis分布式

2023-08-12 13:20 作者:巴比Q啦-  | 我要投稿

p69 token.txt文件,大家直接拿去用,不客氣

package com.hmdp;

import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hmdp.dto.LoginFormDTO;
import com.hmdp.dto.Result;
import com.hmdp.entity.User;
import com.hmdp.service.IUserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

import javax.annotation.Resource;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author itzyh
 * @since 2023-08-11 22:22
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
// 開(kāi)啟虛擬mvc調(diào)用
@AutoConfigureMockMvc
public class TokenTest {
    @Autowired
    private MockMvc mockMvc;

    @Resource
    private IUserService iUserService;

    public static List<String> tokenList = new ArrayList<>();

    @Test
    void token() throws Exception {
        List<String> phones = iUserService.listObjs(Wrappers.<User>lambdaQuery().select(User::getPhone)
                .last("limit 0, 1000"), Object::toString);
        phones.forEach(phone -> {
            try {
                String response = mockMvc.perform(MockMvcRequestBuilders.post("/user/code")
                                .queryParam("phone", phone))
                        .andExpect(MockMvcResultMatchers.status().isOk())
                        .andReturn().getResponse().getContentAsString();
                Result result = JSONUtil.toBean(response, Result.class);
                Assert.isTrue(result.getSuccess(), String.format("獲取“%s”手機(jī)號(hào)的驗(yàn)證碼失敗", phone));

                String code = result.getData().toString();
                LoginFormDTO loginFormDTO = LoginFormDTO.builder().code(code).phone(phone).build();
                String requestBody = JSONUtil.toJsonStr(loginFormDTO);
                System.out.println(requestBody);
                String response2 = mockMvc.perform(MockMvcRequestBuilders
                                .post("/user/login").contentType(MediaType.APPLICATION_JSON).content(requestBody))
                        .andExpect(MockMvcResultMatchers.status().isOk())
                        .andReturn().getResponse().getContentAsString();

                result = JSONUtil.toBean(response2, Result.class);
                String token = result.getData().toString();
                tokenList.add(token);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        writeToken();
    }

    private static void writeToken() {
        // 文件路徑
        String filePath = System.getProperty("user.dir") + "\\src\\main\\resources/";

//        File file = new File(filePath);

        try {
            // 創(chuàng)建文件輸出流
            FileOutputStream fileOutputStream = new FileOutputStream(filePath + "token.txt");

            // 創(chuàng)建 PrintStream,將輸出重定向到文件
            PrintStream printStream = new PrintStream(fileOutputStream);

            // 輸出內(nèi)容到文件
            tokenList.forEach(s -> {
                printStream.println(s);
                printStream.flush();
            });

            // 關(guān)閉文件輸出流
            printStream.close();
        } catch (IOException e) {
        }
    }
}
package com.hmdp;

import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hmdp.dto.LoginFormDTO;
import com.hmdp.dto.Result;
import com.hmdp.entity.User;
import com.hmdp.service.IUserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

import javax.annotation.Resource;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author itzyh
 * @since 2023-08-11 22:22
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
// 開(kāi)啟虛擬mvc調(diào)用
@AutoConfigureMockMvc
public class TokenTest {
    @Autowired
    private MockMvc mockMvc;

    @Resource
    private IUserService iUserService;

    public static List<String> tokenList = new ArrayList<>();

    @Test
    void token() throws Exception {
        List<String> phones = iUserService.listObjs(Wrappers.<User>lambdaQuery().select(User::getPhone)
                .last("limit 0, 1000"), Object::toString);
        phones.forEach(phone -> {
            try {
                String response = mockMvc.perform(MockMvcRequestBuilders.post("/user/code")
                                .queryParam("phone", phone))
                        .andExpect(MockMvcResultMatchers.status().isOk())
                        .andReturn().getResponse().getContentAsString();
                Result result = JSONUtil.toBean(response, Result.class);
                Assert.isTrue(result.getSuccess(), String.format("獲取“%s”手機(jī)號(hào)的驗(yàn)證碼失敗", phone));

                String code = result.getData().toString();
                LoginFormDTO loginFormDTO = LoginFormDTO.builder().code(code).phone(phone).build();
                String requestBody = JSONUtil.toJsonStr(loginFormDTO);
                System.out.println(requestBody);
                String response2 = mockMvc.perform(MockMvcRequestBuilders
                                .post("/user/login").contentType(MediaType.APPLICATION_JSON).content(requestBody))
                        .andExpect(MockMvcResultMatchers.status().isOk())
                        .andReturn().getResponse().getContentAsString();

                result = JSONUtil.toBean(response2, Result.class);
                String token = result.getData().toString();
                tokenList.add(token);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        writeToken();
    }

    private static void writeToken() {
        // 文件路徑
        String filePath = System.getProperty("user.dir") + "\\src\\main\\resources/";

//        File file = new File(filePath);

        try {
            // 創(chuàng)建文件輸出流
            FileOutputStream fileOutputStream = new FileOutputStream(filePath + "token.txt");

            // 創(chuàng)建 PrintStream,將輸出重定向到文件
            PrintStream printStream = new PrintStream(fileOutputStream);

            // 輸出內(nèi)容到文件
            tokenList.forEach(s -> {
                printStream.println(s);
                printStream.flush();
            });

            // 關(guān)閉文件輸出流
            printStream.close();
        } catch (IOException e) {
        }
    }
}


黑馬程序員Redis入門到實(shí)戰(zhàn)教程,深度透析redis底層原理+redis分布式的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
太仓市| 中山市| 武定县| 巴中市| 四子王旗| 定远县| 邵东县| 汕头市| 柳州市| 南岸区| 上思县| 绥化市| 故城县| 墨竹工卡县| 芷江| 和林格尔县| 察隅县| 平利县| 揭阳市| 专栏| 萨迦县| 桂东县| 扎赉特旗| 张家界市| 惠安县| 教育| 贵港市| 黑山县| 安顺市| 乐清市| 泸定县| 大安市| 阳江市| 泰来县| 玛多县| 资源县| 南涧| 息烽县| 阳泉市| 东明县| 钦州市|