java+postgresql+swagger-多表关联insert操作(九)

入参为json,然后根据需要对多张表进行操作:

入参格式:

{"username": "车主01","usertel": "11111111111","useridtype": "2","useridcard": null,"proname": "天津市","cityname": "天津市市辖区","vinnumber": "2222222222","platenumber": "","cartype": "1","renttype": null,"totalperiods": null,"risklevel": null,"riskcontrolscore": null,"contractno": "","userclasstype": "6","overdueperiods": null,"loandate": null,"endrenttime": null,"inputtime": "2025-04-17T11:33:35","jsonreport": null,"createdbyid": "00000000-0000-0000-0000-000000000000","custstoreName":"swagger-测试经销商01","customerName":"swagger-测试客户01","applyid": "1111111111","credittype": null,"projectprocess": null,"yuqiperiod": null,"settledstatus": null,"startoffline": null,"endoffline": null,"offlineduration": null,"carmodel": "宝马8座 手动 1.5","carseries": "冷藏车老司e","carbrand": "澳柯玛增福改一下22","enginenumber": "","cooperativeunit": null,"lendtime": null,"devicenumber": "987654321","devicemodel": "ZRA5N-8-2","simnumber": "123456789","iswireless": "有线","installposition": "后备箱右侧","installtime": "2025-04-17 13:15:31","supplierid": "测试供应商01","suppliercode": "00001","displaystatus": 2,"simkinds": 1,"installproname": "新疆维吾尔自治区","installcityname": "阿克苏地区","installdistname": "温宿县","installlat": null,"installlng": null,"installperson": "XX000000","simservicecycle": null,"isdisplay": 0,"hosttype": null}

分别往下面表进行写数:

tb_custstoreinfo、tb_supplierinfo、tb_caruserinfo、tb_carusersecondaryinfo、tb_deviceinfo

1、实体:

1.1、表实体:

省略

1.2、入参实体:

package com.example.springbootmybatisplus.dto;import lombok.Data;import java.math.BigDecimal;
import java.util.Date;@Data
public class CarUserDto {private String userName;private String userTel;private String userIdType;private String userIdCard;private String proName;private String cityName;private String vinNumber;private String plateNumber;private String carType;private String rentType;private Integer totalPeriods;private Integer riskLevel;private BigDecimal riskControlScore;private String contractNo;private String userClassType;private String overduePeriods;private Date loanDate;private Date endRentTime;private Date inputTime;private String jsonReport;private String createdById;private String custStoreName;private String customerName;private String applyId;private Integer creditType;private String projectProcess;private String yuqiPeriod;private String settledStatus;private String startOffline;private String endOffline;private BigDecimal offlineDuration;private String carModel;private String carSeries;private String carBrand;private String engineNumber;private String cooperativeUnit;private Date lendTime;private String deviceNumber;private String deviceModel;private String simNumber;private String isWireless;private String installPosition;private Date installTime;private String supplierId;private Short displayStatus;private Short simKinds;private String installProName;private String installCityName;private String installDistName;private BigDecimal installLat;private BigDecimal installLng;private String installPerson;private Short simServiceCycle;private Integer isDisplay;private Integer hostType;private String supplierCode;
}

1.3、其他中间实体:

package com.example.springbootmybatisplus.dto;import lombok.Data;@Data
public class DistrictDto {private String proCode;private String proName;private String cityCode;private String cityName;private String lat;private String lng;
}
package com.example.springbootmybatisplus.entity;import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;import java.io.Serializable;
@Data
public class TbCustStore implements Serializable {/*** 主键(DL)*/@TableId(value = "id", type = IdType.INPUT)private String id;/*** 客户Id*/@TableField(value = "customerid")private String customerId;/*** 上级经销商Id*/@TableField(value = "parentId")private String parentId;/*** 经销商编号*/@TableField(value = "code")private String code;/*** 经销商名称*/@TableField(value = "\"name\"")private String name;/*** 经销商等级*/@TableField(value = "levelCode")private Short levelCode;
}

2、Mapper:

package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbCarUserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbCarUserInfoMapper extends BaseMapper<TbCarUserInfo> {@Select("select Id as carid from tb_caruserinfo where vinnumber = #{vinNumber} and deleted=false limit 1")String getCarId(@Param("vinNumber") String vinNumber);@Select("select 'TC'||nextval('tc')")String getCarUserInfoId();
}
package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbCarUserSecondaryInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbCarUserSecondaryInfoMapper extends BaseMapper<TbCarUserSecondaryInfo> {@Select("select 'CD'||nextval('cd')")String getCarUserSecondaryInfoId();
}
package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbDeviceInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbDeviceInfoMapper extends BaseMapper<TbDeviceInfo> {@Select("select id as DeviceId from tb_deviceinfo where devicenumber = #{deviceNumber} and deleted=false ")String getDeviceId(@Param("deviceNumber") String deviceNumber);@Select("select 'DI'||nextval('di')")String getDeviceInfoId();
}
package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbSupplierinfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbSupplierinfoMapper extends BaseMapper<TbSupplierinfo> {@Select("select * from tb_supplierinfo where name = #{name} and deleted=false limit 1")TbSupplierinfo getSupplierId(@Param("name") String name);@Select("select 'SU'||nextval('su')")String getSupplierinfoId();
}

3、Service:

3.1、对经销商信息进行处理的Service:

package com.example.springbootmybatisplus.service.impl;import com.example.springbootmybatisplus.entity.TbCustStore;
import com.example.springbootmybatisplus.entity.TbCustStoreInfo;
import com.example.springbootmybatisplus.mapper.TbCustStoreInfoMapper;
import com.example.springbootmybatisplus.service.TbPropertyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;
import java.util.Objects;
import java.util.UUID;@Service
public class StoreInfoService {private static final Logger log = LoggerFactory.getLogger(TbPropertyService.class);@Autowiredprivate TbCustStoreInfoMapper tbCustStoreInfoMapper;public void addCustSore(String inCustName, String inCustStoreName, Integer num) {try {if (inCustName == null && inCustStoreName == null) {log.info("输入的经销商或客户名称为空");} else {if (num == 1) {TbCustStore existCustomerId = tbCustStoreInfoMapper.selectTbCustStoreInfo3(inCustName);if (Objects.isNull(existCustomerId)) {log.info("该客户在库中不存在,需要新建");TbCustStoreInfo tbCustStoreInfo = insertTbCustomerInfo(inCustName, 1);tbCustStoreInfoMapper.insert(tbCustStoreInfo);} else {log.info("该客户:{}在库中已存在", inCustName);}}if (num == 2) {TbCustStore existCustStoreId = tbCustStoreInfoMapper.selectTbCustStoreInfo3(inCustStoreName);if (Objects.isNull(existCustStoreId)) {log.info("该经销商在库中不存在,需要新建");TbCustStoreInfo cc = new TbCustStoreInfo();TbCustStore tbCustStore = tbCustStoreInfoMapper.selectTbCustStoreInfo3(inCustName);cc.setId(UUID.randomUUID().toString());cc.setCustomerId((tbCustStore.getCustomerId()));cc.setParentId(tbCustStore.getId());cc.setCustomerdealerid(tbCustStore.getId());cc.setCode(tbCustStoreInfoMapper.getCustStoreCode(tbCustStore.getId()));cc.setLevelCode((short) (tbCustStore.getLevelCode() + 1));cc.setName(inCustStoreName);cc.setType(2);cc.setInsertTime(new Date());tbCustStoreInfoMapper.insert(cc);} else {log.info("该经销商:{}在库中已存在", inCustStoreName);}}}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}public TbCustStoreInfo insertTbCustomerInfo(String inCustName, Integer num) {TbCustStoreInfo bb = new TbCustStoreInfo();String inId = UUID.randomUUID().toString();bb.setId(inId);bb.setCustomerId(inId);bb.setParentId("DL9999999997");bb.setCustomerdealerid(inId);bb.setCode(tbCustStoreInfoMapper.getCustStoreCode("DL9999999997"));bb.setLevelCode(Short.parseShort("2"));bb.setName(inCustName);bb.setType(2);bb.setInsertTime(new Date());return bb;}}

3.2、对供应商进行处理的Service:

package com.example.springbootmybatisplus.service.impl;import com.example.springbootmybatisplus.entity.TbSupplierinfo;
import com.example.springbootmybatisplus.mapper.TbSupplierinfoMapper;
import com.example.springbootmybatisplus.service.TbPropertyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;
import java.util.Objects;@Service
public class SupplierInfoService {private static final Logger log = LoggerFactory.getLogger(TbPropertyService.class);@Autowiredprivate TbSupplierinfoMapper tbSupplierinfoMapper;public void addSupplier(String msg, String code) {try {if (msg == null) {log.info("输入的供应商为空");} else {TbSupplierinfo existsTbSupplierinfo = tbSupplierinfoMapper.getSupplierId(msg);if (Objects.isNull(existsTbSupplierinfo)) {log.info("该供应商在库中不存在,需要新建");TbSupplierinfo tbSupplierinfo = insertTbSupplierinfo(msg, code);tbSupplierinfoMapper.insert(tbSupplierinfo);} else {log.info("该供应商:{}在库中已存在", msg);}}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}public TbSupplierinfo insertTbSupplierinfo(String name, String code) {TbSupplierinfo tbSupplierinfo = new TbSupplierinfo();tbSupplierinfo.setId(tbSupplierinfoMapper.getSupplierinfoId());tbSupplierinfo.setName(name);tbSupplierinfo.setCode(code);tbSupplierinfo.setCreatedById("00000000-0000-0000-0000-000000000000");tbSupplierinfo.setCreatedAt(new Date());tbSupplierinfo.setDeleted(false);return tbSupplierinfo;}}

3.3、实现功能的Service:

package com.example.springbootmybatisplus.service;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.springbootmybatisplus.dto.CarUserDto;
import com.example.springbootmybatisplus.dto.DistrictDto;
import com.example.springbootmybatisplus.entity.*;
import com.example.springbootmybatisplus.mapper.*;
import com.example.springbootmybatisplus.service.impl.StoreInfoService;
import com.example.springbootmybatisplus.service.impl.SupplierInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;
import java.util.Objects;@Service
public class TbCarUserInfoService {private static final Logger log = LoggerFactory.getLogger(TbPropertyService.class);@Autowiredprivate CarUserMapper carUserMapper;@Autowiredprivate TbCarUserInfoMapper tbCarUserInfoMapper;@Autowiredprivate TbCarUserSecondaryInfoMapper tbCarUserSecondaryInfoMapper;@Autowiredprivate TbDeviceInfoMapper tbDeviceInfoMapper;@Autowiredprivate TbCustStoreInfoMapper tbCustStoreInfoMapper;@Autowiredprivate StoreInfoService storeInfoService;@Autowiredprivate TbDistrictMapper tbDistrictMapper;@Autowiredprivate TbSupplierinfoMapper tbSupplierinfoMapper;@Autowiredprivate SupplierInfoService supplierInfoService;public void addCarUser(String msg) {try {CarUserDto carUserDto = JSON.parseObject(msg, CarUserDto.class);if (Objects.isNull(carUserDto)) {log.info("车辆信息为空");return;}storeInfoService.addCustSore(carUserDto.getCustomerName(), carUserDto.getCustStoreName(), 1);storeInfoService.addCustSore(carUserDto.getCustomerName(), carUserDto.getCustStoreName(), 2);supplierInfoService.addSupplier(carUserDto.getSupplierId(), carUserDto.getSupplierCode());if (Objects.isNull(carUserDto.getVinNumber())) {log.error("输入的车架号为空,车架号为非空字段");} else {String existsCarId = tbCarUserInfoMapper.getCarId(carUserDto.getVinNumber());if (Objects.isNull(existsCarId)) {log.info("该车架号不存在系统中,需增加此车架号:{}的信息", carUserDto.getVinNumber());TbCarUserInfo tbCarUserInfo = insertTbCarUserInfo(carUserDto);tbCarUserInfoMapper.insert(tbCarUserInfo);TbCarUserSecondaryInfo tbCarUserSecondaryInfo = insertTbCarUserSecondaryInfo(carUserDto);tbCarUserSecondaryInfoMapper.insert(tbCarUserSecondaryInfo);} else {log.warn("输入的车架号:{}信息已在库中存在,不做任何处理!", carUserDto.getVinNumber());}String existsDeviceId = tbDeviceInfoMapper.getDeviceId(carUserDto.getDeviceNumber());if (Objects.isNull(existsDeviceId)) {log.info("该设备号不存在系统中,需增加此设备号:{}的信息", carUserDto.getDeviceNumber());TbDeviceInfo tbDeviceInfo = insertTbDeviceInfo(carUserDto);tbDeviceInfoMapper.insert(tbDeviceInfo);} else {log.warn("输入的设备号:{}信息已在库中存在,不做任何处理!", carUserDto.getDeviceNumber());}}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}public TbCarUserInfo insertTbCarUserInfo(CarUserDto carUserDto) {TbCarUserInfo tbCarUserInfo = new TbCarUserInfo();DistrictDto districtDto = tbDistrictMapper.selectProCodeAndCityCode(carUserDto.getProName(), carUserDto.getCityName());TbCustStore tbCustStore=tbCustStoreInfoMapper.selectTbCustStoreInfo3(carUserDto.getCustStoreName());tbCarUserInfo.setId(tbCarUserInfoMapper.getCarUserInfoId());tbCarUserInfo.setUserName(carUserDto.getUserName());tbCarUserInfo.setUserTel(carUserDto.getUserTel());tbCarUserInfo.setUserIdType(carUserDto.getUserIdType());tbCarUserInfo.setUserIdCard(carUserDto.getUserIdCard());tbCarUserInfo.setProName(carUserDto.getProName());tbCarUserInfo.setProCode(districtDto.getProCode());tbCarUserInfo.setCityName(carUserDto.getCityName());tbCarUserInfo.setCityCode(districtDto.getCityCode());tbCarUserInfo.setVinNumber(carUserDto.getVinNumber());tbCarUserInfo.setPlateNumber(carUserDto.getPlateNumber());tbCarUserInfo.setCarType(carUserDto.getCarType());tbCarUserInfo.setRentType(carUserDto.getRentType());tbCarUserInfo.setTotalPeriods(carUserDto.getTotalPeriods());tbCarUserInfo.setRiskLevel(carUserDto.getRiskLevel());tbCarUserInfo.setRiskControlScore(carUserDto.getRiskControlScore());tbCarUserInfo.setContractNo(carUserDto.getContractNo());tbCarUserInfo.setUserClassType(carUserDto.getUserClassType());tbCarUserInfo.setOverduePeriods(carUserDto.getOverduePeriods());tbCarUserInfo.setLoanDate(carUserDto.getLoanDate() != null ? carUserDto.getLoanDate() : new Date());tbCarUserInfo.setEndRentTime(carUserDto.getEndRentTime());tbCarUserInfo.setInputTime(carUserDto.getInputTime() != null ? carUserDto.getInputTime() : new Date());tbCarUserInfo.setJsonReport(carUserDto.getJsonReport());tbCarUserInfo.setCreatedById("00000000-0000-0000-0000-000000000000");tbCarUserInfo.setCustomerId(tbCustStore.getCustomerId());tbCarUserInfo.setCuststoreId(tbCustStore.getId());tbCarUserInfo.setApplyId(carUserDto.getApplyId());tbCarUserInfo.setCreditType(carUserDto.getCreditType());tbCarUserInfo.setProjectProcess(carUserDto.getProjectProcess());tbCarUserInfo.setJsonString(JSONObject.toJSONString(carUserDto));tbCarUserInfo.setCreatedAt(new Date());tbCarUserInfo.setDeleted(false);return tbCarUserInfo;}public TbCarUserSecondaryInfo insertTbCarUserSecondaryInfo(CarUserDto carUserDto) {TbCarUserSecondaryInfo tbCarUserSecondaryInfo = new TbCarUserSecondaryInfo();tbCarUserSecondaryInfo.setId(tbCarUserSecondaryInfoMapper.getCarUserSecondaryInfoId());tbCarUserSecondaryInfo.setCarId(tbCarUserInfoMapper.getCarId(carUserDto.getVinNumber()));tbCarUserSecondaryInfo.setYuqiPeriod(carUserDto.getYuqiPeriod());tbCarUserSecondaryInfo.setSettledStatus(carUserDto.getSettledStatus());tbCarUserSecondaryInfo.setStartOffline(carUserDto.getStartOffline());tbCarUserSecondaryInfo.setEndOffline(carUserDto.getEndOffline());tbCarUserSecondaryInfo.setOfflineDuration(carUserDto.getOfflineDuration());tbCarUserSecondaryInfo.setCarModel(carUserDto.getCarModel());tbCarUserSecondaryInfo.setCarSeries(carUserDto.getCarSeries());tbCarUserSecondaryInfo.setCarBrand(carUserDto.getCarBrand());tbCarUserSecondaryInfo.setEngineNumber(carUserDto.getEngineNumber());tbCarUserSecondaryInfo.setCooperativeUnit(carUserDto.getCooperativeUnit());tbCarUserSecondaryInfo.setLendTime(carUserDto.getLendTime() != null ? carUserDto.getLendTime() : new Date());tbCarUserSecondaryInfo.setCreatedById("00000000-0000-0000-0000-000000000000");tbCarUserSecondaryInfo.setCreatedAt(new Date());tbCarUserSecondaryInfo.setDeleted(false);return tbCarUserSecondaryInfo;}public TbDeviceInfo insertTbDeviceInfo(CarUserDto carUserDto) {TbDeviceInfo tbDeviceInfo = new TbDeviceInfo();tbDeviceInfo.setId(tbDeviceInfoMapper.getDeviceInfoId());tbDeviceInfo.setCarId(tbCarUserInfoMapper.getCarId(carUserDto.getVinNumber()));tbDeviceInfo.setDeviceNumber(carUserDto.getDeviceNumber());tbDeviceInfo.setDeviceModel(carUserDto.getDeviceModel());tbDeviceInfo.setSimNumber(carUserDto.getSimNumber());String isWireless = carUserDto.getIsWireless();if ("有线".equals(isWireless)) {tbDeviceInfo.setIsWireless(Short.parseShort("0"));} else if ("无线".equals(isWireless)) {tbDeviceInfo.setIsWireless(Short.parseShort("1"));} else {tbDeviceInfo.setIsWireless(Short.parseShort("2"));}tbDeviceInfo.setInstallPosition(carUserDto.getInstallPosition());tbDeviceInfo.setInstallTime(carUserDto.getInstallTime());tbDeviceInfo.setSupplierid(tbSupplierinfoMapper.getSupplierId(carUserDto.getSupplierId()).getId());tbDeviceInfo.setDisplaystatus(carUserDto.getDisplayStatus());tbDeviceInfo.setSimkinds(carUserDto.getSimKinds());DistrictDto districtDto = tbDistrictMapper.selectProCodeAndCityCode(carUserDto.getInstallProName(), carUserDto.getInstallCityName());if (Objects.isNull(districtDto)){log.warn("未找到对应的省:{}和市:{}的code",carUserDto.getInstallProName(),carUserDto.getInstallCityName());}else {tbDeviceInfo.setInstallProCode(districtDto.getProCode());tbDeviceInfo.setInstallCityCode(districtDto.getCityCode());}tbDeviceInfo.setInstallProName(carUserDto.getInstallProName());tbDeviceInfo.setInstallCityName(carUserDto.getInstallCityName());DistrictDto districtDto1 = tbDistrictMapper.selectProCodeAndCityCode(carUserDto.getInstallCityName(), carUserDto.getInstallDistName());if (Objects.isNull(districtDto1)){log.warn("未找到对应的市:{}和区县:{}的code",carUserDto.getInstallCityName(),carUserDto.getInstallDistName());}else {tbDeviceInfo.setInstallDistCode(districtDto1.getCityCode());}tbDeviceInfo.setInstallDistName(carUserDto.getInstallDistName());tbDeviceInfo.setInstallLat(carUserDto.getInstallLat());tbDeviceInfo.setInstallLng(carUserDto.getInstallLng());tbDeviceInfo.setInstallPerson(carUserDto.getInstallPerson());tbDeviceInfo.setSimServiceCycle(carUserDto.getSimServiceCycle());tbDeviceInfo.setIsDisplay(carUserDto.getDisplayStatus());tbDeviceInfo.setHostType(carUserDto.getHostType());tbDeviceInfo.setCreatedByid("00000000-0000-0000-0000-000000000000");tbDeviceInfo.setCreatedAt(new Date());tbDeviceInfo.setDeleted(false);return tbDeviceInfo;}}

4、Controller:

package com.example.springbootmybatisplus.contronller;import com.example.springbootmybatisplus.service.TbCarUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;@Controller
public class TbCarUserInfoController {@Autowiredprivate TbCarUserInfoService tbCarUserInfoService;@PostMapping("/insert1")public ResponseEntity<String> insert1(@RequestBody String msg) {try {tbCarUserInfoService.addCarUser(msg);return ResponseEntity.status(HttpStatus.CREATED).body("Success");} catch (Exception e) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed");}}
}

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

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

相关文章

JavaSpring 中使用 Redis

创建项目 配置 Redis 服务地址 创建 Controller 类 由于当前只是些简单的测试代码&#xff0c;所以就不进行分层了&#xff0c;只创建一个 Controller 来实现 jedis 通过 jedis 对象里的各种方法来操作 Redis 此处通过 StringRedisTemplate 来操作 Redis 最原始提供的类是 Re…

AI文生图工具推荐

一、AI文生图技术实现原理 AI文生图&#xff08;Text-to-Image&#xff09;基于生成对抗网络&#xff08;GAN&#xff09;或扩散模型&#xff08;Diffusion Model&#xff09;实现&#xff0c;通过深度学习将文本描述转化为图像。其核心流程包括&#xff1a; 文本编码&#xf…

数据结构——快排和归并排序(非递归)

快速排序和归并排序一般都是用递归来实现的&#xff0c;但是掌握非递归也是很重要的&#xff0c;说不定在面试的时候面试官突然问你快排或者归并非递归实现&#xff0c;递归有时候并不好&#xff0c;在数据量非常大的时候效率就不好&#xff0c;但是使用非递归结果就不一样了&a…

【笔记】网络安全管理

计算机硬件中,运算器和控制器通常集成在一块芯片内,一般称为()。 数据库DB、数据库系统DBS、数据库管理系统DBMS,三者之间的关系是()。 OSI/RM体系结构中的网络层与TCP/IP体系结构中的()功能相同。 三级系统应按照等保2.0要求采用密码技术通信过程中数据的()。 …

.net core web api 数据验证(DataAnnotations)

目录 一、什么是 DataAnnotations&#xff1f; 二、扩展验证逻辑&#xff08;自定义验证器&#xff09; 一、什么是 DataAnnotations&#xff1f; DataAnnotations 是一组特性&#xff08;Attributes&#xff09;&#xff0c;用于在模型类上定义验证规则。主要用于属性级别的…

小白从0学习网站搭建的关键事项和避坑指南

以下是针对小白从零学习网站搭建时需要注意的关键事项和避坑指南&#xff0c;帮助你高效学习、少走弯路&#xff1a; 一、学习路径注意事项 不要跳过基础 误区&#xff1a;直接学习框架&#xff08;如 React、Laravel&#xff09;而忽视 HTML/CSS/JS 基础。 正确做法&#xff…

深入剖析JavaScript内存泄漏:识别、定位与实战解决

在JavaScript的世界里&#xff0c;开发者通常不必像使用C那样手动管理内存的分配和释放&#xff0c;这得益于JavaScript引擎内置的垃圾回收&#xff08;Garbage Collection, GC&#xff09;机制。然而&#xff0c;这并不意味着我们可以完全忽视内存管理。“自动"不等于&qu…

2025-04-19 Python 强类型编程

文章目录 1 方法标注1.1 参数与返回值1.2 变参类型1.3 函数类型 2 数据类型2.1 内置类型2.2 复杂数据结构2.3 类别选择2.4 泛型 3 标注方式3.1 注释标注3.2 文件标注 4 特殊情形4.1 前置引用4.2 函数标注扩展4.3 协变与逆变4.4 dataclass 5 高级内容5.1 接口5.2 泛型的协变/逆变…

ETF价格相关性计算算法深度分析

1. 引言 在金融市场中&#xff0c;相关性就像是资产之间“跳舞”的默契程度。想象一下两位舞者&#xff08;ETF&#xff09;&#xff0c;有时步伐一致&#xff0c;有时各跳各的。对于管理大规模资金的投资组合而言&#xff0c;准确理解ETF之间的“舞步同步性”对于风险管理、资…

上海人工智能实验室:LLM无监督自训练

&#x1f4d6;标题&#xff1a;Genius: A Generalizable and Purely Unsupervised Self-Training Framework For Advanced Reasoning &#x1f310;来源&#xff1a;arXiv, 2504.08672 &#x1f31f;摘要 &#x1f538;推进LLM推理技能引起了广泛的兴趣。然而&#xff0c;当前…

【WPF】 在WebView2使用echart显示数据

文章目录 前言一、NuGet安装WebView2二、代码部分1.xaml中引入webview22.编写html3.在WebView2中加载html4.调用js方法为Echarts赋值 总结 前言 为了实现数据的三维效果&#xff0c;所以需要使用Echarts&#xff0c;但如何在WPF中使用Echarts呢&#xff1f; 一、NuGet安装WebV…

2025年3月 Python编程等级考试 2级真题试卷

2025年3月青少年软件编程Python等级考试&#xff08;二级&#xff09;真题试卷 题目总数&#xff1a;37 总分数&#xff1a;100 选择题 第 1 题 单选题 老师要求大家记住四大名著的作者&#xff0c;小明机智地想到了可以用字典进行记录&#xff0c;以下哪个选项的字典…

6. 话题通信 ---- 使用自定义msg,发布方和订阅方cpp,python文件编写

1)在功能包下新建msg目录&#xff0c;在msg目录下新建Person.msg,在Person.msg文件写入&#xff1a; string name uint16 age float64 height 2)修改配置文件 2.1) 功能包下package.xml文件修改 <build_depend>message_generation</build_depend><exec_depend…

多线程使用——线程安全、线程同步

一、线程安全 &#xff08;一&#xff09;什么是线程安全问题 多个线程&#xff0c;同时操作同一个共享资源的时候&#xff0c;可能会出现业务安全的问题。 &#xff08;二&#xff09;用程序摹拟线程安全问题 二、线程同步 &#xff08;一&#xff09;同步思想概述 解决线…

4. 话题通信 ---- 发布方和订阅方cpp文件编写

本节对应赵虚左ROS书籍的2.1.2 以10hz,发布消息和消息的订阅 1) 在功能包的src文件夹下&#xff0c;新建cpp文件&#xff0c;并且写入 #include "ros/ros.h" #include "std_msgs/String.h" int main(int argc, char *argv[]) {setlocale(LC_ALL,"&…

有哪些哲学流派适合创业二

好的&#xff0c;让我们更深入地探讨如何将‌哲学与数学‌深度融合&#xff0c;构建一套可落地的创业操作系统。以下从‌认知框架、决策引擎、执行算法‌三个维度展开&#xff0c;包含具体工具和黑箱拆解&#xff1a; ‌一、认知框架&#xff1a;用哲学重构商业本质‌ 1. ‌本体…

【后端】【python】Python 爬虫常用的框架解析

一、总结 Python 爬虫常用的框架主要分为 三类&#xff1a; 轻量级请求库&#xff1a;如 requests、httpx&#xff0c;用于快速发请求。解析与处理库&#xff1a;如 BeautifulSoup、lxml、pyquery。爬虫框架系统&#xff1a;如 Scrapy、pyspider、Selenium、Playwright 等&am…

力扣-hot100(无重复字符的最长子串)

3. 无重复字符的最长子串 中等 给定一个字符串 s &#xff0c;请你找出其中不含有重复字符的 最长 子串 的长度。 示例 1: 输入: s "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc"&#xff0c;所以其长度为 3。暴力直观解法一&#xff1…

六边形棋盘格(Hexagonal Grids)的坐标

1. 二位坐标转六边形棋盘的方式 1-1这是“波动式”的 这种就是把【方格子坐标】“左右各错开半个格子”做到的 具体来说有如下几种情况 具体到庙算平台上&#xff0c;是很巧妙的用一个4位整数&#xff0c;前两位为x、后两位为y来进行表示 附上计算距离的代码 def get_hex_di…

C++之虚函数 Virtual Function

1. 普通虚函数&#xff08;Virtual Function&#xff09; 定义&#xff1a;基类中用 virtual 声明&#xff0c;允许派生类 覆盖&#xff08;Override&#xff09;。特点&#xff1a; 基类可提供默认实现。派生类可选择性覆盖&#xff08;若不覆盖&#xff0c;则调用基类版本&a…