Compare commits
2 Commits
efebd548c6
...
7ea11e34a9
Author | SHA1 | Date |
---|---|---|
Kane Wang | 7ea11e34a9 | |
Kane Wang | 2edd5f67db |
|
@ -157,7 +157,7 @@ module.exports = {
|
|||
"space-in-parens": ["error", "always", { exceptions: ["{}", "[]", "()", "empty",], },],
|
||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/indent": ["error", 4,],
|
||||
"@typescript-eslint/no-extra-semi": "off",
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
|
|
|
@ -12,4 +12,7 @@
|
|||
|
||||
// testRankingListRequest();
|
||||
|
||||
const arr: string[] = [];
|
||||
|
||||
console.log( "test" );
|
||||
console.log( "检查instanceof:", arr instanceof String );
|
||||
|
|
|
@ -26,4 +26,12 @@ 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",
|
||||
// 查询获奖人员
|
||||
// URL_REWARD_GAINERS: "http://{{生产地址}}/desktop_archievement_backend/rewards/query_reward_gainers.do"
|
||||
URL_REWARD_GAINERS: "http://222.76.244.118:11101/desktop_archievement_backend/rewards/query_reward_gainers.do",
|
||||
};
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-09-11 09:59:00
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /task_schedule/src/utils/reward.ts
|
||||
* @Description: 奖励相关的API
|
||||
*
|
||||
* 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[] | null;
|
||||
}
|
||||
|
||||
interface RewardGainer
|
||||
{
|
||||
acquiredDate: string;
|
||||
callerName: string;
|
||||
callerCode: string;
|
||||
rewardProjectCode: string;
|
||||
rewardProjectName: string;
|
||||
}
|
||||
|
||||
interface RewardGainerResponse
|
||||
{
|
||||
success: boolean;
|
||||
message: string;
|
||||
gainerList: RewardGainer[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求奖项清单
|
||||
* @param handler 用于处理请求数据的回调函数;
|
||||
*/
|
||||
function requestRewardPorjectsList( handler: any ): void
|
||||
{
|
||||
if ( handler === undefined || handler === null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const rewardResponse: RewardProjectResponse = {
|
||||
success: false,
|
||||
message: "",
|
||||
rewardList: [],
|
||||
};
|
||||
|
||||
instance.request({
|
||||
url: API_URL.URL_RWARD_PROJECTS,
|
||||
method: "post",
|
||||
})
|
||||
// 请求成功,检查服务器返回结果
|
||||
.then(( response: AxiosResponse<any, any> ): void =>
|
||||
{
|
||||
const data = response.data ?? {};
|
||||
rewardResponse.success = data.success ?? false;
|
||||
rewardResponse.message = data.message ?? "";
|
||||
rewardResponse.rewardList = checkRewardProjects( data.rewardList ?? []);
|
||||
|
||||
handler( rewardResponse, null );
|
||||
})
|
||||
.catch(( error: any ): void =>
|
||||
{
|
||||
console.log( error );
|
||||
|
||||
rewardResponse.success = false;
|
||||
|
||||
handler( rewardResponse, error );
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
function requestRewardGainers( handler: any ): void
|
||||
{
|
||||
if ( handler === undefined || handler === null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const rewardResponse: RewardGainerResponse = {
|
||||
success: false,
|
||||
message: "",
|
||||
gainerList: [],
|
||||
};
|
||||
|
||||
instance.request({
|
||||
url: API_URL.URL_REWARD_GAINERS,
|
||||
method: "post",
|
||||
})
|
||||
.then(( response: AxiosResponse<any, any> ): void =>
|
||||
{
|
||||
const data = response.data ?? {};
|
||||
|
||||
rewardResponse.success = data.success;
|
||||
rewardResponse.message = data.message;
|
||||
rewardResponse.gainerList = data.gainerList;
|
||||
|
||||
handler( rewardResponse, null );
|
||||
})
|
||||
.catch(( error: any ): void =>
|
||||
{
|
||||
console.log( error );
|
||||
|
||||
rewardResponse.success = false;
|
||||
|
||||
handler( rewardResponse, 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;
|
||||
}
|
||||
|
||||
function checkRewardGainers( gainers: any[]): RewardGainer[] | null
|
||||
{
|
||||
const gainerList: RewardGainer[] = [];
|
||||
|
||||
if ( !( gainers instanceof Array ))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
gainers.forEach(( item: RewardGainer ): void =>
|
||||
{
|
||||
const gainer: RewardGainer = {
|
||||
acquiredDate: item.acquiredDate ?? "",
|
||||
callerName: item.callerName ?? "",
|
||||
callerCode: item.callerCode ?? "",
|
||||
rewardProjectCode: item.rewardProjectCode ?? "",
|
||||
rewardProjectName: item.rewardProjectName ?? "",
|
||||
};
|
||||
});
|
||||
|
||||
return gainerList;
|
||||
}
|
||||
|
||||
export {
|
||||
type RewardProject,
|
||||
type RewardGainer,
|
||||
type RewardProjectResponse,
|
||||
type RewardGainerResponse,
|
||||
requestRewardPorjectsList,
|
||||
requestRewardGainers
|
||||
};
|
|
@ -39,52 +39,46 @@
|
|||
/>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="dishonor-wrapper">
|
||||
<el-divider content-position="left">
|
||||
XXX
|
||||
</el-divider>
|
||||
<div class="toolbutton-wrapper">
|
||||
<el-button type="primary">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="danger">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
border
|
||||
stripe
|
||||
style="width:100%;"
|
||||
:height="tableHeight"
|
||||
>
|
||||
<el-table-column type="selection" />
|
||||
<el-table-column
|
||||
label="坐席名称"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
label="奖项名称"
|
||||
align="center"
|
||||
/>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { reactive, computed } from "vue";
|
||||
import {
|
||||
type RewardProject,
|
||||
type RewardGainer,
|
||||
type RewardProjectResponse,
|
||||
type RewardGainerResponse,
|
||||
requestRewardPorjectsList,
|
||||
requestRewardGainers
|
||||
} from "@/utils/reward.js";
|
||||
|
||||
interface UI
|
||||
{
|
||||
rewardGainerList: RewardGainer[];
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "DataManagement",
|
||||
setup()
|
||||
{
|
||||
const ui = reactive({});
|
||||
const ui: UI = reactive({
|
||||
rewardGainerList: [],
|
||||
});
|
||||
|
||||
const tableHeight = computed((): number =>
|
||||
{
|
||||
return 5 * 50 + 40;
|
||||
});
|
||||
|
||||
const applyGainerList = ( response: RewardGainerResponse ): void =>
|
||||
{
|
||||
if ( response.success )
|
||||
{
|
||||
ui.rewardGainerList = response.gainerList;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
ui,
|
||||
tableHeight,
|
||||
|
|
|
@ -19,23 +19,25 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.cpic.xim.mybatis.mapper.RewardsMapper;
|
||||
import com.cpic.xim.mybatis.pojo.RewardGainer;
|
||||
import com.cpic.xim.mybatis.pojo.RewardProject;
|
||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/rewards")
|
||||
@RequestMapping( "/rewards" )
|
||||
public class RewardController
|
||||
{
|
||||
// 日志
|
||||
private static Logger logger = LoggerFactory.getLogger(RewardController.class);
|
||||
private static Logger logger = LoggerFactory.getLogger( RewardController.class );
|
||||
|
||||
private RewardController() {}
|
||||
private RewardController()
|
||||
{}
|
||||
|
||||
/**
|
||||
* 相应查询获奖项目清单的请求
|
||||
* @return 获奖项目清单的response对象
|
||||
*/
|
||||
@PostMapping("/query_reward_projects.do")
|
||||
@PostMapping( "/query_reward_projects.do" )
|
||||
@ResponseBody
|
||||
public RewardProjectsResponse queryRewardProjecrts()
|
||||
{
|
||||
|
@ -43,26 +45,57 @@ public class RewardController
|
|||
|
||||
SqlSession session = null;
|
||||
|
||||
logger.debug( "查询奖项清单。" );
|
||||
|
||||
try
|
||||
{
|
||||
session = MybatisUtils.getSqlSession();
|
||||
|
||||
RewardsMapper mapper = session.getMapper(RewardsMapper.class);
|
||||
RewardsMapper mapper = session.getMapper( RewardsMapper.class );
|
||||
ArrayList<RewardProject> rewards = mapper.queryRewardProjects();
|
||||
|
||||
response.setSuccess(true);
|
||||
response.setMessage("查询成功!");
|
||||
response.setRewardList(rewards);
|
||||
response.setSuccess( true );
|
||||
response.setMessage( "查询成功!" );
|
||||
response.setRewardList( rewards );
|
||||
|
||||
logger.debug( "查询奖项清单," + response.getMessage() + "," + rewards.toString() );
|
||||
}
|
||||
catch (IOException error )
|
||||
catch ( IOException error )
|
||||
{
|
||||
response.setSuccess(false);
|
||||
response.setMessage("查询失败!" + error.getMessage());
|
||||
response.setRewardList(null);
|
||||
response.setSuccess( false );
|
||||
response.setMessage( "查询失败!" + error.getMessage() );
|
||||
response.setRewardList( null );
|
||||
|
||||
logger.debug( "查询奖项清单," + response.getMessage() + "," + error.getMessage() );
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@PostMapping( "/query_reward_gainers.do" )
|
||||
@ResponseBody
|
||||
RewardGainersResponse queryRewardGainers()
|
||||
{
|
||||
RewardGainersResponse response = new RewardGainersResponse();
|
||||
|
||||
try
|
||||
{
|
||||
SqlSession session = MybatisUtils.getSqlSession();
|
||||
RewardsMapper mapper = session.getMapper( RewardsMapper.class );
|
||||
|
||||
ArrayList<RewardGainer> gainers = mapper.queryRewardGainers();
|
||||
|
||||
response.setSuccess( true );
|
||||
response.setMessage( "查询成功!" );
|
||||
response.setGainerList( gainers );
|
||||
}
|
||||
catch ( IOException error )
|
||||
{
|
||||
response.setSuccess( false );
|
||||
response.setMessage( "查询失败!" + error.getMessage() );
|
||||
response.setGainerList( null );
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue