/*
 * @Author: Kane
 * @Date: 2023-01-29 13:59:37
 * @LastEditors: Kane
 * @LastEditTime: 2023-02-04 14:40:07
 * @FilePath: /后端-需求/src/main/java/com/cpic/xim/web/controllers/requirements/RequirementController.java
 * @Description: 
 * 
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 */
package com.cpic.xim.web.controllers.requirements;

import java.sql.SQLException;
import java.util.Vector;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cpic.xim.data.RequirementStatus;
import com.cpic.xim.utils.db.RequirementDbOperation;
import com.cpic.xim.web.controllers.requirements.param.RequirementQueryParam;
import com.cpic.xim.web.controllers.requirements.response.QueryRequirementStatusResult;
import com.cpic.xim.web.controllers.requirements.response.RequirementQueryResult;

@SuppressWarnings( "unused" )
@Controller
public class RequirementController
{
    @RequestMapping( "/query_requirements.do" )
    @ResponseBody
    public RequirementQueryResult queryRequirements( @RequestBody RequirementQueryParam param )
    {
        RequirementQueryResult result = new RequirementQueryResult();

        result.setSuccess( true );

        return result;
    }

    @RequestMapping( "/query_requirement_status.do" )
    @ResponseBody
    public QueryRequirementStatusResult queryRequirementStatus()
    {
        QueryRequirementStatusResult result = new QueryRequirementStatusResult();

        try
        {
            Vector<RequirementStatus> status = RequirementDbOperation.queryRequirementStatus();

            result.setSuccess( true );
            result.setRequirementStatus( status );
        }
        catch ( ClassNotFoundException exception )
        {
            result.setSuccess( false );
            result.setMessage( exception.getMessage() );
        }
        catch ( SQLException exception )
        {
            result.setSuccess( false );
            result.setMessage( exception.getMessage() );
        }

        return result;
    }
}
