尚醫通day11-Java中阿裡雲對象存儲OSS

来源:https://www.cnblogs.com/deyo/archive/2023/06/14/17479789.html
-Advertisement-
Play Games

# 頁面預覽 ## 用戶認證 - 用戶登錄成功後都要進行身份認證,認證通過後才可以預約掛號。 - 認證過程:用戶填寫基本信息(姓名、證件類型、證件號碼和證件照片),提交平臺審核 - 用戶認證相關介面: (1)上傳證件圖片 (2)提交認證 (3)獲取認證信息 ### 提交認證 ![image-2023 ...


頁面預覽

用戶認證

  • 用戶登錄成功後都要進行身份認證,認證通過後才可以預約掛號。

  • 認證過程:用戶填寫基本信息(姓名、證件類型、證件號碼和證件照片),提交平臺審核

  • 用戶認證相關介面:

(1)上傳證件圖片

(2)提交認證

(3)獲取認證信息

提交認證

image-20230224205235514

獲取認證信息

image-20230224210115502

第01章-阿裡雲OSS

1、對象存儲OSS

用戶認證需要上傳證件圖片,因此我們要做文件服務,為瞭解決海量數據存儲與彈性擴容,項目中我們採用雲存儲的解決方案:阿裡雲OSS。

1.1、開通“對象存儲OSS”服務

(1)申請阿裡雲賬號

(2)實名認證

(3)開通“對象存儲OSS”服務

(4)進入管理控制台

1.2、創建Bucket

為Bucket起一個名字,其餘選項預設即可。

註意:項目中涉及身份證照片,讀寫許可權選擇預設的“私有”

img

得到endpoint:創建Bucket後,在概覽頁面可以獲取當前Bucket的endpoint值,這個值後面編程的時候會用到

image-20230222050700956

1.3、上傳測試文件

創建一個文件夾,上傳一個文件

img

2、使用RAM子用戶

2.1、進入子用戶管理頁面

img

img

2.2、添加用戶

img

2.3、獲取子用戶Id和key

AccessKeyId, AccessKeySecret

2.4、設置用戶許可權

添加許可權:AliyunOSSFullAccess

img

3、使用SDK

在對象存儲首頁的右側,可以找到幫助文檔的入口

img

img

第02章-用戶認證

1、新建雲服務模塊

1.1、創建模塊

在service模塊下創建子模塊service-yun

image-20230317155904674

1.2、添加依賴

在service-yun中引入依賴

<dependencies>
    <!-- 阿裡雲oss依賴 -->
    <dependency>
        <groupId>com.aliyun.oss</groupId>
        <artifactId>aliyun-sdk-oss</artifactId>
        <version>3.15.1</version>
    </dependency>

    <!--實體-->
    <dependency>
        <groupId>com.atguigu</groupId>
        <artifactId>model</artifactId>
        <version>1.0</version>
    </dependency>

    <!--服務通用配置-->
    <dependency>
        <groupId>com.atguigu</groupId>
        <artifactId>service-util</artifactId>
        <version>1.0</version>
    </dependency>
    
    <!--時間日期工具-->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
    </dependency>
    
    <!--自定義安全模塊-->
    <dependency>
        <groupId>com.atguigu</groupId>
        <artifactId>spring-security</artifactId>
        <version>1.0</version>
    </dependency>
    
    <!-- 單元測試 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>


</dependencies>

1.3、創建配置文件

在server-yun模塊中resources目錄下創建文件

application.yml

spring:
  application:
    name: service-yun
  profiles:
    active: dev,redis

application-dev.yml

server:
  port: 8204
spring:
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
  servlet:
    multipart:
      max-file-size: 10MB
      max-request-size: 10MB

logging:
  level:
    root: info
  file:
    path: yun
  
aliyun:
  oss: #阿裡雲 OSS
    endpoint: your endpoint
    key-id: your accessKeyId
    key-secret: your accessKeySecret
    bucket-name: your bucketname

1.4、創建啟動類

創建ServiceYunApplication

package com.atguigu.syt.yun;

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)//取消數據源配置自動讀取
@ComponentScan(basePackages = {"com.atguigu"})
public class ServiceYunApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServiceYunApplication.class, args);
    }
}

