Example #1
0
 @Override
 public Integer update(ModelCarType t) {
   try {
     // validation
     if (t == null) {
       return null;
     }
     // persist object in security mode
     ModelCarType carTypeDB = find(t.getId());
     BeanUtils.copyProperties(carTypeDB, t, false);
     // update inner object chargeStandard
     ModelChargeStandard chargeStandard = t.getChargeStandard();
     if (chargeStandard != null) {
       iServChargeStandard.update(chargeStandard);
       carTypeDB.setChargeStandardId(chargeStandard.getId());
     }
     ModelFileUpload icon = t.getIcon();
     if (icon != null) {
       iServFileUpload.uploadFile(icon);
       carTypeDB.setIconId(icon.getId());
     }
     return super.update(carTypeDB);
   } catch (Exception e) {
     throw new ServException(e);
   }
 }
Example #2
0
 @Override
 public Integer add(ModelCarType t) {
   // validation
   if (t == null) {
     return null;
   }
   // update inner object chargeStandard
   ModelChargeStandard chargeStandard = t.getChargeStandard();
   if (chargeStandard != null) {
     iServChargeStandard.add(chargeStandard);
     t.setChargeStandardId(chargeStandard.getId());
   }
   // update t
   t.setCreateTime(new Date());
   t.setUpdateTime(new Date());
   // update icon information
   ModelFileUpload icon = t.getIcon();
   // update DB
   if (icon != null) {
     icon = iServFileUpload.uploadFile(icon);
     t.setIconId(icon.getId());
   }
   return super.add(t);
 }