前后端验证码分析(字母计算)

news2024/9/30 20:21:20

样式:

前端:

login.vue

<template>
<view class="normal-login-container">
<view class="login-form-content">
<view class="input-item flex align-center">
<view class="iconfont icon-user icon"></view>
<input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
</view>
<view class="input-item flex align-center">
<view class="iconfont icon-password icon"></view>
<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
</view>
<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
<view class="iconfont icon-code icon"></view>
<input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
<view class="login-code">
<image :src="codeUrl" @click="getCode" class="login-code-img"></image>
</view>
</view>
<view class="action-btn">
<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
</view>
</view>

</view>
</template>

<script>
import { getCodeImg } from '@/api/login'
export default {
data() {
return {
codeUrl: "",
captchaEnabled: true,
loginForm: {
username: "",
password: "",
code: "",
uuid: ''
}
}
},
created() {
this.getCode()
},
methods: {
// 获取图形验证码
getCode() {
getCodeImg().then(res => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
if (this.captchaEnabled) {
this.codeUrl = 'data:image/gif;base64,' + res.img
this.loginForm.uuid = res.uuid
}
})
},
// 登录方法
async handleLogin() {
if (this.loginForm.username === "") {
this.modal.msgError("请输入您的账号")
        } else if (this.loginForm.password === "") {
          this.modal.msgError("请输入您的密码")
} else if (this.loginForm.code === "" && this.captchaEnabled) {
this.modal.msgError("请输入验证码")
        } else {
          this.modal.loading("登录中,请耐心等待...")
this.pwdLogin()
}
},
// 密码登录
async pwdLogin() {
this.store.dispatch('Login', this.loginForm).then(() => {
          this.modal.closeLoading()
this.loginSuccess()
}).catch(() => {
if (this.captchaEnabled) {
this.getCode()
}
})
},
// 登录成功后,处理函数
loginSuccess(result) {
// 设置用户信息
this.store.dispatch('GetInfo').then(res => {
          this.tab.reLaunch('/pages/index')
})
}
}
}
</script>

<style lang="scss">
page {
background-color: #ffffff;
}

.normal-login-container {
width: 100%;

.login-form-content {
  text-align: center;
  margin: 20px auto;
  margin-top: 15%;
  width: 80%;

  .input-item {
    margin: 20px auto;
    background-color: #f5f6f7;
    height: 45px;
    border-radius: 20px;

    .icon {
      font-size: 38rpx;
      margin-left: 10px;
      color: #999;
    }

    .input {
      width: 100%;
      font-size: 14px;
      line-height: 20px;
      text-align: left;
      padding-left: 15px;
    }

  }

  .login-btn {
    margin-top: 40px;
    height: 45px;
  }
  
  .login-code {
    height: 38px;
    float: right;
  
    .login-code-img {
      height: 38px;
      position: absolute;
      margin-left: 10px;
      width: 200rpx;
    }
  }
}
}

</style>

login.js

import request from '@/utils/request'

// 登录方法
export function login(username, password, code, uuid) {
  const data = {
    username,
    password,
    code,
    uuid
  }
  return request({
    'url': '/login',
    headers: {
      isToken: false
    },
    'method': 'post',
    'data': data
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo() {
  return request({
    'url': '/getInfo',
    'method': 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    'url': '/logout',
    'method': 'post'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    'url': '/captchaImage',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  })
}

 八个Utils:

auth.js

const TokenKey = 'App-Token'

export function getToken() {
  return uni.getStorageSync(TokenKey)
}

export function setToken(token) {
  return uni.setStorageSync(TokenKey, token)
}

export function removeToken() {
  return uni.removeStorageSync(TokenKey)
}

common.js

/**
* 显示消息提示框
* @param content 提示的标题
*/
export function toast(content) {
  uni.showToast({
    icon: 'none',
    title: content
  })
}

/**
* 显示模态弹窗
* @param content 提示的标题
*/
export function showConfirm(content) {
  return new Promise((resolve, reject) => {
    uni.showModal({
      title: '提示',
      content: content,
      cancelText: '取消',
      confirmText: '确定',
      success: function(res) {
        resolve(res)
      }
    })
  })
}
export function praseStrEmpty(str) {
	if (!str || str == "undefined" || str == "null") {
		return "";
	}
	return str;
}

/**
* 参数处理
* @param params 参数
*/
export function tansParams(params) {
  let result = ''
  for (const propName of Object.keys(params)) {
    const value = params[propName]
    var part = encodeURIComponent(propName) + "="
    if (value !== null && value !== "" && typeof (value) !== "undefined") {
      if (typeof value === 'object') {
        for (const key of Object.keys(value)) {
          if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
            let params = propName + '[' + key + ']'
            var subPart = encodeURIComponent(params) + "="
            result += subPart + encodeURIComponent(value[key]) + "&"
          }
        }
      } else {
        result += part + encodeURIComponent(value) + "&"
      }
    }
  }
  return result
}

constant.js

const constant = {
   avatar: 'vuex_avatar',
   name: 'vuex_name',
   roles: 'vuex_roles',
   permissions: 'vuex_permissions'
 }

 export default constant

 errorCode.js

export default {
  '401': '认证失败,无法访问系统资源',
  '403': '当前操作没有权限',
  '404': '访问资源不存在',
  'default': '系统未知错误,请反馈给管理员'
}

 permission.js

import store from '@/store'

/**
 * 字符权限校验
 * @param {Array} value 校验值
 * @returns {Boolean}
 */
export function checkPermi(value) {
  if (value && value instanceof Array && value.length > 0) {
    const permissions = store.getters && store.getters.permissions
    const permissionDatas = value
    const all_permission = "*:*:*"

    const hasPermission = permissions.some(permission => {
      return all_permission === permission || permissionDatas.includes(permission)
    })

    if (!hasPermission) {
      return false
    }
    return true
  } else {
    console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
    return false
  }
}

/**
 * 角色权限校验
 * @param {Array} value 校验值
 * @returns {Boolean}
 */
export function checkRole(value) {
  if (value && value instanceof Array && value.length > 0) {
    const roles = store.getters && store.getters.roles
    const permissionRoles = value
    const super_admin = "admin"

    const hasRole = roles.some(role => {
      return super_admin === role || permissionRoles.includes(role)
    })

    if (!hasRole) {
      return false
    }
    return true
  } else {
    console.error(`need roles! Like checkRole="['admin','editor']"`)
    return false
  }
}

 request.js

import store from '@/store'
import config from '@/config'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
import axios from 'axios'

let timeout = 10000
const baseUrl = config.baseUrl

const request = config => {
  // 是否需要设置 token
  const isToken = (config.headers || {}).isToken === false
  config.header = config.header || {}
  console.log("--------"+getToken())
  if (getToken() && !isToken) {
    config.header['Authorization'] = 'Bearer ' + getToken()
  }
  // get请求映射params参数
  if (config.params) {
    let url = config.url + '?' + tansParams(config.params)
    url = url.slice(0, -1)
    config.url = url
  }
  return new Promise((resolve, reject) => {
    uni.request({
        method: config.method || 'get',
        timeout: config.timeout ||  timeout,
        url: config.baseUrl || baseUrl + config.url,
        data: config.data,
        header: config.header,
        dataType: 'json'
      }).then(response => {
        let [error, res] = response
        if (error) {
          toast('后端接口连接异常')
          reject('后端接口连接异常')
          return
        }
        const code = res.data.code || 200
        const msg = errorCode[code] || res.data.msg || errorCode['default']
        if (code === 401) {
          showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
            if (res.confirm) {
              store.dispatch('LogOut').then(res => {
                uni.reLaunch({ url: '/pages/login' })
              })
            }
          })
          reject('无效的会话,或者会话已过期,请重新登录。')
        } else if (code === 500) {
          toast(msg)
          reject('500')
        } else if (code !== 200) {
          toast(msg)
          reject(code)
        }
        resolve(res.data)
      })
      .catch(error => {
        let { message } = error
        if (message === 'Network Error') {
          message = '后端接口连接异常'
        } else if (message.includes('timeout')) {
          message = '系统接口请求超时'
        } else if (message.includes('Request failed with status code')) {
          message = '系统接口' + message.substr(message.length - 3) + '异常'
        }
        toast(message)
        reject(error)
      })
  })
}

export default request

 storage.js

import constant from './constant'

// 存储变量名
let storageKey = 'storage_data'

// 存储节点变量名
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions]

const storage = {
  set: function(key, value) {
    if (storageNodeKeys.indexOf(key) != -1) {
      let tmp = uni.getStorageSync(storageKey)
      tmp = tmp ? tmp : {}
      tmp[key] = value
      uni.setStorageSync(storageKey, tmp)
    }
  },
  get: function(key) {
    let storageData = uni.getStorageSync(storageKey) || {}
    return storageData[key] || ""
  },
  remove: function(key) {
    let storageData = uni.getStorageSync(storageKey) || {}
    delete storageData[key]
    uni.setStorageSync(storageKey, storageData)
  },
  clean: function() {
    uni.removeStorageSync(storageKey)
  }
}

export default storage

upload.js

import store from '@/store'
import config from '@/config'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'

let timeout = 10000
const baseUrl = config.baseUrl

const upload = config => {
  // 是否需要设置 token
  const isToken = (config.headers || {}).isToken === false
  config.header = config.header || {}
  if (getToken() && !isToken) {
    config.header['Authorization'] = 'Bearer ' + getToken()
  }
  // get请求映射params参数
  if (config.params) {
    let url = config.url + '?' + tansParams(config.params)
    url = url.slice(0, -1)
    config.url = url
  }
  return new Promise((resolve, reject) => {
      uni.uploadFile({
        timeout: config.timeout || timeout,
        url: baseUrl + config.url,
        filePath: config.filePath,
        name: config.name || 'file',
        header: config.header,
        formData: config.formData,
        success: (res) => {
          let result = JSON.parse(res.data)
          const code = result.code || 200
          const msg = errorCode[code] || result.msg || errorCode['default']
          if (code === 200) {
            resolve(result)
          } else if (code == 401) {
            showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then(res => {
              if (res.confirm) {
                store.dispatch('LogOut').then(res => {
                  uni.reLaunch({ url: '/pages/login/login' })
                })
              }
            })
            reject('无效的会话,或者会话已过期,请重新登录。')
          } else if (code === 500) {
            toast(msg)
            reject('500')
          } else if (code !== 200) {
            toast(msg)
            reject(code)
          }
        },
        fail: (error) => {
          let { message } = error
          if (message == 'Network Error') {
            message = '后端接口连接异常'
          } else if (message.includes('timeout')) {
            message = '系统接口请求超时'
          } else if (message.includes('Request failed with status code')) {
            message = '系统接口' + message.substr(message.length - 3) + '异常'
          }
          toast(message)
          reject(error)
        }
      })
  })
}

export default upload

 

后端:

传入URL:

http://localhost:8080/captchaImage

验证码操作处理(CaptchaController):

生成验证码的Controller,可以生成数字计算或者字符验证类型的验证码。生成的验证码被存储在Redis缓存中,并返回一个包含验证码图片Base64编码和验证码uuid的AjaxResult对象。

package com.muyuan.web.controller.common;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.code.kaptcha.Producer;
import com.muyuan.common.constant.Constants;
import com.muyuan.common.core.domain.AjaxResult;
import com.muyuan.common.core.redis.RedisCache;
import com.muyuan.common.utils.sign.Base64;
import com.muyuan.common.utils.uuid.IdUtils;

/**
 * 验证码操作处理
 */
//@Api("验证码")
@RestController
public class CaptchaController {
    @Resource(name = "captchaProducer")
    private Producer captchaProducer;

    @Resource(name = "captchaProducerMath")
    private Producer captchaProducerMath;

    @Autowired
    private RedisCache redisCache;
    
    // 验证码类型
    @Value("${muyuan.captchaType}")
    private String captchaType;