1.5、配置網關

在網關中配置如下內容:

        - id: service-yun
          predicates: Path=/*/yun/**
          uri: lb://service-yun

2、文件上傳

2.1、從配置文件讀取常量

創建常量讀取工具類:OssConstantProperties.java

package com.atguigu.syt.yun.utils;
@Configuration
@ConfigurationProperties(prefix="aliyun.oss") //讀取節點
@Data
public class OssConstantProperties {
    
    private String endpoint;
    private String keyId;
    private String keySecret;
    private String bucketName;
}

2.2、Controller

創建controller.front包,創建FrontFileController類

package com.atguigu.syt.yun.controller.front;

@Api(tags = "阿裡雲文件管理")
@RestController
@RequestMapping("/front/yun/file")
public class FrontFileController {

    @Resource
    private FileService fileService;
    /**
     * 文件上傳
     */
    @ApiOperation("文件上傳")
    @ApiImplicitParam(name = "file",value = "上傳文件", required = true)
    @PostMapping("/auth/upload")
    public Result<Map<String, String>> upload(MultipartFile file) {
        Map<String, String> map = fileService.upload(file);
        return Result.ok(map);
    }
}

2.3、Service

介面:FileService

package com.atguigu.syt.oss.service;

public interface FileService {

    /**
     * 文件上傳
     * @param file
     * @return
     */
    Map<String, String> upload(MultipartFile file);
}

實現:FileServiceImpl

參考SDK中的:Java->上傳文件->簡單上傳->流式上傳->上傳文件流

package com.atguigu.syt.oss.service.impl;

@Service
@Slf4j
public class FileServiceImpl implements FileService {

    @Resource
    private OssConstantProperties ossConstantProperties;

    /**
     * 參考SDK中的:Java->上傳文件->簡單上傳->流式上傳->上傳文件流
     * @param file
     * @return
     */
    @Override
    public Map<String, String> upload(MultipartFile file) {

        // Endpoint以華東1(杭州)為例,其它Region請按實際情況填寫。
        String endpoint = ossConstantProperties.getEndpoint();
        // 阿裡雲賬號AccessKey擁有所有API的訪問許可權,風險很高。強烈建議您創建並使用RAM用戶進行API訪問或日常運維,請登錄RAM控制台創建RAM用戶。
        String accessKeyId = ossConstantProperties.getKeyId();
        String accessKeySecret = ossConstantProperties.getKeySecret();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = ossConstantProperties.getBucketName();

        // 文件名稱
        String originalFilename = file.getOriginalFilename();
        String dateString = new DateTime().toString("yyyyMMdd");
        // 填寫Object完整路徑,完整路徑中不能包含Bucket名稱,例如exampledir/exampleobject.txt。
        String objectName =
                dateString
                        + "/" + UUID.randomUUID().toString().replace("-", "")
                        + originalFilename.substring(originalFilename.lastIndexOf("."));

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        try {
            InputStream inputStream = file.getInputStream();
            // 創建PutObjectRequest對象。
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, inputStream);
            // 設置該屬性可以返回response。如果不設置,則返回的response為空。
            putObjectRequest.setProcess("true");
            // 創建PutObject請求。
            PutObjectResult result = ossClient.putObject(putObjectRequest);

            // 如果上傳成功,則返回200。
            log.info(Integer.toString(result.getResponse().getStatusCode()));
            if(result.getResponse().getStatusCode() != 200){
                throw new GuiguException(ResultCodeEnum.FAIL);
            }

            //返回圖片路徑
            //參考SDK中的:Java-> Java授權訪問-> 生成以GET方法訪問的簽名URL
            // 設置URL過期時間為1小時,單位:毫秒
            Date expiration = new Date(new Date().getTime() + 60 * 60 * 1000);
            URL url = ossClient.generatePresignedUrl(bucketName, objectName, expiration);

            Map<String, String> map = new HashMap<>();
            map.put("previewUrl", url.toString()); //頁面中授權預覽圖片
            map.put("url", objectName); //資料庫存儲

            return map;

        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());

