tdesign的文件上传(微信小程序+idea的springboot)

目录

1. springboot后端

1.1 FileController.java

 1.2 listener文件的ErpApplicationListener.java

1.3  【重点!】FileServiceImpl层

 1.4 IFileService

1.5 StringUtil通用类

 1.6 主程序加一个监听器

 1.7 application.yml文件

2. 微信小程序端

2.1 TDesign的upload组件

1. app.json全局引用一下

2. wxml

3. js


1. springboot后端


1.1 FileController.java

 如上图可以看到,微信小程序的请求url要传来一个type值,

controller全部代码如下,直接复制粘贴就行:

package com.huashang.controller;import com.huashang.common.BaseController;
import com.huashang.service.IFileService;
import org.springframework.web.bind.annotation.*;import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;@RestController
public class FileController extends BaseController {@Resourceprivate IFileService fileService;@RequestMapping(value = "/files/{type}", method = RequestMethod.POST)public String uploadFile(@PathVariable String type ,HttpServletRequest request) throws Exception {return fileService.uploadFiles(request, type);}}

 1.2 listener文件的ErpApplicationListener.java

1.3  【重点!】FileServiceImpl层

FileServiceImpl是IFileService的实现类,先看实现类,接口放最后了

以下代码不要直接复制粘贴到serviceImpl层,是原始代码,需要修改并添加一个引用才能使用

package com.huashang.serviceImpl;import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;import javax.servlet.http.HttpServletRequest;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSException;
import com.huashang.common.Constants;
import com.huashang.model.Alioss;
import com.huashang.service.IFileService;import cn.hutool.core.date.DateUtil;@Service
public class FileServiceImpl implements IFileService {private Alioss alioss;private final static List<String> FILE_TYPE = Arrays.asList("product", "biz", "color", "qa", "mes_qa", "oa", "model");@Autowiredpublic void setAlioss(Alioss alioss) {this.alioss = alioss;}public static OSSClient ossClient;private final static Logger logger = LoggerFactory.getLogger(FileServiceImpl.class);@Overridepublic void initClient() {// 实例化客户端logger.info("**************************初始化阿里云文件上传服务服务端--START****************************");ossClient = new OSSClient(alioss.getEndpoint(), alioss.getAccessKeyId(), alioss.getAcceddKeySecret());logger.info("**************************初始化阿里云文件上传服务服务端--END****************************");}@Transactional@Overridepublic String uploadFiles(HttpServletRequest request, String type) throws IOException {String picUrl = "";if (request instanceof MultipartHttpServletRequest) {MultiValueMap<String, MultipartFile> multiMap = ((MultipartHttpServletRequest) request).getMultiFileMap();Set<String> keys = multiMap.keySet();for (String key : keys) {List<MultipartFile> mutiFiles = multiMap.get(key);for (int i = 0; i < mutiFiles.size(); i++) {if (!FILE_TYPE.contains(type)) {return "可以上传的文件类型:" + FILE_TYPE.toString();}MultipartFile file = mutiFiles.get(i);String originalFilename = this.getFileOldName(file);LocalDate now = LocalDate.now();String dir = type + "/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth() + "/";String path = dir + originalFilename;try {ossClient.putObject(alioss.getBucketName(), path, mutiFiles.get(i).getInputStream());} catch (OSSException | ClientException | IOException e) {e.printStackTrace();}if (mutiFiles.size() - i == 1) {picUrl += "https://" + alioss.getUrl() + "/" + path;} else {picUrl += "https://" + alioss.getUrl() + "/" + path + ",";}}}}return picUrl;}@Overridepublic String uploadTmpFile(String filePath, String fileName) throws FileNotFoundException {StringBuilder dirBuilder = new StringBuilder("tmp/");dirBuilder.append(DateUtil.format(new Date(), Constants.DATE_yyyyMMdd)).append("/");StringBuilder fileLinkBuilder = new StringBuilder();fileLinkBuilder.append("https://").append(alioss.getUrl()).append("/").append(dirBuilder.toString()).append(fileName);ossClient.putObject(alioss.getBucketName(), dirBuilder.toString() + fileName, new FileInputStream(filePath + fileName));return fileLinkBuilder.toString();}private String getFileOldName(MultipartFile file) {return Objects.requireNonNull(file.getOriginalFilename()).replaceAll("[^a-zA-Z0-9.]", "^_^");}
}

接下来教大家怎么修改文件

