lin
2024-04-11 dd60de8d90f05c64e3cf166bc617b95a82102c52
新增自定义异常类
18 files modified
1 files added
134 ■■■■ changed files
src/main/java/org/springblade/common/exception/CustomException.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/pay/service/IWxPayService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/pay/service/impl/WxPayServiceImpl.java 13 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/property/service/IPropertyCompanyDistrictService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyDistrictServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskBailReportingEventService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskCampusReportingEventService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskHotelReportingService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskLabelReportingEventService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskNoFraudReportingService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskPlaceSelfCheckService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskBailReportingEventServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskCampusReportingEventServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskHotelReportingServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskNoFraudReportingServiceImpl.java 40 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskPlaceSelfCheckServiceImpl.java 11 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/wechat/service/WechatService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/wechat/service/impl/WechatServiceImpl.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/exception/CustomException.java
New file
@@ -0,0 +1,18 @@
package org.springblade.common.exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class CustomException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    public CustomException() {}
    public CustomException(String message) {
        super(message);
    }
}
src/main/java/org/springblade/modules/pay/service/IWxPayService.java
@@ -28,7 +28,7 @@
    void processRefund(Map<String, Object> bodyMap) throws Exception;
    Map<String, String> jsapiPay(Long productId) throws IOException, Exception;
    Map<String, String> jsapiPay(Long productId) throws IOException;
    String refundsNotify(HttpServletRequest request, HttpServletResponse response);
src/main/java/org/springblade/modules/pay/service/impl/WxPayServiceImpl.java
@@ -20,6 +20,7 @@
import org.springblade.common.enums.wxpay.WxNotifyType;
import org.springblade.common.enums.wxpay.WxRefundStatus;
import org.springblade.common.enums.wxpay.WxTradeState;
import org.springblade.common.exception.CustomException;
import org.springblade.common.utils.HttpUtils;
import org.springblade.common.utils.SpringUtils;
import org.springblade.common.utils.WechatPay2ValidatorForRequest;
@@ -410,13 +411,13 @@
    @Override
    public Map<String, String> jsapiPay(Long properChargeRecordId) throws Exception {
    public Map<String, String> jsapiPay(Long properChargeRecordId) throws IOException {
        String prepayId = "";
        //生成订单
        OrderInfoEntity orderInfo = orderInfoService.getOne(Wrappers.<OrderInfoEntity>lambdaQuery().eq(OrderInfoEntity::getProperChargeRecordId, properChargeRecordId));
        if (orderInfo.getTotalFee() <= 0) {
            throw new Exception("支付金额不能低于等于0元");
            throw new CustomException("支付金额不能低于等于0元");
        }
        IUserService userService = SpringUtils.getBean(IUserService.class);
        User serviceOne = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getId, AuthUtil.getUserId()));
@@ -493,6 +494,14 @@
            payMap.put("paySign", paySign);
            logger.info("返回参数 ===> {}" + gson.toJson(payMap));
            return payMap;
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (SignatureException e) {
            throw new RuntimeException(e);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (InvalidKeyException e) {
            throw new RuntimeException(e);
        } finally {
            response.close();
        }
src/main/java/org/springblade/modules/property/service/IPropertyCompanyDistrictService.java
@@ -48,7 +48,7 @@
     * @param propertyCompanyDistrict
     * @return
     */
    boolean saveOrUpdatePropertyCompanyDistrict(PropertyCompanyDistrictEntity propertyCompanyDistrict) throws Exception;
    boolean saveOrUpdatePropertyCompanyDistrict(PropertyCompanyDistrictEntity propertyCompanyDistrict);
    List<UserEntity> getDistictUserByCode(String houseCode);
}
src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyDistrictServiceImpl.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.flowable.idm.engine.impl.persistence.entity.UserEntity;
import org.springblade.common.exception.CustomException;
import org.springblade.common.utils.RoleUtil;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
@@ -84,7 +85,7 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdatePropertyCompanyDistrict(PropertyCompanyDistrictEntity propertyCompanyDistrict) throws Exception {
    public boolean saveOrUpdatePropertyCompanyDistrict(PropertyCompanyDistrictEntity propertyCompanyDistrict) {
        // IUserService bean = SpringUtil.getBean(IUserService.class);
        // User user = bean.getOne(Wrappers.<User>lambdaQuery().eq(User::getId, propertyCompanyDistrict.getPrincipal()));
        // if (StringUtils.isNotBlank(user.getRoleId())) {
@@ -103,7 +104,7 @@
                .eq(PropertyCompanyDistrictEntity::getPropertyCompanyId, propertyCompanyDistrict.getPropertyCompanyId())
                .eq(PropertyCompanyDistrictEntity::getIsDeleted, 0));
            if (count > 0) {
                throw new Exception("您已有该小区的合同,请勿重复添加!");
                throw new CustomException("您已有该小区的合同,请勿重复添加!");
            }
            // bean.updateById(user);
            return save(propertyCompanyDistrict) && submitPropertyDistrictUser(propertyCompanyDistrict);
src/main/java/org/springblade/modules/task/service/ITaskBailReportingEventService.java
@@ -42,5 +42,5 @@
    Boolean saveBailReporting(TaskBailReportingEventDTO taskBailReportingEvent);
    Boolean updateBailReporting(TaskBailReportingEventEntity taskBailReportingEvent) throws Exception;
    Boolean updateBailReporting(TaskBailReportingEventEntity taskBailReportingEvent) ;
}
src/main/java/org/springblade/modules/task/service/ITaskCampusReportingEventService.java
@@ -42,5 +42,5 @@
    Boolean saveCampusReporting(TaskCampusReportingEventDTO taskCampusReportingEvent);
    Boolean updateCampusReporting(TaskCampusReportingEventDTO taskCampusReportingEvent) throws Exception;
    Boolean updateCampusReporting(TaskCampusReportingEventDTO taskCampusReportingEvent);
}
src/main/java/org/springblade/modules/task/service/ITaskHotelReportingService.java
@@ -48,5 +48,5 @@
     */
    boolean saveHotelReporting(TaskHotelReportingDTO taskHotelReporting);
    Boolean updateHotelReporting(TaskHotelReportingVO taskHotelReporting) throws Exception;
    Boolean updateHotelReporting(TaskHotelReportingVO taskHotelReporting);
}
src/main/java/org/springblade/modules/task/service/ITaskLabelReportingEventService.java
@@ -46,7 +46,7 @@
    Boolean saveReportingEven(TaskLabelReportingEventDTO taskLabelReportingEvent);
    Boolean updateLabelReporting(TaskLabelReportingEventVO taskLabelReportingEvent) throws Exception;
    Boolean updateLabelReporting(TaskLabelReportingEventVO taskLabelReportingEvent);
    /**
     * 查询打金店报事
src/main/java/org/springblade/modules/task/service/ITaskNoFraudReportingService.java
@@ -50,4 +50,6 @@
    TaskNoFraudReportingVO selectTaskNoFraudReportingById(TaskNoFraudReportingEntity taskNoFraudReporting);
    List<TaskNoExplosionExcel> exportTaskNoFraudReporting(TaskNoFraudReportingVO taskNoFraudReportingVO);
    Boolean updateTaskNoFraudReporting(TaskNoFraudReportingVO taskNoFraudReporting);
}
src/main/java/org/springblade/modules/task/service/ITaskPlaceSelfCheckService.java
@@ -59,9 +59,9 @@
    public List<TaskPlaceSelfCheckDTO> selectTaskPlaceSelfCheckList(TaskPlaceSelfCheckDTO taskPlaceSelfCheckDTO);
    Boolean savePlace(TaskPlaceSelfCheckVO taskPlaceSelfCheck) throws Exception;
    Boolean savePlace(TaskPlaceSelfCheckVO taskPlaceSelfCheck) ;
    Boolean updateTaskPlaceSelfCheck(TaskPlaceSelfCheckVO taskPlaceSelfCheck) throws Exception;
    Boolean updateTaskPlaceSelfCheck(TaskPlaceSelfCheckVO taskPlaceSelfCheck);
    /**
     * 导出消防自查信息
src/main/java/org/springblade/modules/task/service/impl/TaskBailReportingEventServiceImpl.java
@@ -19,6 +19,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.commons.lang3.StringUtils;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.exception.CustomException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.task.dto.TaskBailReportingEventDTO;
@@ -67,7 +68,7 @@
    }
    @Override
    public Boolean updateBailReporting(TaskBailReportingEventEntity taskBailReportingEvent) throws Exception {
    public Boolean updateBailReporting(TaskBailReportingEventEntity taskBailReportingEvent)  {
        Integer integer = StringUtils.isBlank(taskBailReportingEvent.getConfirmFlag()) ? null : Integer.valueOf(taskBailReportingEvent.getConfirmFlag());
        Long aLong = taskService.updateTask(null, null, null, "", AuthUtil.getUserId(), taskBailReportingEvent.getTaskId(), integer);
        if (aLong > 0) {
@@ -77,7 +78,7 @@
            if (b) {
                return b;
            }
            throw new Exception("更新失败!");
            throw new CustomException("更新失败!");
        }
        return false;
    }
src/main/java/org/springblade/modules/task/service/impl/TaskCampusReportingEventServiceImpl.java
@@ -21,6 +21,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.exception.CustomException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.place.entity.PlaceEntity;
import org.springblade.modules.place.service.IPlaceService;
@@ -83,7 +84,7 @@
    @Override
    public Boolean updateCampusReporting(TaskCampusReportingEventDTO taskCampusReportingEvent) throws Exception {
    public Boolean updateCampusReporting(TaskCampusReportingEventDTO taskCampusReportingEvent)  {
        Integer integer = null==taskCampusReportingEvent.getStatus() ? null : taskCampusReportingEvent.getStatus();
        Long aLong = taskService.updateTask(null, null, null, "", AuthUtil.getUserId(), taskCampusReportingEvent.getTaskId(), integer);
        if (aLong > 0) {
@@ -97,7 +98,7 @@
            if (b) {
                return b;
            }
            throw new Exception("更新失败!");
            throw new CustomException("更新失败!");
        }
        return false;
    }
src/main/java/org/springblade/modules/task/service/impl/TaskHotelReportingServiceImpl.java
@@ -20,6 +20,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.exception.CustomException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.place.entity.PlaceEntity;
import org.springblade.modules.place.service.IPlaceService;
@@ -86,7 +87,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateHotelReporting(TaskHotelReportingVO taskHotelReporting) throws Exception {
    public Boolean updateHotelReporting(TaskHotelReportingVO taskHotelReporting) {
        Long aLong = taskService.updateTask(null, null, null, "", AuthUtil.getUserId(), taskHotelReporting.getTaskId(), taskHotelReporting.getStatus());
        if (aLong > 0) {
            if (null!=taskHotelReporting.getStatus()
@@ -99,7 +100,7 @@
            if (b) {
                return b;
            }
            throw new Exception("更新失败!");
            throw new CustomException("更新失败!");
        }
        return false;
    }
src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java
@@ -22,6 +22,7 @@
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.exception.CustomException;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
@@ -93,7 +94,7 @@
    @Override
    public Boolean updateLabelReporting(TaskLabelReportingEventVO taskLabelReportingEvent) throws Exception {
    public Boolean updateLabelReporting(TaskLabelReportingEventVO taskLabelReportingEvent)  {
        Long aLong = taskService.updateTask(null, null, null, "", AuthUtil.getUserId(),
            taskLabelReportingEvent.getTaskId(), taskLabelReportingEvent.getStatus());
        if (aLong > 0) {
@@ -109,7 +110,7 @@
            if (b) {
                return b;
            }
            throw new Exception("更新失败!");
            throw new CustomException("更新失败!");
        }
        return false;
    }
src/main/java/org/springblade/modules/task/service/impl/TaskNoFraudReportingServiceImpl.java
@@ -16,30 +16,28 @@
 */
package org.springblade.modules.task.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.exception.CustomException;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.system.entity.DictBiz;
import org.springblade.modules.task.dto.TaskNoFraudReportingDTO;
import org.springblade.modules.task.dto.TaskPlaceSelfCheckDTO;
import org.springblade.modules.task.entity.TaskNoFraudReportingEntity;
import org.springblade.modules.task.entity.TaskPlaceRecordEntity;
import org.springblade.modules.task.excel.TaskNoExplosionExcel;
import org.springblade.modules.task.mapper.TaskNoFraudReportingMapper;
import org.springblade.modules.task.service.ITaskNoFraudReportingService;
import org.springblade.modules.task.entity.TaskNoFraudReportingEntity;
import org.springblade.modules.task.service.ITaskPlaceRecordService;
import org.springblade.modules.task.service.ITaskService;
import org.springblade.modules.task.vo.TaskNoFraudReportingVO;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.task.vo.TaskPlaceRecordVO;
import org.springblade.modules.task.vo.TaskPlaceSelfCheckVO;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@@ -121,4 +119,32 @@
            commonParamSet.getGridCodeList());
        return taskNoExplosionExcels;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateTaskNoFraudReporting(TaskNoFraudReportingVO taskNoFraudReporting){
        // 1.更新任务表
        ITaskService taskService = SpringUtils.getBean(ITaskService.class);
        Long aLong = taskService.updateTask(null, null, null, taskNoFraudReporting.getReasonFailure(), AuthUtil.getUserId(), taskNoFraudReporting.getTaskId(), taskNoFraudReporting.getStatus());
        if (aLong <= 0) {
            return false;
        }
        // 2.更新任务详情
        boolean save = updateById(taskNoFraudReporting);
        if (save) {
            // 3.更新题目记录
            List<TaskPlaceRecordVO> taskPlaceRecordList = taskNoFraudReporting.getTaskPlaceRecordVOList();
            if (taskPlaceRecordList != null && taskPlaceRecordList.size() > 0) {
                ITaskPlaceRecordService bean = SpringUtil.getBean(ITaskPlaceRecordService.class);
                List<TaskPlaceRecordEntity> copy = BeanUtil.copy(taskPlaceRecordList, TaskPlaceRecordEntity.class);
                boolean b = bean.saveOrUpdateBatch(copy);
                if (b) {
                    return b;
                }
                throw new CustomException("保存失败!");
            }
            return save;
        }
        throw new CustomException("保存失败!");
    }
}
src/main/java/org/springblade/modules/task/service/impl/TaskPlaceSelfCheckServiceImpl.java
@@ -22,6 +22,7 @@
import liquibase.repackaged.org.apache.commons.lang3.StringUtils;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.exception.CustomException;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.AuthUtils;
import org.springblade.common.utils.SpringUtils;
@@ -136,7 +137,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean savePlace(TaskPlaceSelfCheckVO taskPlaceSelfCheck) throws Exception {
    public Boolean savePlace(TaskPlaceSelfCheckVO taskPlaceSelfCheck)  {
        taskPlaceSelfCheck.setCreateUser(AuthUtil.getUserId());
        // 1.保存任务表
        ITaskService bean2 = SpringUtils.getBean(ITaskService.class);
@@ -168,8 +169,8 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateTaskPlaceSelfCheck(TaskPlaceSelfCheckVO taskPlaceSelfCheck) throws Exception {
    @Transactional
    public Boolean updateTaskPlaceSelfCheck(TaskPlaceSelfCheckVO taskPlaceSelfCheck) {
        // 1.更新任务表
        ITaskService taskService = SpringUtils.getBean(ITaskService.class);
        Long aLong = taskService.updateTask(null, null, null, taskPlaceSelfCheck.getReasonFailure(), AuthUtil.getUserId(), taskPlaceSelfCheck.getTaskId(), taskPlaceSelfCheck.getStatus());
@@ -188,11 +189,11 @@
                if (b) {
                    return b;
                }
                throw new Exception("保存失败!");
                throw new CustomException("保存失败!");
            }
            return save;
        }
        throw new Exception("保存失败!");
        throw new CustomException("保存失败!");
    }
    /**
src/main/java/org/springblade/modules/wechat/service/WechatService.java
@@ -8,5 +8,5 @@
     *
     * @return 小程序登录校验对象
     */
    WeChatMiniAuthorizeVo miniAuthCode(String code) throws Exception;
    WeChatMiniAuthorizeVo miniAuthCode(String code);
}
src/main/java/org/springblade/modules/wechat/service/impl/WechatServiceImpl.java
@@ -8,6 +8,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.config.WxMiniConfig;
import org.springblade.common.exception.CustomException;
import org.springblade.common.utils.HttpClientUtils;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
@@ -33,17 +34,17 @@
     * @return 小程序登录校验对象
     */
    @Override
    public WeChatMiniAuthorizeVo miniAuthCode(String code) throws Exception {
    public WeChatMiniAuthorizeVo miniAuthCode(String code) {
        String url = StrUtil.format(wxMiniConfig.getJscode2sessionUrl(), wxMiniConfig.getAppid(), wxMiniConfig.getSecret(), code);
        JSONObject data = JSON.parseObject(HttpClientUtils.doGet(url));
        if (ObjectUtil.isNull(data)) {
            logger.error("微信平台接口异常,没任何数据返回!");
            throw new Exception("微信平台接口异常,没任何数据返回!");
            throw new CustomException("微信平台接口异常,没任何数据返回!");
        }
        if (data.containsKey("errcode") && !data.getString("errcode").equals("0")) {
            if (data.containsKey("errmsg")) {
                logger.error("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
                throw new Exception("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
                throw new CustomException("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
            }
        }
        WeChatMiniAuthorizeVo weChatMiniAuthorizeVo = JSONObject.parseObject(data.toJSONString(), WeChatMiniAuthorizeVo.class);