            throw new GuiguException(ResultCodeEnum.FAIL, oe);

        } catch (GuiguException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());

            throw new GuiguException(ResultCodeEnum.FAIL, ce);

        } catch (IOException e) {

            throw new GuiguException(ResultCodeEnum.FAIL, e);

        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

3、授權校驗

3.1、輔助類

在service-util模塊中添加AuthContextHolder.java

package com.atguigu.common.service.utils;

/**
 * 授權校驗
 */
@Component
public class AuthContextHolder {

    @Resource
    private RedisTemplate redisTemplate;

    /**
     * 校驗token是否存在並返回UserId
     * @param request
     */
    public Long checkAuth(HttpServletRequest request){
        //從http請求頭中獲取token
        String token = request.getHeader("token");
        if(StringUtils.isEmpty(token)) {
            throw new GuiguException(ResultCodeEnum.LOGIN_AUTH);
        }

        Object userIdObj = redisTemplate.opsForValue().get("user:token:" + token);

        //數據存入redis時,按照實際的大小分配空間,取出時int能存下,預設使用int類型,int存不下再用long
        //我們無法判斷redis中存儲的是什麼類型的id,因此在此做一個轉換
        Long userId = null;
        if(userIdObj instanceof Integer){
            userId = ((Integer)userIdObj).longValue();
        }else if(userIdObj instanceof Long){
            userId = (Long)userIdObj;
        }else if(userIdObj instanceof String){
            userId = Long.parseLong(userIdObj.toString());
        }

        if(StringUtils.isEmpty(userId)) {
            throw new GuiguException(ResultCodeEnum.LOGIN_AUTH);
        }

        return userId;
    }
}

3.2、修改文件上傳controller

添加校驗代碼

...
public class FrontFileController {

    ...
    @Resource
    private AuthContextHolder authContextHolder;
    
    ...
    public Result<Map<String, String>> upload(MultipartFile file, HttpServletRequest request) {

        authContextHolder.checkAuth(request);
        ...
    }
}

3.3、測試文件上傳

首先添加全局參數token,然後再進行測試

image-20230223131310737

4、提交認證

4.1、Controller

創建FrontUserInfoController中添加如下方法

package com.atguigu.syt.user.controller.front;

@Api(tags = "用戶管理")
@RestController
@RequestMapping("/front/user/userInfo")
public class FrontUserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @Resource
    private AuthContextHolder authContextHolder;

    @ApiOperation(value = "用戶認證")
    @ApiImplicitParam(name = "userAuthVo",value = "用戶實名認證對象", required = true)
    @PostMapping("/auth/userAuth")
    public Result userAuth(@RequestBody UserAuthVo userAuthVo, HttpServletRequest request) {

        Long userId = authContextHolder.checkAuth(request);
        userInfoService.userAuth(userId, userAuthVo);
        return Result.ok();
    }
}

4.2、Service

介面:UserInfoService

/**
     * 保存實名認證信息
     * @param userId
     * @param userAuthVo
     */
void userAuth(Long userId, UserAuthVo userAuthVo);

實現:UserInfoServiceImpl

@Override
public void userAuth(Long userId, UserAuthVo userAuthVo) {
    //設置認證信息
    UserInfo userInfo = new UserInfo();
    userInfo.setId(userId);
    userInfo.setName(userAuthVo.getName());
    userInfo.setCertificatesType(userAuthVo.getCertificatesType());
    userInfo.setCertificatesNo(userAuthVo.getCertificatesNo());
    userInfo.setCertificatesUrl(userAuthVo.getCertificatesUrl());
    userInfo.setAuthStatus(AuthStatusEnum.AUTH_RUN.getStatus());
    //信息更新
    baseMapper.updateById(userInfo);
}

5、獲取認證信息

5.1、Controller

在service-user模塊的FrontUserInfoController中添加如下方法

@ApiOperation(value = "獲取認證信息")
@GetMapping("/auth/getUserInfo")
public Result<UserInfo> getUserInfo(HttpServletRequest request) {

    Long userId = authContextHolder.checkAuth(request);
    UserInfo userInfo = userInfoService.getUserInfoById(userId);
    return Result.ok(userInfo);
}

5.2、Service

