Example #1
0
  // 保存
  public void save(BusinessRequest res) {

    HopIncDto dto = super.getDto(HopIncDto.class, res);
    if (dto.getHopInc().getIncId() == null) {
      dto.getHopInc().setIncHospid(Long.valueOf(super.getLoginInfo().get("HOPID").toString()));
    } else {
      List<HopIncAlias> hopIncAlias =
          commonService.findByProperty(
              HopIncAlias.class, "incAliaIncId", dto.getHopInc().getIncId());
      if (hopIncAlias.size() > 0) {
        for (HopIncAlias hopIncAlias2 : hopIncAlias) {
          commonService.delete(hopIncAlias2);
        }
      }
    }
    if (org.apache.commons.lang.StringUtils.isNotBlank(dto.getHopInc().getIncAliaS())) {
      String[] alias = dto.getHopInc().getIncAliaS().split(",");
      for (String alia : alias) {
        HopIncAlias hopIncAlias = new HopIncAlias();
        hopIncAlias.setIncAliasText(alia);
        hopIncAlias.setIncAliaIncId(dto.getHopInc().getIncId());
        commonService.saveOrUpdate(hopIncAlias);
      }
    } else {
      HopIncAlias hopIncAlias = new HopIncAlias();
      hopIncAlias.setIncAliasText(PingYinUtil.getFirstSpell(dto.getHopInc().getIncName()));
      hopIncAlias.setIncAliaIncId(dto.getHopInc().getIncId());
      commonService.saveOrUpdate(hopIncAlias);
    }
    commonService.saveOrUpdate(dto.getHopInc());
  }
Example #2
0
  /**
   * 修改初始化方法 也是根据iD查询实体的方法 在action加能过注解把这个实体to json
   *
   * @param: res
   */
  @SuppressWarnings("unchecked")
  public void findById(BusinessRequest res) {

    HopIncDto dto = super.getDto(HopIncDto.class, res);

    // 调用对应的service方法

    hopIncService.findById(dto);
    DetachedCriteria criteria = DetachedCriteria.forClass(HopIncAlias.class);
    criteria.setProjection(Property.forName("incAliasText"));
    criteria.add(Restrictions.eq("incAliaIncId", dto.getHopInc().getIncId()));
    List<String> alias = commonService.findByDetachedCriteria(criteria);
    dto.getHopInc().setIncAliaS(org.apache.commons.lang.StringUtils.join(alias, ","));
  }