 看不清楚没关系,如下图片是你唯一需要修改的地方

以下代码直接复制粘贴到FileServiceImpl

package com.huashang.serviceImpl;import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;import javax.servlet.http.HttpServletRequest;import com.huashang.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSException;
import com.huashang.common.Constants;
import com.huashang.model.Alioss;
import com.huashang.service.IFileService;import cn.hutool.core.date.DateUtil;@Service
public class FileServiceImpl implements IFileService {private Alioss alioss;private final static List<String> FILE_TYPE = Arrays.asList("product", "biz", "color", "qa", "mes_qa", "oa", "model");@Autowiredpublic void setAlioss(Alioss alioss) {this.alioss = alioss;}public static OSSClient ossClient;private final static Logger logger = LoggerFactory.getLogger(FileServiceImpl.class);@Overridepublic void initClient() {// 实例化客户端logger.info("**************************初始化阿里云文件上传服务服务端--START****************************");ossClient = new OSSClient(alioss.getEndpoint(), alioss.getAccessKeyId(), alioss.getAcceddKeySecret());logger.info("**************************初始化阿里云文件上传服务服务端--END****************************");}@Transactional@Overridepublic String uploadFiles(HttpServletRequest request, String type) throws IOException {if(StringUtil.stringBlank(type)){throw new RuntimeException("type must not be empty");}if(!Arrays.asList("user", "house", "project").contains(type)){throw new RuntimeException("type is not supported");}StringBuilder picUrl = new StringBuilder();if (request instanceof MultipartHttpServletRequest) {MultiValueMap<String, MultipartFile> multiMap = ((MultipartHttpServletRequest) request).getMultiFileMap();Set<String> keys = multiMap.keySet();for (String key : keys) {List<MultipartFile> mutiFiles = multiMap.get(key);for (int i = 0; i < mutiFiles.size(); i++) {String fileOldName = StringUtil.getFileOldName(mutiFiles.get(i));String fileName = StringUtil.randomString(20) + fileOldName;String dir = type + "/" + DateUtil.format(new Date(), "yyMMddHH") + "/";String path = dir + fileName;try {ossClient.putObject(alioss.getBucketName(), path, mutiFiles.get(i).getInputStream());} catch (OSSException | ClientException | IOException e) {e.printStackTrace();}if (mutiFiles.size() - i == 1) {picUrl.append("https://").append(alioss.getUrl()).append("/").append(path);} else {picUrl.append("https://").append(alioss.getUrl()).append("/").append(path).append(",");}}}}return picUrl.toString();}@Overridepublic String uploadTmpFile(String filePath, String fileName) throws FileNotFoundException {StringBuilder dirBuilder = new StringBuilder("tmp/");dirBuilder.append(DateUtil.format(new Date(), Constants.DATE_yyyyMMdd)).append("/");StringBuilder fileLinkBuilder = new StringBuilder();fileLinkBuilder.append("https://").append(alioss.getUrl()).append("/").append(dirBuilder.toString()).append(fileName);ossClient.putObject(alioss.getBucketName(), dirBuilder.toString() + fileName, new FileInputStream(filePath + fileName));return fileLinkBuilder.toString();}}

