@Override public Template save(Template entity) { String subject = ""; String operate = OperateLog.OPERATE_CREATE; if (entity.isNew()) { subject = "新建模板:" + entity.getSubject(); } else { subject = "更新模板:" + entity.getSubject(); operate = OperateLog.OPERATE_UPDATE; } // 正常 if (entity.getStatus() == BCConstants.STATUS_ENABLED) { Template oldTpl = this.templateDao.loadByCodeAndId(entity.getCode(), entity.getId()); if (oldTpl != null) { this.operateLogService.saveWorkLog( Template.class.getSimpleName(), oldTpl.getId().toString(), "禁用旧模板:" + oldTpl.getSubject(), null, OperateLog.OPERATE_UPDATE); oldTpl.setStatus(BCConstants.STATUS_DISABLED); this.templateDao.save(oldTpl); } } entity = this.templateDao.save(entity); this.operateLogService.saveWorkLog( Template.class.getSimpleName(), entity.getId().toString(), subject, null, operate); return entity; }
public void saveTpl(Template template) { Template oldTpl = this.templateDao.loadByCodeAndId(template.getCode(), template.getId()); if (oldTpl != null) { oldTpl.setStatus(BCConstants.STATUS_DISABLED); this.templateDao.save(oldTpl); } this.templateDao.save(template); }