加入奖项相关的代码
This commit is contained in:
		@@ -0,0 +1,19 @@
 | 
			
		||||
/*
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2023-09-06 11:17:44
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/mapper/RewardsMapper.java
 | 
			
		||||
 * @Description: 
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package com.cpic.xim.mybatis.mapper;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import com.cpic.xim.mybatis.pojo.RewardProject;
 | 
			
		||||
 | 
			
		||||
public interface RewardsMapper 
 | 
			
		||||
{
 | 
			
		||||
    public ArrayList<RewardProject> queryRewardProjects();
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,90 @@
 | 
			
		||||
/*
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2023-09-06 11:00:35
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/pojo/RewardProject.java
 | 
			
		||||
 * @Description: 奖励项目对象
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.mybatis.pojo;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonProperty;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 奖励项目对象
 | 
			
		||||
 */
 | 
			
		||||
public class RewardProject
 | 
			
		||||
{
 | 
			
		||||
    public RewardProject( int rewardCode, String rewardName)
 | 
			
		||||
    {
 | 
			
		||||
        this.rewardCode = rewardCode;
 | 
			
		||||
        this.rewardName = rewardName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getRewardCode()
 | 
			
		||||
    {
 | 
			
		||||
        return rewardCode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRewardCode( int rewardCode )
 | 
			
		||||
    {
 | 
			
		||||
        this.rewardCode = rewardCode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getRewardName()
 | 
			
		||||
    {
 | 
			
		||||
        return rewardName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRewardName( String rewardName )
 | 
			
		||||
    {
 | 
			
		||||
        this.rewardName = rewardName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString()
 | 
			
		||||
    {
 | 
			
		||||
        return "RewardProject [rewardCode=" + rewardCode + ", rewardName=" + rewardName + "]";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode()
 | 
			
		||||
    {
 | 
			
		||||
        final int prime = 31;
 | 
			
		||||
        int result = 1;
 | 
			
		||||
        result = prime * result + rewardCode;
 | 
			
		||||
        result = prime * result + ((rewardName == null) ? 0 : rewardName.hashCode());
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals( Object obj )
 | 
			
		||||
    {
 | 
			
		||||
        if ( this == obj )
 | 
			
		||||
            return true;
 | 
			
		||||
        if ( obj == null )
 | 
			
		||||
            return false;
 | 
			
		||||
        if ( getClass() != obj.getClass() )
 | 
			
		||||
            return false;
 | 
			
		||||
        RewardProject other = (RewardProject) obj;
 | 
			
		||||
        if ( rewardCode != other.rewardCode )
 | 
			
		||||
            return false;
 | 
			
		||||
        if ( rewardName == null )
 | 
			
		||||
        {
 | 
			
		||||
            if ( other.rewardName != null )
 | 
			
		||||
                return false;
 | 
			
		||||
        } else if ( !rewardName.equals( other.rewardName ) )
 | 
			
		||||
            return false;
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // 奖励项目代码
 | 
			
		||||
    @JsonProperty("rewardCode")
 | 
			
		||||
    private int rewardCode;
 | 
			
		||||
 | 
			
		||||
    // 奖励项目名称
 | 
			
		||||
    @JsonProperty("rewardName")
 | 
			
		||||
    private String rewardName;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,66 @@
 | 
			
		||||
/*
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2023-09-06 10:41:34
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/controllers/rewards/RewardController.java
 | 
			
		||||
 * @Description: 坐席奖励相关的请求
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.web.controllers.rewards;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import org.apache.ibatis.session.SqlSession;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
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.RewardProject;
 | 
			
		||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
 | 
			
		||||
 | 
			
		||||
@Controller
 | 
			
		||||
@RequestMapping("/rewards")
 | 
			
		||||
public class RewardController
 | 
			
		||||
{
 | 
			
		||||
    // 日志
 | 
			
		||||
    private static Logger logger = LoggerFactory.getLogger(RewardController.class);
 | 
			
		||||
 | 
			
		||||
    private RewardController() {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 相应查询获奖项目清单的请求
 | 
			
		||||
     * @return 获奖项目清单的response对象
 | 
			
		||||
     */
 | 
			
		||||
    @PostMapping("/query_reward_projects.do")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public RewardProjectsResponse queryRewardProjecrts()
 | 
			
		||||
    {
 | 
			
		||||
        RewardProjectsResponse response = new RewardProjectsResponse();
 | 
			
		||||
 | 
			
		||||
        SqlSession session = null;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            session = MybatisUtils.getSqlSession();
 | 
			
		||||
 | 
			
		||||
            RewardsMapper mapper = session.getMapper(RewardsMapper.class);
 | 
			
		||||
            ArrayList<RewardProject> rewards = mapper.queryRewardProjects();
 | 
			
		||||
 | 
			
		||||
            response.setSuccess(true);
 | 
			
		||||
            response.setMessage("查询成功!");
 | 
			
		||||
            response.setRewardList(rewards);
 | 
			
		||||
        }
 | 
			
		||||
        catch (IOException error )
 | 
			
		||||
        {
 | 
			
		||||
            response.setSuccess(false);
 | 
			
		||||
            response.setMessage("查询失败!" + error.getMessage());
 | 
			
		||||
            response.setRewardList(null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return response;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,46 @@
 | 
			
		||||
/*
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2023-09-06 10:59:45
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/controllers/rewards/RewardProjectsResponse.java
 | 
			
		||||
 * @Description: 奖励项目请求结果
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.web.controllers.rewards;
 | 
			
		||||
 | 
			
		||||
import com.cpic.xim.mybatis.pojo.RewardProject;
 | 
			
		||||
import com.cpic.xim.web.controllers.QueryResult;
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonProperty;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
public class RewardProjectsResponse extends QueryResult
 | 
			
		||||
{
 | 
			
		||||
    public RewardProjectsResponse( boolean success, String message,
 | 
			
		||||
            ArrayList<RewardProject> rewardList)
 | 
			
		||||
    {
 | 
			
		||||
        super( success, message );
 | 
			
		||||
 | 
			
		||||
        this.rewardList = rewardList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public RewardProjectsResponse()
 | 
			
		||||
    {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        this.rewardList = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ArrayList<RewardProject> getRewardList()
 | 
			
		||||
    {
 | 
			
		||||
        return rewardList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRewardList( ArrayList<RewardProject> rewardList )
 | 
			
		||||
    {
 | 
			
		||||
        this.rewardList = rewardList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @JsonProperty("rewardList")
 | 
			
		||||
    private ArrayList<RewardProject> rewardList;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="com.cpic.xim.mybatis.mapper.RewardsMapper">
 | 
			
		||||
    <select id="queryRewardProjects" resultMap="RewardProjectMap">
 | 
			
		||||
        select reward_index, reward_name from reward_projects
 | 
			
		||||
    </select>
 | 
			
		||||
    <resultMap id="RewardProjectMap" type="com.cpic.xim.mybatis.pojo.RewardProject">
 | 
			
		||||
        <id property="rewardCode" column="reward_index" />
 | 
			
		||||
        <result property="rewardName" column="reward_name" javaType="String"/>
 | 
			
		||||
    </resultMap>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -25,5 +25,6 @@
 | 
			
		||||
        <!-- <mapper resource="mybatis/mapper/StaffMapper.xml" /> -->
 | 
			
		||||
        <mapper resource="mybatis/mapper/ArchievementMapper.xml" />
 | 
			
		||||
        <mapper resource="mybatis/mapper/RankingListMapper.xml" />
 | 
			
		||||
        <mapper resource="mybatis/mapper/RewardsMapper.xml" />
 | 
			
		||||
    </mappers>
 | 
			
		||||
</configuration>
 | 
			
		||||
@@ -23,10 +23,11 @@ import org.junit.Test;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import com.cpic.xim.mybatis.mapper.ArchievementMapper;
 | 
			
		||||
import com.cpic.xim.mybatis.mapper.RewardsMapper;
 | 
			
		||||
import com.cpic.xim.mybatis.pojo.MensualArchievementItem;
 | 
			
		||||
import com.cpic.xim.utils.archievement.DepartmentArchievement;
 | 
			
		||||
import com.cpic.xim.utils.ranking.CallerRankingList;
 | 
			
		||||
import com.cpic.xim.mybatis.pojo.RewardProject;
 | 
			
		||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
 | 
			
		||||
import com.cpic.xim.utils.ranking.CallerRankingList;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings( "all" )
 | 
			
		||||
public class DesktopArchievementTest
 | 
			
		||||
@@ -101,11 +102,11 @@ public class DesktopArchievementTest
 | 
			
		||||
            mapper.getCallerArchievement( params );
 | 
			
		||||
 | 
			
		||||
            Object obj = params.get( "a_mensual_cur" );
 | 
			
		||||
            mensual = (ArrayList<MensualArchievementItem>)params.get( "a_mensual_cur" );
 | 
			
		||||
            mensual = (ArrayList<MensualArchievementItem>) params.get( "a_mensual_cur" );
 | 
			
		||||
 | 
			
		||||
            System.out.println( params.toString() );
 | 
			
		||||
            System.out.println( mensual.toString() );
 | 
			
		||||
            System.out.println( obj.getClass());
 | 
			
		||||
            System.out.println( obj.getClass() );
 | 
			
		||||
 | 
			
		||||
            assertTrue( params.size() > 1 );
 | 
			
		||||
        }
 | 
			
		||||
@@ -114,4 +115,24 @@ public class DesktopArchievementTest
 | 
			
		||||
            assert (false);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testRewardProjects()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            SqlSession session = MybatisUtils.getSqlSession();
 | 
			
		||||
            RewardsMapper mapper = session.getMapper( RewardsMapper.class );
 | 
			
		||||
 | 
			
		||||
            ArrayList<RewardProject> rewards = mapper.queryRewardProjects();
 | 
			
		||||
 | 
			
		||||
            System.out.println( rewards );
 | 
			
		||||
            assert( rewards.isEmpty() == false );
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
        catch ( IOException error )
 | 
			
		||||
        {
 | 
			
		||||
            assert( false );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user