CSGO 皮膚交易平臺后端 (Spring Boot) 代碼結構與示例

csgo-market/
├── pom.xml (or build.gradle)
└── src/└── main/├── java/│   └── com/│       └── yourcompany/│           └── csgomarket/│               ├── CsgomarketApplication.java  # Spring Boot 啟動類│               ├── config/                     # 配置類 (SecurityConfig, JacksonConfig...)│               ├── controller/                 # RESTful API 控制器│               │   ├── UserController.java│               │   ├── ListingController.java│               │   └── ...│               ├── dto/                        # 數據傳輸對象│               │   ├── UserDTO.java│               │   ├── ListingDTO.java│               │   ├── CreateListingDTO.java│               │   └── ...│               ├── entity/                     # JPA 實體類 (對應數據庫表)│               │   ├── User.java│               │   ├── SkinDefinition.java│               │   ├── UserInventoryItem.java│               │   ├── Listing.java│               │   ├── Transaction.java│               │   └── ...│               ├── enums/                      # 枚舉類型 (ListingStatus, TransactionType...)│               │   ├── ListingStatus.java│               │   └── ...│               ├── exception/                  # 自定義異常類 & 全局異常處理│               │   ├── GlobalExceptionHandler.java│               │   └── ResourceNotFoundException.java│               ├── repository/                 # Spring Data JPA Repositories│               │   ├── UserRepository.java│               │   ├── ListingRepository.java│               │   └── ...│               ├── service/                    # 業務邏輯服務接口│               │   ├── UserService.java│               │   ├── ListingService.java│               │   ├── SteamService.java  # (非常重要且復雜)│               │   └── ...│               ├── service/impl/               # 業務邏輯服務實現│               │   ├── UserServiceImpl.java│               │   ├── ListingServiceImpl.java│               │   └── ...│               └── util/                       # 工具類└── resources/├── application.properties (or application.yml) # 配置文件├── db/migration/                           # 數據庫遷移腳本 (Flyway/Liquibase)└── static/                                 # 靜態資源 (如果前后端不分離)└── templates/                              # 服務端模板 (如果使用 Thymeleaf 等)