 1.4 IFileService


package com.huashang.service;import java.io.FileNotFoundException;
import java.io.IOException;import javax.servlet.http.HttpServletRequest;public interface IFileService {void initClient();String uploadFiles(HttpServletRequest request, String type) throws IOException;String uploadTmpFile(String filePath, String fileName) throws FileNotFoundException;
}

1.5 StringUtil通用类


都是定义好的,复制粘贴就行

package com.huashang.util;import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;@Component("stringUtil")
public class StringUtil {private static final String ALL_CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";private static final String ALL_NUMBERS = "0123456789";/*** 将换行处理为空**/public static String n2Null(String myString) {if (myString == null) {return myString;}String newString = null;Pattern CRLF = Pattern.compile("(\r\n|\r|\n|\n\r)");Matcher m = CRLF.matcher(myString);if (m.find()) {newString = m.replaceAll(" ");} else {newString = myString;}return newString;}public static String randomString(int length) {StringBuffer sb = new StringBuffer();Random random = new Random();for (int i = 0; i < length; i++) {sb.append(ALL_CHARS.charAt(random.nextInt(ALL_CHARS.length())));}return sb.toString();}public static String randomNumber(int length) {StringBuffer sb = new StringBuffer();Random random = new Random();for (int i = 0; i < length; i++) {sb.append(ALL_NUMBERS.charAt(random.nextInt(ALL_NUMBERS.length())));}return sb.toString();}public static boolean stringBlank(String str) {return str == null || "".equals(str.trim());}public static String getFileOldName(MultipartFile file) {return file.getOriginalFilename().replaceAll("[^a-zA-Z0-9.]", "^_^");}public static String humb2UnderLine(String s) {if (s == null) {return null;}StringBuilder sb = new StringBuilder();boolean upperCase = false;for (int i = 0; i < s.length(); i++) {char c = s.charAt(i);boolean nextUpperCase = true;if (i < (s.length() - 1)) {nextUpperCase = Character.isUpperCase(s.charAt(i + 1));}if (Character.isUpperCase(c)) {if (!upperCase || !nextUpperCase) {if (i > 0) {sb.append("_");}}upperCase = true;} else {upperCase = false;}sb.append(Character.toLowerCase(c));}return sb.toString();}public static String firstImage(String images) {List<String> ia = imageArray(images);return ia.isEmpty() ? null : ia.get(0);}public static List<String> imageArray(String images) {List<String> is = new ArrayList<>();for (String i : split(images, ";")) {if (!"".equals(i.trim())) {is.add(i.trim());}}return is;}public static List<String> split(String images, String splitor) {if (images == null || "".equals(images.trim())) {return new ArrayList<>();}return Arrays.asList(images.split(splitor));}public static String nullString(Object obj) {return obj == null ? "" : obj.toString();}/*** 图片的字符串,将其中的eshangying的连接替换为支持https协议的简赢域名* http://files.eshangying.com/2015-06-03/ctgge_518h0aZN0DL._UL1500_.jpg;* esyfiles.lrerp.com*/public static String dealImageEwin2Jy(String images) {if (StringUtil.stringBlank(images)) {return images;}images = images.replace("files.eshangying.com", "esyfiles.lrerp.com");return images;}/*** 将字符串text中由openToken和closeToken组成的占位符依次替换为args数组中的值** @param openToken* @param closeToken* @param text* @param args* @return*/public static String parseInner(String openToken, String closeToken, String text, Object... args) {if (args == null || args.length <= 0) {return text;}int argsIndex = 0;if (text == null || text.isEmpty()) {return "";}char[] src = text.toCharArray();int offset = 0;// search open tokenint start = text.indexOf(openToken, offset);if (start == -1) {return text;}final StringBuilder builder = new StringBuilder();StringBuilder expression = null;while (start > -1) {if (start > 0 && src[start - 1] == '\\') {// this open token is escaped. remove the backslash and continue.builder.append(src, offset, start - offset - 1).append(openToken);offset = start + openToken.length();} else {// found open token. let's search close token.if (expression == null) {expression = new StringBuilder();} else {expression.setLength(0);}builder.append(src, offset, start - offset);offset = start + openToken.length();int end = text.indexOf(closeToken, offset);while (end > -1) {if (end > offset && src[end - 1] == '\\') {// this close token is escaped. remove the backslash and continue.expression.append(src, offset, end - offset - 1).append(closeToken);offset = end + closeToken.length();end = text.indexOf(closeToken, offset);} else {expression.append(src, offset, end - offset);offset = end + closeToken.length();break;}}if (end == -1) {// close token was not found.builder.append(src, start, src.length - start);offset = src.length;} else {///仅仅修改了该else分支下的个别行代码String value = (argsIndex <= args.length - 1) ?(args[argsIndex] == null ? "" : args[argsIndex].toString()) : expression.toString();builder.append(value);offset = end + closeToken.length();argsIndex++;}}start = text.indexOf(openToken, offset);}if (offset < src.length) {builder.append(src, offset, src.length - offset);}return builder.toString();}public static String parseWith$(String text, Object... args) {return parseInner("${", "}", text, args);}public static String parse(String text, Object... args) {return parseInner("{", "}", text, args);}/*** 数组指定位置插入元素** @param after 在数组哪个元素后面  特殊: index0 代表 插入最开始* @param item  需要插入的元素* @param arr   操作的数组* @return 插入后的数组*/public static String[] arrPushItem(String after, String item, String[] arr) {ArrayList<String> list = new ArrayList<>(Arrays.asList(arr));if (after == null) {list.add(item);} else if ("index0".equals(after)) {list.add(0, item);} else {int i = list.indexOf(after) + 1;list.add(i, item);}String[] strings = new String[list.size()];list.toArray(strings);return strings;}/*** 字符串转换为BigDecimal** @param number* @return*/public static BigDecimal string2BigDecimal(String number) {if (stringBlank(number)) {return null;}return new BigDecimal(number);}public static boolean isNumeric(String str) {if (stringBlank(str)) {return false;}return str.matches("-?[0-9]+.?[0-9]*");}/*** 替换掉html 标签** @param myString* @return*/public static String filterHtml(String myString) {if (myString == null) {return myString;}String newString = myString;Pattern BREND = Pattern.compile("(<br/>|<br />|<br>|<br >)", Pattern.CASE_INSENSITIVE);Matcher me = BREND.matcher(newString);if (me.find()) {newString = me.replaceAll("\r\n");}Pattern SPANEND = Pattern.compile("(<span/>|<span />)", Pattern.CASE_INSENSITIVE);Matcher se = SPANEND.matcher(newString);if (se.find()) {newString = se.replaceAll(" ");}// 过滤html标签Pattern pHtml = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE);Matcher mHtml = pHtml.matcher(newString);if (mHtml.find()) {newString = mHtml.replaceAll("");}return newString;}public static String firstToLowerCase(String str) {if (stringBlank(str)) {return str;}return str.replaceFirst(String.valueOf(str.charAt(0)), String.valueOf(str.charAt(0)).toLowerCase());}public static List<String> stringArr2List(String[] stringArr) {List<String> resultList = new ArrayList<>();if (stringArr == null) {return resultList;}for (String string : stringArr) {if (StringUtil.stringBlank(string)) {continue;}resultList.add(string);}return resultList;}public static byte[] s2BytesUTF8(String str) {if (stringBlank(str)) {return null;}return str.getBytes(StandardCharsets.UTF_8);}/*** 解码* 编码字符串 --> 文本字符串* 支持对 ASCII与UNICODE混合编码的(脏文本)字符串解码* Eg :  "\"2ABRT3425\\u884C\\u653F\\u590D\\u8BAE\\u8868436FDGDSD\""  -->  2ABRT3425行政复议表** @param unicode* @return*/public static String unicodetoString(String unicode) {if (unicode == null || "".equals(unicode)) {return null;}StringBuilder sb = new StringBuilder();for (int pos = 0; pos < unicode.length(); ) {//"\"2ABRT3425\\u884C\\u653F\\u590D\\u8BAE\\u8868436FDGDSD\"";//System.out.println("pos:"+unicode.substring(pos,pos+1)+" - "+pos);//System.out.println("index:"+unicode.indexOf("\\u", pos)+"\n");if (unicode.indexOf("\\u", pos) - pos == 0) {//unicode编码 Eg: \\2435//System.out.println("pos2:"+unicode.substring(pos,pos+6));if (pos + 6 <= unicode.length()) {Character ch = (char) Integer.parseInt(unicode.substring(pos + 2, pos + 6), 16);//System.out.println("char:"+ch);sb.append(ch);pos += 6;} else {// \\usb.append(unicode, pos, pos + 2);pos += 2;}} else {//非unicode编码sb.append(unicode.charAt(pos));pos += 1;}}return sb.toString();}public static boolean integerBlank(Integer integer) {return integer == null || integer <= 0;}
}