主類添加

@EnableFeignClients("com.atguigu.syt")

介面:UserInfoService

/**
     * 根據用戶id獲取用戶信息
     * @param userId
     * @return
     */
UserInfo getUserInfoById(Long userId);

實現:UserInfoServiceImpl

@Override
public UserInfo getUserInfoById(Long userId) {
    UserInfo userInfo = baseMapper.selectById(userId);
    return this.packUserInfo(userInfo);
}

輔助方法:UserInfoServiceImpl

@Resource
private DictFeignClient dictFeignClient;

/**
     * 封裝用戶狀態、認證狀態、證件類型信息
     * @param userInfo
     * @return
     */
private UserInfo packUserInfo(UserInfo userInfo) {
    String certificatesTypeString = dictFeignClient.getName(
        DictTypeEnum.CERTIFICATES_TYPE.getDictTypeId(),
        userInfo.getCertificatesType()
    );

    userInfo.getParam().put("certificatesTypeString", certificatesTypeString);
    userInfo.getParam().put(
        "authStatusString", AuthStatusEnum.getStatusNameByStatus(userInfo.getAuthStatus())
    );
    userInfo.getParam().put(
        "statusString", UserStatusEnum.getStatusNameByStatus(userInfo.getStatus())
    );
    return userInfo;
}

6、顯示圖片

6.1、Controller

InnerFileController類

package com.atguigu.syt.yun.controller.inner;

@Api(tags = "阿裡雲文件管理")
@RestController
@RequestMapping("/inner/yun/file")
public class InnerFileController {

    @Resource
    private FileService fileService;
    
    @ApiOperation(value = "獲取圖片預覽Url")
    @ApiImplicitParam(name = "objectName",value = "文件名", required = true)
    @GetMapping("/getPreviewUrl")
    public String getPreviewUrl(@RequestParam String objectName) {

        return fileService.getPreviewUrl(objectName);
    }
}

6.2、Service

介面:FileService

/**
     * 獲取圖片url地址
     * @param objectName
     * @return
     */
String getPreviewUrl(String objectName);

實現:FileServiceImpl

@Override
public String getPreviewUrl(String objectName) {
    // Endpoint以華東1(杭州)為例,其它Region請按實際情況填寫。
    String endpoint = ossConstantProperties.getEndpoint();
    // 阿裡雲賬號AccessKey擁有所有API的訪問許可權,風險很高。強烈建議您創建並使用RAM用戶進行API訪問或日常運維,請登錄RAM控制台創建RAM用戶。
    String accessKeyId = ossConstantProperties.getKeyId();
    String accessKeySecret = ossConstantProperties.getKeySecret();
    // 填寫Bucket名稱,例如examplebucket。
    String bucketName = ossConstantProperties.getBucketName();

    OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    // 設置URL過期時間為1小時,單位:毫秒
    Date expiration = new Date(new Date().getTime() + 60 * 60 * 1000);
    URL url = ossClient.generatePresignedUrl(bucketName, objectName, expiration);
    System.out.println(url.toString());
    return url.toString();
}

6.3、創建service-yun-client

image-20230317172233786

6.4、定義FeignClient

介面:

package com.atguigu.syt.yun.client;
@FeignClient(
        value = "service-yun",
        contextId = "fileFeignClient",
        fallback = FileDegradeFeignClient.class
)
public interface FileFeignClient {

    @GetMapping("inner/yun/file/getPreviewUrl")
    String getPreviewUrl(@RequestParam String objectName);
}

降級:

package com.atguigu.syt.yun.client.impl;

@Component
public class FileDegradeFeignClient implements FileFeignClient {
    @Override
    public String getPreviewUrl(String objectName) {
        return "圖片顯示失敗";
    }
}

6.5、service中添加依賴

<dependency>
    <groupId>com.atguigu</groupId>
    <artifactId>service-yun-client</artifactId>
    <version>1.0</version>
</dependency>

6.6、遠程調用

UserInfoServiceImpl:

@Resource
private FileFeignClient fileFeignClient;

UserInfoServiceImpl:packUserInfo方法中添加如下代碼

