@Override
  @Transactional(readOnly = false)
  public int save(SysLogin entity, Long[] roleIds, Long deptId) throws Exception {
    String hql = "select count(*) from SysLogin as model where model.loginName= ?)";
    long count = baseDao.findLong(hql, entity.getLoginName());
    if (count > 0) {
      return ResultConstants.SAVE_FAILED_NAME_IS_EXIST;
    }

    hql = "select count(*) from SysLogin as model where model.userCode= ?)";
    count = baseDao.findLong(hql, entity.getUserCode());
    if (count > 0) {
      return ResultConstants.SAVE_FAILED_CODE_IS_EXIST;
    }

    hql = "select count(*) from SysLogin as model where model.idCard= ?)";
    count = baseDao.findLong(hql, entity.getIdCard());
    if (count > 0) {
      return ResultConstants.SAVE_FAILED_NAME_IS_EXIST;
    }

    entity.setLoginPwd(MD5Utils.toMD5(entity.getLoginPwd()));
    baseDao.save(entity);
    sysLoginRoleService.saveLoginRole(entity, roleIds);
    // 保存系统日志
    String operDesc = "【用户新增】用户名:" + entity.getLoginName();
    sysLogService.save(SysLog.OPERATE_TYPE_ADD, operDesc);
    return ResultConstants.SAVE_SUCCEED;
  }