 1.6 主程序加一个监听器

package com.huashang;import com.huashang.listener.ErpApplicationListener;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;@SpringBootApplication
@EnableAsync
@EnableScheduling
@EnableTransactionManagement
@EnableAspectJAutoProxy(proxyTargetClass = true)
@MapperScan("com.huashang.mapper")
@ComponentScan("com.huashang")
public class ErpApplication {public static void main(String[] args) {SpringApplication springApplication = new SpringApplication(ErpApplication.class);// 添加监听器,执行需要在服务启动时执行的业务逻辑springApplication.addListeners(new ErpApplicationListener());springApplication.run(args);}}

 1.7 application.yml文件


只需要修改一下这里就行,是你oss的配置,我这里是阿里的oss

 oss是什么和怎么创建看视频就行:

如何使用OSS控制台、ossutil、ossbrowser、OSSSDK_对象存储 OSS-阿里云帮助中心 (aliyun.com)

创建好了以后,对

以上2个文件都进行以下修改

spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverusername: 'lrerp'password: 'By*****23'url: jdbc:mysql://pc-uf6fv9vxz81ws1y53.rwlb.rds.aliyuncs.com:3306/lingrong?useUnicode=yes&characterEncoding=UTF8&useSSL=false&serverTimezone=Asia/Shanghaiservlet:multipart:enabled: truemax-file-size: 10MBmax-request-size: 20MBaop:auto: truecross:origin: 'lrerp.com'audience:clientId: cbde72f64*****************00d3bbase64Secret: ZWExZjcxNzFi*********E2NGUwZTEzZjgxYmRkMzU=name: restapiuserexpiresSecond: 172800000
liteflow:print-banner: falserule-source-ext-data-map:driverClassName: com.mysql.cj.jdbc.Driverusername: 'lrerp'password: '******3'url: jdbc:mysql://pc-uf6fv9vxz81ws1y53.rwlb.rds.aliyuncs.com:3306/lingrong?useUnicode=yes&characterEncoding=UTF8&useSSL=false&serverTimezone=Asia/ShanghaiapplicationName: lingrongchainTableName: chainchainApplicationNameField: application_namechainNameField: chain_nameelDataField: el_dataalioss:url: file.lrerp.comendpoint: http://oss-cn-shanghai.aliyuncs.comaccessKeyId: LT#****************PPMacceddKeySecret: UVg***************C6LbucketName: lrerp

2. 微信小程序端


2.1 TDesign的upload组件


TDesign的upload组件 (tencent.com)icon-default.png?t=N7T8https://tdesign.tencent.com/miniprogram/components/upload

1. app.json全局引用一下

2. wxml

如图可以看到mediaType中我只保留了模版中的image,bind:add事件我定义了一个handleCertificateAdd(),用于上传我的房屋产权图片,max修改为0,可以上传任意个图片

3. js

js页面主要修改了

1. data的数据:

定义一个数组 `certificateList:[ ]`就行

2. 【重点!】uploadFile()方法