String previewUrl = fileFeignClient.getPreviewUrl(userInfo.getCertificatesUrl());
userInfo.getParam().put("previewUrl", previewUrl);

註意:由於是遠程調用阿裡雲伺服器,因此配置文件中feignClient的遠程超時時間可以設置的稍微長一些,避免個別情況下由於網路原因出現的圖片無法載入的情況

7、用戶認證前端

7.1、api

創建api/userInfo.js

import request from '@/utils/request'

//引入js-cookie
import cookie from 'js-cookie'

export default {

  saveUserAuth(userAuth) {
    return request({
      url: `/front/user/userInfo/auth/userAuth`,
      method: 'post',
      data: userAuth,
      headers:{token: cookie.get('token')}
    })
  },

  getUserInfo() {
    return request({
      url: `/front/user/userInfo/auth/getUserInfo`,
      method: `get`,
      headers:{token: cookie.get('token')}
    })
  }
}

7.2、頁面渲染

pages/user/index.vue文件

資料:資料>實名認證>user

7.3、統一發送請求頭

也可以統一發送請求頭:刪除api/user.js 中對請求頭的設置,修改utils/request.js文件如下

//引入js-cookie
import cookie from 'js-cookie'

修改請求攔截器

// http request 攔截器
service.interceptors.request.use(
	config => {
		//從cookie中取出token,並且在請求頭中攜帶token
		if (cookie.get('token')) {
			config.headers['token'] = cookie.get('token')
		}
		return config
	},
	err => {
		return Promise.reject(err)
	})

源碼:https://gitee.com/dengyaojava/guigu-syt-parent

本文來自博客園,作者:自律即自由-,轉載請註明原文鏈接:https://www.cnblogs.com/deyo/p/17479789.html


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • # Go 語言之 SQLX 高級操作 sqlx.In ## sqlx.In 介紹 `sqlx` is a package for Go which provides a set of extensions on top of the excellent built-in `database/sql` ...
  • # 簡介 Scala是一種多範式的編程語言(多範式:多種編程方法的意思。有面向過程、面向對象、泛型、函數式四種程式設計方法),其設計的初衷是要集成面向對象編程和函數式編程的各種特性。Scala運行於Java平臺(Java虛擬機),並相容現有的Java程式 > 官網:https://www.scala ...
  • 基礎使用 首先引入依賴 <!-- redis依賴--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </depende ...
  • Fork譯為拆分,Join譯為合併Fork/Join框架的思路是把一個非常巨大的任務,拆分成若然的小任務,再由小任務繼續拆解。直至達到一個相對合理的任務粒度。然後執行獲得結果,然後將這些小任務的結果彙總,生成大任務的結果,直至彙總成最初巨大任務的結果。如下圖: 紅色箭頭代表拆分子任務。綠色箭頭代表返 ...
  • 本文實現的功能主要是根據已知欄位值,給指定的名稱欄位賦上對應的值;整個處理的邏輯很簡單,就是通過判斷語句,判斷其他欄位值,然後給指定的欄位填上對應的值即可; 欄位統計界面如下圖所示: #腳本代碼如下 def updatefiles(ssssss): if(ssssss == 1): total="高 ...
  • ## 教程簡介 Aurelia 是一個用於 Web 和移動應用程式開發的現代開源 UI 框架。它允許您編寫乾凈、模塊化的 JavaScript。該框架遵循簡單的約定,並專註於 Web 標準。 [Aurelia入門教程](https://www.itbaoku.cn/tutorial/aurelia- ...
  • ## 教程簡介 Apache Tajo是Hadoop的開源分散式數據倉庫框架。塔霍最初由位於南韓的基於Hadoop的基礎設施公司Gruter開始。後來,Intel,Etsy,NASA,Cloudera,Hortonworks的專家也為該項目做出了貢獻。塔霍指北韓鴕鳥。在2014年3月,Tajo獲得了 ...
  • 博客推行版本更新,成果積累制度,已經寫過的博客還會再次更新,不斷地琢磨,高質量高數量都是要追求的,工匠精神是學習必不可少的精神。因此,大家有何建議歡迎在評論區踴躍發言,你們的支持是我最大的動力,你們敢投,我就敢肝 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...