保存进度!

This commit is contained in:
Kane Wang 2023-09-11 11:49:58 +08:00
parent efebd548c6
commit 2edd5f67db
3 changed files with 104 additions and 0 deletions

View File

@ -12,4 +12,7 @@
// testRankingListRequest();
const arr: string[] = [];
console.log( "test" );
console.log( "检查instanceof", arr instanceof String );

View File

@ -26,4 +26,9 @@ export const API_URL = {
// 坐席业绩查询
URL_CALLER_ARCHIEVEMENT: "http://10.39.0.41:8081/desktop_archievement_backend/archievement/query_caller_archievement.do",
/** 奖项相关 **/
// 查询奖励项目
// URL_RWARD_PROJECTS: "http://222.76.244.118:11101/desktop_archievement_backend/rewards/query_reward_projects.do"
URL_RWARD_PROJECTS: "http://10.39.0.41:8081/desktop_archievement_backend/rewards/query_reward_projects.do",
};

View File

@ -0,0 +1,96 @@
/*
* @Author: Kane
* @Date: 2023-09-11 09:59:00
* @LastEditors: Kane
* @FilePath: /task_schedule/src/utils/reward.ts
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import { type AxiosResponse } from "axios";
import { service as instance } from "./api/request.js";
import { API_URL } from "./api/config.js";
interface RewardProject
{
rewardCode: number;
rewardName: string;
}
interface RewardProjectResponse
{
success: boolean;
message: string;
rewardList: RewardProject[];
}
interface RewardGainer
{
acquiredDate: string;
callerName: string;
callerCode: string;
rewardProjectCode: string;
rewardProjectName: string;
}
/**
*
* @param handler
*/
function requestRewardPorjectsList( handler: any ): void
{
if ( handler === undefined || handler === null )
{
return;
}
instance.request({
url: API_URL.URL_RWARD_PROJECTS,
method: "post",
})
// 请求成功,检查服务器返回结果
.then(( response: AxiosResponse<any, any> ): void =>
{
const data = response.data ?? {};
const success = data.success ?? false;
const message = data.message ?? "";
const rewardProjectList = checkRewardProjects( data.rewardList ?? []);
})
.catch(( error: any ): void =>
{
console.log( error );
handler( null, error );
});
}
// **功能函数 **********************************/
function checkRewardProjects( data: any[]): RewardProject[] | null
{
const rewardList: RewardProject[] = [];
// 检查一下参数的类型,如果不是数组返回 null
if ( !( data instanceof Array ))
{
return null;
}
data.forEach(( item: any ) =>
{
const reward = {
rewardCode: item.rewardCode ?? "",
rewardName: item.rewardName ?? "",
};
rewardList.push( reward );
});
return rewardList;
}
export {
type RewardProject,
type RewardGainer,
type RewardProjectResponse,
requestRewardPorjectsList
};