 token

这个token就是数据库中的token的值 

3. handleCertificateAdd()方法

 遍历上传的所有图片,通过调用上面的uploadFile方法

下面来分析这几个红框中的代码

1. 

      this.setData({certificateList: [...(this.data.certificateList), {...file,status: 'loading'}],});

2. 

可以看到task的返回值参数res.progress为100

3. 

 

[`certificateList[${length}].status`]: 'done'

就是把图片的status属性设置为done,图片显示出来不会一直转圈

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

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

相关文章

随机产生两个数在屏幕上打印,例如6*7=? 让学生输入答案,若正确打印答对了,否则提示学生重做,直到答对为止(小游戏)

#include<stdio.h> #include<stdlib.h> #include<time.h>//时间的库函数 int main() {int i 0;srand(time(0));//随机种子初始化int num1 rand() %10;//随机数int num2 rand() %10;printf("%d * %d ?\n", num1, num2);printf("请输入答案…

阿里云无影电脑:免费体验无影云电脑3个月

阿里云无影云电脑免费领取流程&#xff0c;免费无影云电脑配置为4核8G&#xff0c;可以免费使用3个月&#xff0c;阿里云百科分享阿里云无影云电脑&#xff08;云桌面&#xff09;免费申请入口、申请流程及免费使用限制条件说明&#xff1a; 目录 阿里云无影云电脑免费申请入…

【C++初阶】动态内存管理

​&#x1f47b;内容专栏&#xff1a; C/C编程 &#x1f428;本文概括&#xff1a; C/C内存分布、C语言动态内存管理、C动态内存管理、operator new与operator delete函数、new和delete的实现原理、定位new表达式、常见面试问题等。 &#x1f43c;本文作者&#xff1a; 阿四啊 …

CSRF和SSRF有什么不同?

文章目录 CSRF复现SSRF复现启动环境漏洞复现探测存活IP和端口服务计划任务反弹shell 区别 CSRF复现 打开dvwa&#xff0c;将难度调为low&#xff0c;点击CSRF&#xff0c;打开后发现有一个修改密码的输入框&#xff1a; 在这里修改密码&#xff0c;并用bp抓包&#xff0c;在…

C++实现观察者模式(包含源码)

文章目录 观察者模式一、基本概念二、实现方式三、角色四、过程五、结构图六、构建思路七、完整代码 观察者模式 一、基本概念 观察者模式&#xff08;又被称为模型&#xff08;Model&#xff09;-视图&#xff08;View&#xff09;模式&#xff09;是软件设计模式的一种。在…

开启编程之门

自我介绍 目前已经大二了&#xff0c;计算机专业在读&#xff0c;是一个热爱编程&#xff0c;做事踏实专注的人。转眼间一年已经过去了&#xff0c;也接触编程一年了&#xff0c;但开始并没有对所学所想进行很好的总结和输出&#xff0c;这一年也有了新的很多感悟与心得&#x…

浅谈双十一背后的支付宝LDC架构和其CAP分析

本人汤波&#xff0c;superthem.com 圆领超级个体创始人&#xff0c;Github page地址&#xff1a;https://tbwork.github.io/ 看到很多人在盗用我的文章&#xff0c;还标记成原创&#xff0c;进行收费&#xff0c;非常令人作呕。 我的所有技术文章全部免费阅读&#xff0c;大家…

PCB走线规则

1、线间距。 这里应该遵循3W规则&#xff0c;所谓3W就是为了减少线间串扰&#xff0c;应保证线间距足够大&#xff0c;当线中心不少于3倍线宽&#xff0c;则可 保持70%的电场不互相干扰。如要达到98%的电场不互相干扰&#xff0c;可使用10W的间距。——这是查阅华为PCB布线规则…

npm 清缓存(重新安装node-modules)

安装node依赖包的会出现失败的情况&#xff0c;如下图所示&#xff1a; 此时 提示有些依赖树有冲突&#xff0c;根据提示 “ this command with --force or --legacy-peer-deps” 执行命令即可。 具体步骤如下&#xff1a; 1、先删除本地node-modules包 2、删掉page-loacl…

el-upload 上传附件(拆解步骤)

目录 1. 看elementui /element-plus 官网案例 2. html部分&#xff1a; 把官网上的搬下来&#xff0c;最好加一个按钮&#xff0c;上传到服务器&#xff08;后端&#xff09; 3. js 部分&#xff1a; 3.1 首先&#xff0c;先定义一个变量&#xff0c;files 3.2 当上传图片…

机器学习(11)---降维PCA

目录 一、概述1.1 维度1.2 sklearn中的降维算法 二、降维实现原理2.1 PCA与SVD2.2 降维实现2.3 降维过程 三、鸢尾花数据集降维3.1 高维数据的可视化3.2 探索降维后的数据3.3 累积可解释方差贡献率曲线 四、选n_components参数方法4.1 最大似然估计自选超参数4.2 按信息量占比选…

WavJourney:进入音频故事情节生成世界的旅程

推荐&#xff1a;使用 NSDT场景编辑器快速搭建3D应用场景 若要正确查看音频生成的强大功能&#xff0c;请考虑以下方案。我们只需要提供一个简单的指令&#xff0c;描述场景和场景设置&#xff0c;模型就会生成一个扣人心弦的音频脚本&#xff0c;突出与原始指令的最高上下文相…

数组和指针笔试题解析之【数组】

目录 前言&#xff1a; 1.一维数组&#xff1a; 2.字符数组 &#xff1a; 2.1题型一&#xff1a; 2.2题型二&#xff1a; 2.3题型三&#xff1a; 3.二维数组 &#xff1a; 前言&#xff1a; 1.数组名的意义&#xff1a; sizeof(数组名)&#xff1a;这里的数组名表示整…

【C++STL基础入门】list的运算符重载和关于list的算法

文章目录 前言一、list运算符1.1 逻辑运算符1.2 赋值运算符 二、list相关算法2.1 查找函数总结 前言 C标准模板库&#xff08;STL&#xff09;是一组强大而灵活的工具&#xff0c;用于处理数据结构和算法。其中&#xff0c;std::list是STL中的一个重要容器&#xff0c;它实现了…

小型网络实验组网

路漫漫其修远兮&#xff0c;吾将上下而求索 时隔多日&#xff0c;没有更新&#xff0c;今日一写&#xff0c;倍感教育的乐趣。如果让我每天发无意义的文章&#xff0c;我宁可不发。 实验拓扑 实验要求 &#xff08;1&#xff09;内网主机采用DHCP分配IP地址 &#xff08;2&…

记录本地Nginx发布vue项目

一、前端&#xff1a;vue-cli-service build 二、下载Nginx&#xff0c;并创建目录&#xff0c;放置静态文件 三、在conf目录下nginx.conf文件配置代理服务 server {listen 8787;server_name localhost;location / {root app/dist; #前端dist包地址index index.html…

Tomcat架构设计及组件详解

继Tomcat配置详解&#xff08;Tomcat配置server.xml详解&#xff09;Tomcat配置详解&#xff08;Tomcat配置server.xml详解&#xff09;_tomcat xml配置https://blog.csdn.net/imwucx/article/details/132166738文章之后&#xff0c;深入的学习tomcat相关知识&#xff0c;对Tom…

基于SSM+Vue的“魅力”繁峙宣传网站

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;采用Vue技术开发 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#x…

数据分享|R语言逻辑回归、Naive Bayes贝叶斯、决策树、随机森林算法预测心脏病...

全文链接&#xff1a;http://tecdat.cn/?p23061 这个数据集&#xff08;查看文末了解数据免费获取方式&#xff09;可以追溯到1988年&#xff0c;由四个数据库组成。克利夫兰、匈牙利、瑞士和长滩。"目标 "字段是指病人是否有心脏病。它的数值为整数&#xff0c;0无…

无代码和低代码平台:程序员的竞争优势

无代码和低代码平台&#xff1a;程序员的竞争优势 无代码和低代码平台&#xff1a;程序员的竞争优势摘要引言1. 了解无代码和低代码平台1.1 无代码和低代码平台的定义无代码平台低代码平台 1.2 它们如何简化应用程序开发1.3 主要的无代码和低代码工具和供应商无代码平台低代码…