Exemplo n.º 1
0
  @Override
  public void save(EditableModel obj) throws DaoException {
    ExternalApp externalApp = (ExternalApp) obj;
    externalApp.setAppId(createAppId());
    externalApp.setThreeDesKey(getUUID());
    externalApp.setCreateTime(new Date());
    externalApp.setUpdateTime(externalApp.getCreateTime());

    User user = new User();
    user.setUserName(externalApp.getAppName());
    user.setPassword(DigestUtils.md5Hex(SystemConfig.getString("system.user.default-password")));
    user.setCreateTime(new Date());
    user.setUpdateTime(user.getCreateTime());
    user.setState(Constants.FLAG_USER_STATE_USING.value());
    user.setType(Constants.FLAG_USER_TYPE_APPUSER.value());
    try {
      userDao.save(user);
      User newUser = userDao.queryByUserName(user.getUserName());
      externalApp.setUser(newUser);
      externalAppDao.save(externalApp);
    } catch (Exception e) {
      LogUtil.error(this, "ExternalAppServiceImpl.save error", e);
      throw new DaoException(e);
    }
  }
Exemplo n.º 2
0
 @Override
 public long getTotal(String keyword) throws DaoException {
   try {
     DetachedCriteria criteria = DetachedCriteria.forClass(ExternalApp.class);
     if (StringUtils.isNotEmpty(keyword)) {
       AbstractRestriction ar = new LikeRestriction("appName", keyword);
       criteria.add(ar.getCriterion());
     }
     return externalAppDao.queryCount(criteria);
   } catch (Exception e) {
     LogUtil.error(this, "ExternalAppServiceImpl.getTotal error", e);
     throw new DaoException(e);
   }
 }
Exemplo n.º 3
0
 @Override
 public List<ExternalApp> getExternalAppByPage(int pageIndex, int pageSize, String keyword)
     throws DaoException {
   try {
     DetachedCriteria criteria = DetachedCriteria.forClass(ExternalApp.class);
     if (StringUtils.isNotEmpty(keyword)) {
       AbstractRestriction ar = new LikeRestriction("appName", keyword);
       criteria.add(ar.getCriterion());
     }
     return externalAppDao.queryByCriteria(criteria, pageIndex, pageSize);
   } catch (Exception e) {
     LogUtil.error(this, "ExternalAppServiceImpl.getByPage error", e);
     throw new DaoException(e);
   }
 }