spring boot+mybatis-plus+SQL server调用有返回值的存储过程

苏高峰
2023-12-01

1.在mapper.xml中

<select id="checkXkEnable" parameterType="java.util.Map" statementType="CALLABLE" resultType="java.util.Map">
    {call up_Ty_CheckXkEnable(
            #{CphOrYyZh,mode=IN,jdbcType=VARCHAR},
            #{XkWh,mode=IN,jdbcType=VARCHAR},
            #{Czr,mode=IN,jdbcType=VARCHAR},
            #{sequence,mode=OUT,jdbcType=VARCHAR},
            #{sBackValue,mode=OUT,jdbcType=VARCHAR},
            #{sRet,mode=OUT,jdbcType=VARCHAR}
        )
    }
</select>

2.在mapper.java中

List<Map<String,Object>> checkXkEnable(Map<String, Object> map);

3.在controller中

@ApiOperation("校验申请按钮")
@ApiImplicitParams({@ApiImplicitParam(value = "车牌号",name = "cphOrYyZh",dataType = "String",paramType = "query"),
        @ApiImplicitParam(value = "",name = "xkWh",dataType = "String",paramType = "query"),
        @ApiImplicitParam(value = "czr",name = "czr",dataType = "String",paramType = "query")})
@PostMapping("/checkXkEnable")
public ResultInfo checkXkEnable(String cphOrYyZh, String xkWh,String czr) {
    try {
        Map<String, Object> params = new HashMap<>();
        params.put("CphOrYyZh",cphOrYyZh);
        params.put("XkWh",xkWh);
        params.put("Czr",czr);
        xkSqMapper.checkXkEnable(params);
        String sRet = (String) params.get("sRet");
        if ("succeed".equals(sRet)) {
            return ResultInfo.ok("数据查询成功!");
        } else {
            return ResultInfo.fail(902, sRet);
        }
    } catch (Exception e) {
        return ResultInfo.fail(901,"数据查询失败!");
    }
}

 

 类似资料: