浏览代码

代码提交

chenweida 8 年之前
父节点
当前提交
15bfa107e5
共有 1 个文件被更改,包括 10 次插入9 次删除
  1. 10 9
      svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsGatewayService.java

+ 10 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsGatewayService.java

@ -4,6 +4,7 @@ import com.yihu.jw.base.dao.sms.SmsGatewayDao;
import com.yihu.jw.base.model.sms.BaseSmsGateway;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.base.sms.BaseSmsContants;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,14 +23,14 @@ public class SmsGatewayService extends BaseJpaService<BaseSmsGateway, SmsGateway
    @Transactional
    public BaseSmsGateway createSmsGateway(BaseSmsGateway smsGateway) throws ApiException {
        if (StringUtils.isEmpty(smsGateway.getCode())) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        BaseSmsGateway smsGatewayTmp = smsGatewayDao.findByName(smsGateway.getName());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
@ -37,17 +38,17 @@ public class SmsGatewayService extends BaseJpaService<BaseSmsGateway, SmsGateway
    @Transactional
    public BaseSmsGateway updateSmsGateway(BaseSmsGateway smsGateway) {
        if (StringUtils.isEmpty(smsGateway.getCode())) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getId())) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_id_is_null, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        BaseSmsGateway smsGatewayTmp = smsGatewayDao.findByNameExcludeCode(smsGateway.getName(), smsGateway.getCode());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
@ -55,7 +56,7 @@ public class SmsGatewayService extends BaseJpaService<BaseSmsGateway, SmsGateway
    public BaseSmsGateway findByCode(String code) {
        BaseSmsGateway smsGateway = smsGatewayDao.findByCode(code);
        if (smsGateway == null) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return smsGateway;
    }
@ -64,7 +65,7 @@ public class SmsGatewayService extends BaseJpaService<BaseSmsGateway, SmsGateway
    public void deleteSmsGateway(String code) {
        BaseSmsGateway smsGateway = smsGatewayDao.findByCode(code);
        if (smsGateway == null) {
            throw new ApiException(BaseContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        smsGateway.setStatus(-1);
    }