ResultUtil.java

package com.xs.utils;


import com.xs.domain.Result;




/**
 * 直接在右边的文件框里编辑你说需要注释的东西,
 * 然后应用保存之后,当你创建类的时候就会自动生成注释。
 */
public class ResultUtil {
    //成功方法-含参
    public static Result success(Object object) {
        Result result = new Result<>();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(object);
        return result;
    }
    //成功方法-无参
    public static Result success() {
        return success(null);
    }
    //异常方法
    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
@RequestMapping(value = "doRegister", method = RequestMethod.POST) @ResponseBody public Result doRegister(@RequestBody Map<String, Object> tempParams){ // begin pansheng 20210421 校验验证码是否存在 String linkManPhone = MapUtil.getStr(tempParams, "linkManPhone"); String linkPhoneCode = MapUtil.getStr(tempParams, "linkPhoneCode"); if(StrUtil.isBlank(linkManPhone) || StrUtil.isBlank(linkPhoneCode)) { return ResultUtil.fail("联系人手机号码或者验证码不能为空!"); } String internetCafeId = MapUtil.getStr(tempParams,"internetCafeId"); if(StrUtil.isBlank(internetCafeId)){ return ResultUtil.fail("网吧编号不能为空!"); } String applyNo = MapUtil.getStr(tempParams,"applyNo"); if(StrUtil.isBlank(applyNo)){ return ResultUtil.fail("申请编号不能为空!"); } boolean isCodeExists = shengpayService.verifySmsCode(applyNo, internetCafeId, linkManPhone, linkPhoneCode); if(!isCodeExists){ return ResultUtil.fail("验证码不存在,请重新获取!"); } // end // begin pansheng 20210430 校验用户是否同意授权 String agreeStatus = MapUtil.getStr(tempParams,"agreeStatus"); if("false".equals(agreeStatus)){ return ResultUtil.fail("请勾选同意授权之后,再提交进件!"); } // end // 直接接收前端参数,由Service去判断参数 JSONObject result = null; try { result = shengpayService.doRegister(tempParams); }catch (Exception e){ logger.error("盛付通进件请求接口报错", e); return ResultUtil.fail("进件失败,请重试!"); } if(result == null){ return ResultUtil.fail("进件失败,请重试!"); } if(result.containsKey("resultCode")){ String resultCode = result.getString("resultCode"); if("SUCCESS".equals(resultCode)){ return ResultUtil.success(); } } return ResultUtil.fail(result.getString("errorMsg")); }
03-04

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值