1. 實體(列表.java

package com.yourcompany.csgomarket.entity;import com.yourcompany.csgomarket.enums.ListingStatus;
import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;import java.math.BigDecimal;
import java.time.LocalDateTime;@Entity
@Table(name = "listings")
@Data
@NoArgsConstructor
public class Listing {@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Long id;// Unique=true 應由業務邏輯或數據庫約束保證一個 item 只有一個 active listing@OneToOne(fetch = FetchType.LAZY)@JoinColumn(name = "inventory_item_id", referencedColumnName = "id", nullable = false, unique = true)private UserInventoryItem inventoryItem;@ManyToOne(fetch = FetchType.LAZY)@JoinColumn(name = "seller_id", nullable = false)private User seller;@Column(nullable = false, precision = 15, scale = 2)private BigDecimal price;@Enumerated(EnumType.STRING)@Column(nullable = false, length = 20)private ListingStatus status = ListingStatus.ACTIVE;@CreationTimestamp@Column(nullable = false, updatable = false)private LocalDateTime createdAt;@UpdateTimestamp@Column(nullable = false)private LocalDateTime updatedAt;@Columnprivate LocalDateTime soldAt;// Constructors, Getters, Setters (Lombok handles this)
}

2. 存儲庫(ListingRepository.java

package com.yourcompany.csgomarket.repository;import com.yourcompany.csgomarket.entity.Listing;
import com.yourcompany.csgomarket.entity.User;
import com.yourcompany.csgomarket.enums.ListingStatus;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; // For dynamic queries
import org.springframework.stereotype.Repository;import java.util.List;
import java.util.Optional;@Repository
public interface ListingRepository extends JpaRepository<Listing, Long>, JpaSpecificationExecutor<Listing> {// Find active listings by sellerPage<Listing> findBySellerAndStatus(User seller, ListingStatus status, Pageable pageable);// Find listing by inventory item ID (useful for checking duplicates)Optional<Listing> findByInventoryItemId(Long inventoryItemId);// Example using Specification for dynamic filtering/searching (needs implementation elsewhere)// Page<Listing> findAll(Specification<Listing> spec, Pageable pageable);// Find multiple listings by their IDsList<Listing> findByIdIn(List<Long> ids);
}

3. DTO(創建列表DTO.java

package com.yourcompany.csgomarket.dto;import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotNull;
import lombok.Data;import java.math.BigDecimal;@Data
public class CreateListingDTO {@NotNull(message = "Inventory item ID cannot be null")private Long inventoryItemId;@NotNull(message = "Price cannot be null")@DecimalMin(value = "0.01", message = "Price must be greater than 0")private BigDecimal price;// Seller ID will usually be inferred from the authenticated user context
}

4. DTO(ListingDTO.java- 用于 API 響應)

package com.yourcompany.csgomarket.dto;import com.yourcompany.csgomarket.enums.ListingStatus;
import lombok.Data;import java.math.BigDecimal;
import java.time.LocalDateTime;@Data
public class ListingDTO {private Long id;private UserInventoryItemDTO inventoryItem; // Another DTO for item detailsprivate UserSummaryDTO seller; // Simplified user DTOprivate BigDecimal price;private ListingStatus status;private LocalDateTime createdAt;private LocalDateTime soldAt;
}

5. 服務接口(列表服務.java

package com.yourcompany.csgomarket.service;import com.yourcompany.csgomarket.dto.CreateListingDTO;
import com.yourcompany.csgomarket.dto.ListingDTO;
import com.yourcompany.csgomarket.entity.User; // Assuming User entity represents authenticated user
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;public interface ListingService {/*** Creates a new listing for the authenticated user.* Requires complex logic involving inventory check and potentially Steam interaction.*/ListingDTO createListing(CreateListingDTO createListingDTO, User seller);/*** Retrieves a listing by its ID.*/ListingDTO getListingById(Long id);/*** Cancels an active listing owned by the user.*/void cancelListing(Long listingId, User owner);/*** Retrieves listings based on filter criteria (complex).* This would involve dynamic query building.*/Page<ListingDTO> findListings(/* Filter criteria DTO */ Object filter, Pageable pageable);/*** Retrieves listings created by a specific user.*/Page<ListingDTO> findMyListings(User seller, Pageable pageable);// ... other methods like handling purchase, updating status etc.
}

6. 服務實施(ListingServiceImpl.java- 簡化示例)

package com.yourcompany.csgomarket.service.impl;import com.yourcompany.csgomarket.dto.CreateListingDTO;
import com.yourcompany.csgomarket.dto.ListingDTO;
import com.yourcompany.csgomarket.entity.Listing;
import com.yourcompany.csgomarket.entity.User;
import com.yourcompany.csgomarket.entity.UserInventoryItem;
import com.yourcompany.csgomarket.enums.ListingStatus;
import com.yourcompany.csgomarket.enums.InventoryItemStatus; // Assuming enum exists
import com.yourcompany.csgomarket.exception.ResourceNotFoundException;
import com.yourcompany.csgomarket.exception.InvalidOperationException;
import com.yourcompany.csgomarket.repository.ListingRepository;
import com.yourcompany.csgomarket.repository.UserInventoryItemRepository;
import com.yourcompany.csgomarket.service.ListingService;
import com.yourcompany.csgomarket.service.SteamService; // Crucial dependency
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper; // Or MapStruct
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;@Service
@RequiredArgsConstructor // Lombok for constructor injection
public class ListingServiceImpl implements ListingService {private final ListingRepository listingRepository;private final UserInventoryItemRepository inventoryItemRepository;private final SteamService steamService; // For inventory sync and potentially bot interactionprivate final ModelMapper modelMapper; // For DTO mapping@Override@Transactionalpublic ListingDTO createListing(CreateListingDTO createListingDTO, User seller) {// 1. Validate inventory item exists and belongs to the sellerUserInventoryItem item = inventoryItemRepository.findByIdAndUserId(createListingDTO.getInventoryItemId(), seller.getId()).orElseThrow(() -> new ResourceNotFoundException("Inventory item not found or does not belong to user"));// 2. Check if item is already listed or in an invalid stateif (item.getStatus() != InventoryItemStatus.ON_PLATFORM) { // Assuming ON_PLATFORM means ready to be listedthrow new InvalidOperationException("Item is not in a listable state (status: " + item.getStatus() + ")");}listingRepository.findByInventoryItemId(item.getId()).filter(l -> l.getStatus() == ListingStatus.ACTIVE).ifPresent(l -> { throw new InvalidOperationException("Item is already listed actively."); });// --- !! Placeholder for complex logic !! ---// 3. [Optional, depending on model] Interact with Steam Bot?//    Maybe move item to a trade bot if using a centralized model.//    This is highly complex and error-prone.//    boolean botTransferSuccess = steamService.requestItemTransferToBot(item.getAssetId(), seller.getTradeOfferUrl());//    if (!botTransferSuccess) { throw new RuntimeException("Failed to transfer item to bot"); }// --- End Placeholder ---// 4. Create and save the listing entityListing newListing = new Listing();newListing.setInventoryItem(item);newListing.setSeller(seller);newListing.setPrice(createListingDTO.getPrice());newListing.setStatus(ListingStatus.ACTIVE); // Set initial statusListing savedListing = listingRepository.save(newListing);// 5. Update inventory item statusitem.setStatus(InventoryItemStatus.LISTED);inventoryItemRepository.save(item);// 6. Map to DTO and returnreturn convertToListingDTO(savedListing);}@Overridepublic ListingDTO getListingById(Long id) {Listing listing = listingRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Listing not found with id: " + id));return convertToListingDTO(listing);}@Override@Transactionalpublic void cancelListing(Long listingId, User owner) {Listing listing = listingRepository.findById(listingId).orElseThrow(() -> new ResourceNotFoundException("Listing not found with id: " + listingId));if (!listing.getSeller().getId().equals(owner.getId())) {throw new InvalidOperationException("User is not the owner of this listing.");}if (listing.getStatus() != ListingStatus.ACTIVE) {throw new InvalidOperationException("Only active listings can be cancelled.");}// --- !! Placeholder for complex logic !! ---// [Optional, depending on model] Interact with Steam Bot?// If item was transferred to a bot, initiate return transfer.// boolean returnSuccess = steamService.requestItemReturnFromBot(listing.getInventoryItem().getAssetId(), owner.getTradeOfferUrl());// if (!returnSuccess) { throw new RuntimeException("Failed to return item from bot"); }// --- End Placeholder ---listing.setStatus(ListingStatus.CANCELLED);listingRepository.save(listing);// Update inventory item status backUserInventoryItem item = listing.getInventoryItem();item.setStatus(InventoryItemStatus.ON_PLATFORM); // Or back to IN_STEAM if returnedinventoryItemRepository.save(item);}@Overridepublic Page<ListingDTO> findMyListings(User seller, Pageable pageable) {Page<Listing> listingsPage = listingRepository.findBySellerAndStatus(seller, ListingStatus.ACTIVE, pageable); // Example: find only activereturn listingsPage.map(this::convertToListingDTO);}// Implement findListings with SpecificationExecutor for filtering// --- Helper Method for DTO Conversion ---private ListingDTO convertToListingDTO(Listing listing) {ListingDTO dto = modelMapper.map(listing, ListingDTO.class);// Manual mapping or configuration for nested DTOs might be needed// dto.setInventoryItem(modelMapper.map(listing.getInventoryItem(), UserInventoryItemDTO.class));// dto.setSeller(modelMapper.map(listing.getSeller(), UserSummaryDTO.class));// Handle potential lazy loading issues if necessarydto.setInventoryItem(mapInventoryItem(listing.getInventoryItem())); // Example manual mapdto.setSeller(mapUserSummary(listing.getSeller())); // Example manual mapreturn dto;}// Example manual mapping helpers (replace with ModelMapper/MapStruct config)private UserInventoryItemDTO mapInventoryItem(UserInventoryItem item) {if (item == null) return null;UserInventoryItemDTO dto = new UserInventoryItemDTO();// ... map fields ...dto.setId(item.getId());// Make sure SkinDefinition is loaded or handle proxyif (item.getSkinDefinition() != null) {dto.setMarketHashName(item.getSkinDefinition().getMarketHashName());dto.setName(item.getSkinDefinition().getName());dto.setIconUrl(item.getSkinDefinition().getIconUrl());// ... other definition fields}dto.setWearFloat(item.getWearFloat());// ... etc. ...return dto;}private UserSummaryDTO mapUserSummary(User user) {if (user == null) return null;UserSummaryDTO dto = new UserSummaryDTO();dto.setSteamId(user.getSteamId());dto.setPlatformUsername(user.getPlatformUsername());dto.setAvatarUrl(user.getAvatarUrl());return dto;}
}

7. 控制器(列表控制器.java

package com.yourcompany.csgomarket.controller;import com.yourcompany.csgomarket.dto.CreateListingDTO;
import com.yourcompany.csgomarket.dto.ListingDTO;
import com.yourcompany.csgomarket.entity.User; // Assume this comes from Security Context
import com.yourcompany.csgomarket.service.ListingService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
// import org.springframework.security.core.annotation.AuthenticationPrincipal; // For getting User
import org.springframework.web.bind.annotation.*;@RestController
@RequestMapping("/api/listings")
@RequiredArgsConstructor
public class ListingController {private final ListingService listingService;// --- Public Endpoints ---@GetMapping("/{id}")public ResponseEntity<ListingDTO> getListingById(@PathVariable Long id) {ListingDTO listing = listingService.getListingById(id);return ResponseEntity.ok(listing);}@GetMappingpublic ResponseEntity<Page<ListingDTO>> searchListings(/* @RequestParam Map<String, String> filters, // Or specific DTO for filters */@PageableDefault(size = 20, sort = "createdAt") Pageable pageable) {// Page<ListingDTO> listings = listingService.findListings(filters, pageable);// return ResponseEntity.ok(listings);// Simplified placeholder:return ResponseEntity.ok(Page.empty(pageable)); // Replace with actual implementation}// --- Authenticated Endpoints ---@PostMappingpublic ResponseEntity<ListingDTO> createListing(@Valid @RequestBody CreateListingDTO createListingDTO //,/* @AuthenticationPrincipal User currentUser */) { // Inject authenticated user// !! Replace null with actual authenticated user !!User currentUser = getCurrentAuthenticatedUserPlaceholder();if (currentUser == null) return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();ListingDTO createdListing = listingService.createListing(createListingDTO, currentUser);return ResponseEntity.status(HttpStatus.CREATED).body(createdListing);}@GetMapping("/my")public ResponseEntity<Page<ListingDTO>> getMyListings(/* @AuthenticationPrincipal User currentUser, */@PageableDefault(size = 10) Pageable pageable) {// !! Replace null with actual authenticated user !!User currentUser = getCurrentAuthenticatedUserPlaceholder();if (currentUser == null) return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();Page<ListingDTO> myListings = listingService.findMyListings(currentUser, pageable);return ResponseEntity.ok(myListings);}@DeleteMapping("/{id}")public ResponseEntity<Void> cancelMyListing(@PathVariable Long id //,/* @AuthenticationPrincipal User currentUser */) {// !! Replace null with actual authenticated user !!User currentUser = getCurrentAuthenticatedUserPlaceholder();if (currentUser == null) return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();listingService.cancelListing(id, currentUser);return ResponseEntity.noContent().build();}// --- Placeholder for getting authenticated user ---// Replace this with actual Spring Security integration (@AuthenticationPrincipal)private User getCurrentAuthenticatedUserPlaceholder() {// In real app, get this from SecurityContextHolder or @AuthenticationPrincipalUser user = new User();user.setId(1L); // Example IDuser.setSteamId("76561198000000001"); // Example Steam IDreturn user;}
}

前端 (Vue 3 + Pinia + Axios + Element Plus) 代碼結構與示例

csgo-market-ui/
├── public/
├── src/
│   ├── assets/         # 靜態資源 (CSS, images)
│   ├── components/     # 可復用 UI 組件
│   │   ├── SkinCard.vue
│   │   ├── ListingForm.vue
│   │   └── ...
│   ├── layouts/        # 頁面布局 (DefaultLayout.vue)
│   ├── pages/ (or views/) # 頁面級組件
│   │   ├── HomePage.vue
│   │   ├── MarketplacePage.vue
│   │   ├── ItemDetailPage.vue
│   │   ├── UserProfilePage.vue
│   │   ├── MyListingsPage.vue
│   │   └── LoginPage.vue
│   ├── plugins/        # Vue 插件 (axios, element-plus)
│   ├── router/         # Vue Router 配置
│   │   └── index.js
│   ├── services/ (or api/) # API 請求封裝
│   │   ├── axiosInstance.js
│   │   ├── listingService.js
│   │   ├── userService.js
│   │   └── authService.js
│   ├── stores/         # Pinia 狀態管理
│   │   ├── authStore.js
│   │   └── userStore.js
│   ├── App.vue         # 根組件
│   └── main.js         # 入口文件
├── index.html
├── vite.config.js (or vue.config.js)
└── package.json

1. API 服務(服務/listingService.js

import axiosInstance from './axiosInstance'; // Your configured axios instanceconst API_URL = '/listings'; // Base URL relative to backendexport const listingService = {getListingById(id) {return axiosInstance.get(`${API_URL}/${id}`);},searchListings(params) {// params could include page, size, sort, filtersreturn axiosInstance.get(API_URL, { params });},createListing(createListingDTO) {return axiosInstance.post(API_URL, createListingDTO);},getMyListings(params) {// params could include page, sizereturn axiosInstance.get(`${API_URL}/my`, { params });},cancelMyListing(id) {return axiosInstance.delete(`${API_URL}/${id}`);}
};

2. Pinia 商店 (商店/authStore.js

import { defineStore } from 'pinia';
import { ref } from 'vue';
// import { authService } from '@/services/authService'; // Your auth serviceexport const useAuthStore = defineStore('auth', () => {const isAuthenticated = ref(false);const user = ref(null); // Store basic user info like ID, steamId, usernameconst token = ref(localStorage.getItem('authToken') || null); // Example token storage// Setup axios interceptor to add token to headers// ...async function loginWithSteam() {// 1. Redirect user to backend Steam login endpoint//    window.location.href = '/api/auth/steam'; // Example backend endpoint// 2. After successful redirect back from Steam & backend://    Backend should provide a token (e.g., JWT)//    This function might be called on the redirect callback page// await fetchUserAndTokenAfterRedirect();console.warn("Steam Login logic needs implementation!");// Placeholder:isAuthenticated.value = true;user.value = { id: 1, steamId: '7656...', platformUsername: 'DemoUser' };token.value = 'fake-jwt-token';localStorage.setItem('authToken', token.value);// Setup axios header with token.value}function logout() {isAuthenticated.value = false;user.value = null;token.value = null;localStorage.removeItem('authToken');// Remove token from axios headers// Redirect to login page or home page}// async function fetchUserAndTokenAfterRedirect() { /* ... */ }return { isAuthenticated, user, token, loginWithSteam, logout };
});

3. 頁面組件(頁面/MyListingsPage.vue

<template><div class="my-listings-page"><h1>My Active Listings</h1><el-button @click="fetchListings" :loading="loading" type="primary" plain>Refresh</el-button><el-table :data="listings" style="width: 100%" v-loading="loading" empty-text="No active listings found"><el-table-column label="Item"><template #default="scope"><div style="display: flex; align-items: center;"><el-imagestyle="width: 50px; height: 50px; margin-right: 10px;":src="scope.row.inventoryItem?.iconUrl || defaultImage"fit="contain"/><span>{{ scope.row.inventoryItem?.name || 'N/A' }}</span></div></template></el-table-column><el-table-column prop="inventoryItem.wearFloat" label="Wear" :formatter="formatWear" /><el-table-column prop="price" label="Price"><template #default="scope">¥{{ scope.row.price?.toFixed(2) }}</template></el-table-column><el-table-column prop="createdAt" label="Listed At"><template #default="scope">{{ formatDate(scope.row.createdAt) }}</template></el-table-column><el-table-column label="Actions"><template #default="scope"><el-buttonsize="small"type="danger"@click="handleCancel(scope.row.id)":loading="cancellingId === scope.row.id">Cancel</el-button></template></el-table-column></el-table><el-paginationv-if="total > 0"backgroundlayout="prev, pager, next, sizes, total":total="total":page-sizes="[10, 20, 50]"v-model:current-page="currentPage"v-model:page-size="pageSize"@size-change="handleSizeChange"@current-change="handleCurrentChange"style="margin-top: 20px; justify-content: flex-end;"/></div>
</template><script setup>
import { ref, onMounted, watch } from 'vue';
import { listingService } from '@/services/listingService';
import { ElMessage, ElMessageBox } from 'element-plus';
import defaultImage from '@/assets/placeholder.png'; // Placeholder imageconst listings = ref([]);
const loading = ref(false);
const cancellingId = ref(null);
const total = ref(0);
const currentPage = ref(1);
const pageSize = ref(10);async function fetchListings() {loading.value = true;try {const params = {page: currentPage.value - 1, // Spring Pageable is 0-indexedsize: pageSize.value,// sort: 'createdAt,desc' // Example sort};const response = await listingService.getMyListings(params);listings.value = response.data.content; // Assuming Spring Page<> structuretotal.value = response.data.totalElements;} catch (error) {console.error("Error fetching listings:", error);ElMessage.error('Failed to load listings.');listings.value = []; // Clear on errortotal.value = 0;} finally {loading.value = false;}
}async function handleCancel(id) {await ElMessageBox.confirm('Are you sure you want to cancel this listing?','Warning',{confirmButtonText: 'Yes, Cancel',cancelButtonText: 'No',type: 'warning',}).then(async () => {cancellingId.value = id;try {await listingService.cancelMyListing(id);ElMessage.success('Listing cancelled successfully.');// Refresh the list after cancellingfetchListings();} catch (error) {console.error("Error cancelling listing:", error);ElMessage.error(error.response?.data?.message || 'Failed to cancel listing.');} finally {cancellingId.value = null;}}).catch(() => {// User cancelled the confirmation dialogElMessage.info('Cancellation aborted');});}function handleSizeChange(val) {pageSize.value = val;currentPage.value = 1; // Reset to first page when size changesfetchListings();
}function handleCurrentChange(val) {currentPage.value = val;fetchListings();
}// Formatters
function formatWear(row, column, cellValue) {return cellValue ? cellValue.toFixed(6) : 'N/A'; // Example formatting
}function formatDate(dateString) {if (!dateString) return 'N/A';try {return new Date(dateString).toLocaleString();} catch (e) {return dateString; // Fallback}
}onMounted(() => {fetchListings();
});// Optional: Watch for page/size changes if needed elsewhere
// watch([currentPage, pageSize], fetchListings);</script><style scoped>
.my-listings-page {padding: 20px;
}
/* Add more specific styles */
</style>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/75352.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/75352.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/75352.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mac Python多版本第三方庫的安裝路徑

終端查看python版本是 3.12&#xff0c;但是pycharm使用的python版本是 3.9 終端正常安裝包以后&#xff0c;pycharm都可以正常使用&#xff0c;但是將 pycharm的python換成 3.12 版本&#xff0c;之前安裝的庫都沒有了 通過終端查看安裝庫的位置&#xff0c;確實是安裝到py…

Java常用異步方式總結

使用建議 完整代碼見https://gitee.com/pinetree-cpu/parent-demon 提供了postMan調試json文件于security-demo/src/main/resources/test_file/java-async.postman_collection.json 可導入postMan中進行調試 Java異步方式以及使用場景 繼承Thread類 新建三個類繼承Thread&…

【VUE3】Pinia

目錄 0前言 1 手動添加Pinia 2 創建與使用倉庫&#xff08;Setup Store 組合式&#xff09; 2.1 創建倉庫 2.2 使用倉庫數據 2.3 解構響應式數據 3 持久化插件 0前言 官網&#xff1a;Pinia | The intuitive store for Vue.js 1 手動添加Pinia 上手之后&#xff0c;可…

JVM 每個區域分別存儲什么數據?

JVM&#xff08;Java Virtual Machine&#xff09;的運行時數據區&#xff08;Runtime Data Areas&#xff09;被劃分為幾個不同的區域&#xff0c;每個區域都有其特定的用途和存儲的數據類型。以下是 JVM 各個區域存儲數據的詳細說明&#xff1a; 1. 程序計數器 (Program Cou…

C++中shared_ptr 是線程安全的嗎?

在 C 中&#xff0c;shared_ptr 的線程安全性和實現原理可以通過以下方式通俗理解&#xff1a; 1. shared_ptr 是線程安全的嗎&#xff1f; 答案&#xff1a;部分安全&#xff0c;需分場景&#xff01; 安全的操作&#xff1a; 引用計數的增減&#xff1a;多個線程同時復制或銷…

什么是 CSSD?

文章目錄 一、什么是 CSSD&#xff1f;CSSD 的職責 二、CSSD 是如何工作的&#xff1f;三、CSSD 為什么會重啟節點&#xff1f;情況一&#xff1a;網絡和存儲都斷聯&#xff08;失聯&#xff09;情況二&#xff1a;收到其他節點對自己的踢出通知&#xff08;外部 fencing&#…

arm64平臺下linux訪問寄存器

通用寄存器 示例&#xff1a;讀取寄存器值 // 用戶態程序或內核代碼中均可使用 unsigned long reg_value; asm volatile ("mov %0, x10" // 將X10的值保存到reg_value變量: "r" (reg_value) ); printk("X10 0x%lx\n", reg_value);示例&…

超級好用的小軟件,連接電腦和手機。

將手機變成電腦攝像頭的高效工具Iriun Webcam是一款多平臺軟件&#xff0c;能夠將手機攝像頭變成電腦的攝像頭&#xff0c;通過簡單的設置即可實現視頻會議、直播、錄制等功能。它支持Windows、Mac和Linux系統&#xff0c;同時兼容iOS和Android手機&#xff0c;操作簡單&#x…

Mysql MIC高可用集群搭建

1、介紹 MySQL InnoDB Cluster&#xff08;MIC&#xff09;是基于 MySQL Group Replication&#xff08;MGR&#xff09;的高可用性解決方案&#xff0c;結合 MySQL Shell 和 MySQL Router&#xff0c;提供自動故障轉移和讀寫分離功能&#xff0c;非常適合生產環境 2、部署 …

PERL開發環境搭建>>Windows,Linux,Mac OS

特點 簡單 快速 perl解釋器直接對源代碼程序解釋執行,是一個解釋性的語言, 不需要編譯器和鏈接器來運行代碼>>速度快 靈活 借鑒了C/C, Basic, Pascal, awk, sed等多種語言, 定位于實用性語言,既具備了腳本語言的所有功能,也添加了高級語言功能 開源.免費 沒有&qu…

ubuntu改用戶權限

在 Linux 系統中&#xff0c;賦予普通用戶 sudo 權限可以讓他們執行一些需要 root 權限的命令&#xff0c;而不需要頻繁切換到 root 用戶。以下是具體步驟&#xff1a; 創建用戶(useradd和adduser兩種方式) 首先&#xff0c;需要創建一個新的用戶。可以使用 adduser 或 usera…

藍橋杯 web 學海無涯(axios、ecahrts)版本二

答案&#xff1a; // TODO: 待補充代碼// 初始化圖表的數據&#xff0c;設置周視圖的初始數據 option.series[0].data [180, 274, 253, 324, 277, 240, 332, 378, 101]; // 周數據&#xff08;每周的總學習時長&#xff09; option.xAxis.data ["2月第1周", "…

Java 大視界 -- Java 大數據在智慧文旅虛擬場景構建與沉浸式體驗增強中的技術支撐(168)

&#x1f496;親愛的朋友們&#xff0c;熱烈歡迎來到 青云交的博客&#xff01;能與諸位在此相逢&#xff0c;我倍感榮幸。在這飛速更迭的時代&#xff0c;我們都渴望一方心靈凈土&#xff0c;而 我的博客 正是這樣溫暖的所在。這里為你呈上趣味與實用兼具的知識&#xff0c;也…

API vs 網頁抓取:獲取數據的最佳方式

引言 在當今數字化時代&#xff0c;對于企業、研究人員以及開發人員而言&#xff0c;獲取準確且及時的數據是大多數項目成功的關鍵因素。目前&#xff0c;收集網頁數據主要有兩種常用方法&#xff0c;即使用 API&#xff08;應用程序接口&#xff09;和網頁抓取。然而&#xf…

車載以太網網絡測試-25【SOME/IP-報文格式-1】

目錄 1 摘要2 SOME/IP-報文格式2.1 **Service ID / 16 bits**2.2 **Method ID / Event ID / 16 bits**2.3 **Length / 32 bits**2.4 **Client ID / 16 bits**2.5 Session ID / 16 bits2.6 Protocol Version / 8 bits2.7 Interface Version / 8 bits2.8 Message Type / 8 bits2.…

Python數據可視化-第3章-圖表輔助元素的定制

環境 開發工具 VSCode庫的版本 numpy1.26.4 matplotlib3.10.1 ipympl0.9.7教材 本書為《Python數據可視化》一書的配套內容&#xff0c;本章為第3章-圖表輔助元素的定制 本章主要介紹了圖表輔助元素的定制&#xff0c;包括認識常用的輔助元素、設置坐標軸的標簽、設置刻度范…

小程序30-wxml語法-聲明和綁定數據

小程序頁面中使用的數據均需要在Page() 方法的 data對象中進行聲明定義 在將數據聲明好以后&#xff0c;在 WXML 使用 Mustache 語法 ( 雙大括號{{ }} ) 將變量包起來&#xff0c;從而將數據綁定 在 {{ }} 內部可以做一些簡單的運算&#xff0c;支持如下幾種方式: 算數運算三…

ubuntu開啟黑屏現象解決

文章目錄 前言一、問題描述二、解決方案1. 檢查顯卡驅動解決步驟&#xff1a; 2. 修復 GRUB 配置解決步驟&#xff1a; 3. 使用恢復模式解決步驟&#xff1a; 三、驗證與總結 前言 在使用 Ubuntu 操作系統時&#xff0c;一些用戶可能會遇到開機后屏幕黑屏的現象。這種問題可能…

Modbus TCP轉Profibus DP網關接防撞雷達與PLC通訊

Modbus TCP轉Profibus DP網關接防撞雷達與PLC通訊 在工業自動化領域&#xff0c;通信協議的多樣性既是技術進步的體現&#xff0c;也給系統集成帶來了挑戰。Modbus TCP和Profibus DP是兩種廣泛應用于不同場景下的通信標準&#xff0c;它們各有優勢但也存在著互操作性的需求。本…

分布式鎖方案-Redisson

分布式鎖&#xff1a;Redisson還實現了Redis文檔中提到像分布式鎖Lock這樣的更高階應用場景。事實上Redisson并沒有不止步于此&#xff0c;在分布式鎖的基礎上還提供了聯鎖&#xff08;MultiLock&#xff09;&#xff0c;讀寫鎖&#xff08;ReadWriteLock&#xff09;&#xff…