    /**
     * 生成验证码
     */
    //@ApiOperation("生成验证码")
    @GetMapping("/captchaImage")
    public AjaxResult getCode(HttpServletResponse response) throws IOException
    {
        // 1.保存验证码信息
        //1.1 生成简单的uuid(详细看文章ID生成工具)
        String uuid = IdUtils.simpleUUID();
        //1.2Constants.CAPTCHA_CODE_KEY就是拼接一个前缀信息("captcha_codes:")
        // 确保唯一性(确定每个人独自的验证码)
        String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
        //1.3以下滞空
        String capStr = null, code = null;
        BufferedImage image = null;

        // 2.生成验证码(两种方式计算验证码和字母验证码)
            //2.1由captchaType控制在application.yml中定义:
                //2.1.1 # 验证码类型 math 数组计算 char 字符验证
                //2.1.2captchaType: math
        if ("math".equals(captchaType))
        {
            //2.2.1用captchaProducerMath计算公式创建了一个文本 例如:1+1=@2
            String capText = captchaProducerMath.createText();
            //2.2.2字符串撕裂为 1+1= 这一部分
            capStr = capText.substring(0, capText.lastIndexOf("@"));
            //2.2.3字符串撕裂为 2 这一部分
            code = capText.substring(capText.lastIndexOf("@") + 1);
            //2.2.4创建了一个照片流
            image = captchaProducerMath.createImage(capStr);
        }
        else if ("char".equals(captchaType))
        {
            //2.3.1用captchaProducerMath计算公式创建了一个文本
            capStr = code = captchaProducer.createText();
            //2.3.2创建了一个照片流
            image = captchaProducer.createImage(capStr);
        }
        //redis存储(详见文章spring redis的工具类)
        //TimeUnit.MINUTES为有效时间
        redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
        // 转换流信息写出
        FastByteArrayOutputStream os = new FastByteArrayOutputStream();
        try
        {
            //照片流转成jpg格式名为os
            ImageIO.write(image, "jpg", os);
        }
        catch (IOException e)
        {
            return AjaxResult.error(e.getMessage());
        }
        //操作消息提醒(详见文章封装消息提醒)
        AjaxResult ajax = AjaxResult.success();

        ajax.put("uuid", uuid);
        //将os进行Base64编码的操作提高兼容性
        ajax.put("img", Base64.encode(os.toByteArray()));
        return ajax;
    }
}

之后前端输入验证码点击登录:

接口 URL:

http://localhost:8080/login

登录的操作处理(LoginController):

/**
     * 登录方法
     * 
     * @param loginBody 登录信息
     * @return 结果
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
                loginBody.getUuid());
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }

登录的操作处理(LoginService):

  • 参数:用户名(username)、密码(password)、验证码(code)、验证码唯一标识(uuid)。
  • 首先根据uuid拼接出验证码在Redis缓存中的键名(verifyKey)。
  • 从Redis缓存中获取该键名对应的验证码(captcha)。
  • 删除Redis缓存中的该键名。
  • 如果验证码为null,说明验证码已过期,抛出CaptchaExpireException异常。
  • 如果验证码不匹配,抛出CaptchaException异常。
  • 调用authenticationManager的authenticate方法进行用户验证,传入用户名和密码。
  • 如果验证失败,根据异常类型进行相应处理:
    • 如果是BadCredentialsException异常,抛出UserPasswordNotMatchException异常,表示密码不匹配。
    • 其他异常情况下,抛出CustomException异常,并记录异常信息。
  • 记录登录日志,包括用户名、登录结果(成功或失败)、相关消息。
  • 获取验证通过的用户对象(LoginUser)。
  • 调用tokenService的createToken方法生成token并返回。
package com.muyuan.framework.web.service;

import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import com.muyuan.common.constant.Constants;
import com.muyuan.common.core.domain.model.LoginUser;
import com.muyuan.common.core.redis.RedisCache;
import com.muyuan.common.exception.CustomException;
import com.muyuan.common.exception.user.CaptchaException;
import com.muyuan.common.exception.user.CaptchaExpireException;
import com.muyuan.common.exception.user.UserPasswordNotMatchException;
import com.muyuan.common.utils.MessageUtils;
import com.muyuan.framework.manager.AsyncManager;
import com.muyuan.framework.manager.factory.AsyncFactory;

/**
 * 登录校验方法
 * 
 * 
 */
@Component
public class SysLoginService {
    @Autowired
    private TokenService tokenService;

    @Resource
    private AuthenticationManager authenticationManager;

    @Autowired
    private RedisCache redisCache;

    /**
     * 登录验证
     * 
     * @param username 用户名
     * @param password 密码
     * @param code 验证码
     * @param uuid 唯一标识
     * @return 结果
     */
    public String login(String username, String password, String code, String uuid) {
        //前端获取的进行拼接verifyKey
        String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
        //从redisCache存储中获得verifyKey
        String captcha = redisCache.getCacheObject(verifyKey);
        //清除verifyKey缓存
        redisCache.deleteObject(verifyKey);
        if (captcha == null)
        {
            //记录日志(详见文章日志记录)
            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
            throw new CaptchaExpireException();
        }
        if (!code.equalsIgnoreCase(captcha))
        {
            //记录日志(详见文章日志记录)
            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
            throw new CaptchaException();
        }
        // 用户验证
        Authentication authentication = null;
        try {
            /**
             *获取用户对象的时候,会去调用下面的这个方法查询用户对象
             * UserDetailsServiceImpl.loadUserByUsername
             */
            // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
            System.out.println("username "+username+" -----password "+password);
            authentication = authenticationManager
                    .authenticate(new UsernamePasswordAuthenticationToken(username, password));
        }catch (Exception e) {
            e.printStackTrace();
            if (e instanceof BadCredentialsException) {
                //记录日志(详见文章日志记录)
                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
                throw new UserPasswordNotMatchException();
            }else {
                //记录日志(详见文章日志记录)
                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
                throw new CustomException(e.getMessage());
            }
        }
        //记录日志(详见文章日志记录)
        AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
        LoginUser loginUser = (LoginUser) authentication.getPrincipal();
        // 生成token(详见文章Token验证处理)
        return tokenService.createToken(loginUser);
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1283231.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBootApplication注解保姆级带你如何应对面试官

SpringBootApplication注解保姆级带你如何应对面试官 一介绍 在Java Spring Boot框架中&#xff0c;SpringBootApplication注解是一个组合注解&#xff0c;它由以下三个注解组成&#xff1a;SpringBootConfiguration&#xff0c;EnableAutoConfiguration和ComponentScan。 这…

绿色建筑革新,气膜球馆成为城市锻炼新热点

近年来&#xff0c;全民健身设施蓬勃发展&#xff0c;个性化球场设计逐渐取代了传统模式&#xff0c;其中备受欢迎的是新潮的绿色建筑——气膜室内球馆。这种创新的建筑形式不仅适用于传统的篮球、足球、羽毛球等常规运动&#xff0c;还可以容纳冰壶、滑雪等更为复杂的活动&…

MySQL入门实战:安装与配置基础

MySQL是一个开源的关系型数据库管理系统&#xff0c;由瑞典MySQL AB公司开发&#xff0c;目前已经被Sun Microsystems公司收购。MySQL是一个非常流行的数据库管理系统&#xff0c;它的特点是轻量级、高性能、易于使用和高度可扩展。 MySQL是一个基于客户端/服务器的系统&#…

浅谈基于能耗评价指标的医院智能配电能效管理分析

摘要&#xff1a;目的&#xff1a;为了更好地推进医院能源管理工作&#xff0c;主要利用空调系统分项能耗对上海7所三甲医院能源管理工作存在的问题进行分析。方法&#xff1a;Pearson系数被用作分析影响因素与医院总能耗的关联程度&#xff0c;再利用单位面积总能耗和空调系统…

基于Gradio的快速搭建AI算法可视化Web界面部署教程

基于Gradio的快速搭建AI算法可视化Web界面部署教程 1 Gradio简介1.1 视图框架1.2 Gradio介绍 2 功能模块2.1 概述2.2 模块介绍2.2.1 gradio.File() 上传文件2.2.2 gradio.Slider() 配置滑动条2.2.3 gr.Textbox() 文本框2.2.4 gradio.Dropdown() 建立下拉列表2.2.5 gradio.inter…

分享80个菜单导航JS特效,总有一款适合您

分享80个菜单导航JS特效&#xff0c;总有一款适合您 80个菜单导航JS特效下载链接&#xff1a;https://pan.baidu.com/s/1NgNc759Kg1of_8vR7kaj6A?pwd6666 提取码&#xff1a;6666 Python采集代码下载链接&#xff1a;采集代码.zip - 蓝奏云 学习知识费力气&#xff0c;…

面向对象及编程

C语言是一门面向过程的编程语言&#xff0c; C、Java这些编程语言都是面向对象。 分门别类&#xff1a;抽取事物的共性&#xff0c;将相似事物归纳为一个类别 面向的对象的核心概念&#xff1a; 类&#xff1a;就是一个事物的类别 |--属性 …

数据结构和算法专题---1、数据结构和算法概述

本文会系统性的介绍算法的概念、复杂度&#xff0c;后续会更新算法思想以及常见的失效算法、限流算法、调度算法、定时算法等&#xff0c;辅助大家快速学习算法和数据结构知识。 概念 数据结构 概述 数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或…

Ubuntu之Sim2Real环境配置(坑居多)

不要一上来就复制哦&#xff0c;因为很多下面的步骤让我走了很多弯路&#xff0c;如果可能的话&#xff0c;我会重新整理再发出来 前提&#xff1a; 参考教程 Docs 创建工作空间(不用跟着操作&#xff0c;无用&#xff09; 1.创建sim2real server container 1.尝试创建sim2r…

Python 解析JSON实现主机管理

JSON&#xff08;JavaScript Object Notation&#xff09;是一种轻量级的数据交换格式&#xff0c;它以易于阅读和编写的文本形式表示数据。JSON 是一种独立于编程语言的数据格式&#xff0c;因此在不同的编程语言中都有对应的解析器和生成器。JSON 格式的设计目标是易于理解、…

防火墙规则保存及自定义链

目录 防火墙规则保存 备份工具 iptables services 自定义链 自定义链实现方式 删除自定义链 重命名自定义链 防火墙规则保存 命令&#xff1a;iptables -save 工具&#xff1a;iptables services [rootlocalhost ~]# iptables-save > /opt/iptables.bak #将文件保存…

科普类软文怎么写才能提高用户接受度?媒介盒子分享

科普类软文以干货为主&#xff0c;可以给用户带来实用价值&#xff0c;但是相应会比较枯燥。如何才能把科普内容讲得专业又有趣&#xff0c;从而提高用户接受度呢&#xff1f;媒介盒子接下来就分享三大技巧&#xff1a; 一、 联系产品选题 科普类软文想要写好就需要做好选题&…

【数据结构】手撕排序NO.1

&#x1f525;博客主页&#xff1a; 小羊失眠啦. &#x1f3a5;系列专栏&#xff1a;《C语言》 《数据结构》 《Linux》《Cpolar》 ❤️感谢大家点赞&#x1f44d;收藏⭐评论✍️ 文章目录 一、排序的概念及其运用1.1 排序的概念1.2 常见的算法排序 二、 冒泡排序三、直接插入排…

2023年「全球化新品牌」与品牌出海路径洞察分析

观点&#xff1a;全球化品牌是未来品牌发展的最优选择 什么是全球化品牌&#xff1f; •多市场:在全球多个市场均有业务布局&#xff0c;既包括传统市场&#xff0c;也包括新兴市场。 •全渠道:线上第三方平台品牌独立站社交网络线下实体店&#xff0c;从2C扩展到2B。 •本土…

SSM项目实战-前端-在Index.vue中展示第一页数据

1、util/request.js import axios from "axios";let request axios.create({baseURL: "http://localhost:8080",timeout: 50000 });export default request 2、api/schedule.js import request from "../util/request.js";export let getSchedu…

开关电源调试时,常见的10个问题:

1、变压器饱和 变压器饱和现象 在高压或低压输入下开机(包含轻载&#xff0c;重载&#xff0c;容性负载)&#xff0c;输出短路&#xff0c;动态负载&#xff0c;高温等情况下&#xff0c;通过变压器(和开关管)的电流呈非线性增长&#xff0c;当出现此现象时&#xff0c;电流的…

SpringBoot2.x整合WebService实现远程接口调用

一、添加依赖 <!-- SpringBoot 2.4 以下版本--> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web-services</artifactId> </dependency><dependency><groupId>org.apach…

java日历功能

java 日历功能 功能概述java代码打印结果 功能概述 输入年份和月份&#xff0c;打印该月份所有日期&#xff0c;头部信息为星期一至星期日 java代码 package com.java.core.demoTest; import java.util.Calendar; import java.util.Scanner;// 打印日历 public class Calend…

接口测试很难?1分钟带你入门接口自动化测试

1、什么是接口&#xff1f; 接口是连接前台和后台的桥梁&#xff0c;前台通过接口调用后端已完成的功能&#xff0c;而无需关注内部的实现细节。借助于接口&#xff0c;可以实现前后台分离&#xff0c;各自完成开发工作后&#xff0c;进行联调&#xff0c;提高工作效率 2、接…