Java Code Examples for com.alibaba.druid.util.StringUtils#isEmpty()

The following examples show how to use com.alibaba.druid.util.StringUtils#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LitemallCouponServiceImpl.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
public List<LitemallCoupon> querySelective(String name, Short type, Short status, Integer page, Integer limit, String sort, String order) {
    LitemallCouponExample example = new LitemallCouponExample();
    LitemallCouponExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    if (type != null) {
        criteria.andTypeEqualTo(type);
    }
    if (status != null) {
        criteria.andStatusEqualTo(status);
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return couponMapper.selectByExample(example);
}
 
Example 2
Source File: AdminServiceImpl.java    From product-recommendation-system with MIT License 6 votes vote down vote up
@Override
public Admin loginAdmin(String loginName, String password) {
	if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
		return null;
	}
	Admin admin = new Admin();
	admin.setLoginName(loginName);
	
	// 调用mapper去查询符合条件的用户列表
	List<Admin> userList = this.adminMapper.listAdmin(admin);
	if (userList.isEmpty()) {
		return null;
	}
	
	// 用户列表不为空则验证密码是否正确,正确则返回该用户
	Admin plainUser = userList.get(0);
	String encryptedPassword = plainUser.getPassword();
	if (validatePsd(password, encryptedPassword)) {
		return plainUser;
	}
	
	return null;
}
 
Example 3
Source File: PersonsController.java    From maintain with MIT License 6 votes vote down vote up
@RequestMapping("/statistics")
public ModelAndView statistics(PersonalInfo personalInfo) {
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    if (null == personalInfo) {
    	personalInfo = new PersonalInfo();
	}

	if (StringUtils.isEmpty(personalInfo.getGroupOne())) {
		personalInfo.setGroupOne("to_char(pil1.sys_date, 'yyyy-mm-dd')");
		personalInfo.setSysDateStr(sdf.format(Calendar.getInstance().getTime()));
	}
	final Map<String, String> groupField = new LinkedHashMap<String, String>(){{
		this.put("to_char(pil1.sys_date, 'yyyy-mm-dd hh')", "按小时");
		this.put("to_char(pil1.sys_date, 'yyyy-mm-dd')", "按天");
		this.put("to_char(pil1.sys_date, 'yyyy-mm')", "按月");
		this.put("to_char(pil1.sys_date, 'yyyy')", "按年");
	}};
	PageInfo<PersonalInfo> pageInfo = this.getPageInfo(personalInfo, PersonalInfo.class, this.personalInfoService, "statisticsPersonalInfo");
	ModelAndView mv = this.buildBaseModelAndView("persons/statistics", pageInfo);
	mv.addObject("personalInfo", personalInfo);
	mv.addObject("personalInfoList", pageInfo.getList());
	mv.addObject("groupField", groupField);
	return mv;
}
 
Example 4
Source File: LoginMemberController.java    From product-recommendation-system with MIT License 6 votes vote down vote up
/**
 * 用来验证用户登录的请求
 * @return
 */
@RequestMapping(value="/loginMember")
public String loginMember(String loginName, String password, HttpServletRequest request, HttpSession session) {
	// 1.合法性校验
	if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
		request.setAttribute(ERR_MSG_ATTR, ERR_MSG_CONTENT);
		return LOGIN_MEMBER_URI;
	}
	// 2.调用service层方法去查询,获得返回结果
	Member member = memberService.loginMember(loginName, password);
	// 3.成功重定向到首页,并且把当前用户的信息放入session中
	if (member != null) {
		session.setAttribute("member", member);
		return "redirect:/index.jsp";
	}
	// 4.失败则转发会原页面
	request.setAttribute(ERR_MSG_ATTR, ERR_MSG_CONTENT);
	return "forward:/toLogin";
}
 
Example 5
Source File: FinanceConsumer.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
/**
 * 异步打钱后返回状态
 * @param record
 */
@KafkaListener(topics = {"withdraw-notify"})
public void withdrawNotify(ConsumerRecord<String, String> record){
    logger.info("topic={},accessKey={},value={}", record.topic(), record.key(), record.value());
    if (StringUtils.isEmpty(record.value())) {
        return;
    }
    JSONObject json = JSON.parseObject(record.value());
    Long withdrawId = json.getLong("withdrawId");
    WithdrawRecord withdrawRecord=withdrawRecordService.findOne(withdrawId);
    if(withdrawRecord==null){
        return;
    }
    String txid=json.getString("txid");
    int status=json.getInteger("status");
    //转账失败,状态变回等待放币
    if(status==0){
        withdrawRecord.setStatus(WithdrawStatus.WAITING);
        withdrawRecordService.save(withdrawRecord);
    }else if(status==1){
        withdrawRecordService.withdrawSuccess(withdrawId, txid);
    }
}
 
Example 6
Source File: PmsRolePermissionServiceImpl.java    From roncoo-pay with Apache License 2.0 6 votes vote down vote up
/**
 * 根据角色ID集得到所有权限ID集
 * 
 * @param roleIds
 * @return actionIds
 */
private String getActionIdsByRoleIds(String roleIds) {
	// 得到角色-权限表中roleiId在ids中的所有关联对象
	List<PmsRolePermission> listRolePermission = pmsRolePermissionDao.listByRoleIds(roleIds); // 构建StringBuffer
	StringBuffer actionIdsBuf = new StringBuffer("");
	// 拼接字符串
	for (PmsRolePermission pmsRolePermission : listRolePermission) {
		actionIdsBuf.append(pmsRolePermission.getPermissionId()).append(",");
	}
	String actionIds = actionIdsBuf.toString();
	// 截取字符串
	if (StringUtils.isEmpty(actionIds) && actionIds.length() > 0) {
		actionIds = actionIds.substring(0, actionIds.length() - 1); // 去掉最后一个逗号
	}
	return actionIds;
}
 
Example 7
Source File: FinanceConsumer.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
/**
 * 处理充值消息,key值为币种的名称(注意是全称,如Bitcoin)
 *
 * @param record
 */
@KafkaListener(topics = {"deposit"})
public void handleDeposit(ConsumerRecord<String, String> record) {
    logger.info("topic={},key={},value={}", record.topic(), record.key(), record.value());
    if (StringUtils.isEmpty(record.value())) {
        return;
    }
    JSONObject json = JSON.parseObject(record.value());
    if (json == null) {
        return;
    }
    BigDecimal amount = json.getBigDecimal("amount");
    String txid = json.getString("txid");
    String address = json.getString("address");
    Coin coin = coinService.findOne(record.key());
    logger.info("coin={}", coin);

    if (coin != null && walletService.findDeposit(address, txid) == null) {
        MessageResult mr = walletService.recharge(coin, address, amount, txid);
        logger.info("wallet recharge result:{}", mr);
    }
}
 
Example 8
Source File: RegistMemberController.java    From product-recommendation-system with MIT License 6 votes vote down vote up
/**
 * 检查用户名是否存在
 * @param userName
 * @return
 */
@RequestMapping("/checkUser/{loginName}")
public @ResponseBody Map<String, String> checkUserName(@PathVariable(value="loginName") String loginName) {
	Map<String, String> messageMap = new HashMap<String, String>();
	messageMap.put("isExists", "false");
	
	if (StringUtils.isEmpty(loginName)) {
		// 用户名不存在,返回
		return messageMap;
	}
	// 1.创建member对象
	Member member = new Member();
	member.setLoginName(loginName);
	
	// 2.验证某个用户名是否存在
	List<Member> memeberList = memberService.listMember(member);
	if (memeberList.size() > 0) {
		messageMap.put("isExists", "true");
	}
	
	return messageMap;
}
 
Example 9
Source File: LitemallRoleServiceImpl.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
public List<LitemallRole> querySelective(String name, Integer page, Integer limit, String sort, String order) {
    LitemallRoleExample example = new LitemallRoleExample();
    LitemallRoleExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return roleMapper.selectByExample(example);
}
 
Example 10
Source File: DtsGrouponRulesService.java    From dts-shop with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 获取团购活动列表
 *
 * @param goodsId
 * @param page
 * @param size
 * @param sort
 * @param order
 * @return
 */
public List<DtsGrouponRules> querySelective(String goodsId, Integer page, Integer size, String sort, String order) {
	DtsGrouponRulesExample example = new DtsGrouponRulesExample();
	example.setOrderByClause(sort + " " + order);

	DtsGrouponRulesExample.Criteria criteria = example.createCriteria();

	if (!StringUtils.isEmpty(goodsId)) {
		criteria.andGoodsIdEqualTo(Integer.parseInt(goodsId));
	}
	criteria.andDeletedEqualTo(false);

	PageHelper.startPage(page, size);
	return mapper.selectByExample(example);
}
 
Example 11
Source File: DtsGrouponService.java    From dts-shop with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 查询所有发起的团购记录
 *
 * @param rulesId
 * @param page
 * @param size
 * @param sort
 * @param order
 * @return
 */
public List<DtsGroupon> querySelective(String rulesId, Integer page, Integer size, String sort, String order) {
	DtsGrouponExample example = new DtsGrouponExample();
	DtsGrouponExample.Criteria criteria = example.createCriteria();

	if (!StringUtils.isEmpty(rulesId)) {
		criteria.andRulesIdEqualTo(Integer.parseInt(rulesId));
	}
	criteria.andDeletedEqualTo(false);
	criteria.andPayedEqualTo(true);
	criteria.andGrouponIdEqualTo(0);

	PageHelper.startPage(page, size);
	return mapper.selectByExample(example);
}
 
Example 12
Source File: HttpClientTool.java    From maintain with MIT License 5 votes vote down vote up
public static List<NetInterfaceInfo> getNetInterfaceInfoListJson(String url) {
	Gson gson = new Gson();
	String result = get(url + "netInterfaceInfo");
	if (!StringUtils.isEmpty(result)) {
		return Arrays.asList(gson.fromJson(result, NetInterfaceInfo[].class));
	} else {
		return null;
	}
}
 
Example 13
Source File: ParaTool.java    From maintain with MIT License 5 votes vote down vote up
public static String getWrapDesc(String wrapCode, WrapService wrapService) {
	String result = "";
	Para para = null;
	if (StringUtils.isEmpty(CommonConstant.getWRAP_TYPE_MAP().get(wrapCode))) {
		para = wrapService.getWrapByCode(wrapCode);
		if (null != para) {
			CommonConstant.getWRAP_TYPE_MAP().put(wrapCode, para.getName());
			result = para.getName();
		}
	} else {
		result = CommonConstant.getWRAP_TYPE_MAP().get(wrapCode);
	}
	return result;
}
 
Example 14
Source File: HttpClientTool.java    From maintain with MIT License 5 votes vote down vote up
public static <T> T getJson(String url, Class<T> clazz) {
	Gson gson = new Gson();
	String result = get(url);
	if (!StringUtils.isEmpty(result)) {
		return gson.fromJson(result, clazz);
	} else {
		return null;
	}
}
 
Example 15
Source File: JSONUtils.java    From yyblog with MIT License 5 votes vote down vote up
/**
 * Bean对象转JSON
 * 
 * @param object
 * @param dataFormatString
 * @return
 */
public static String beanToJson(Object object, String dataFormatString) {
    if (object != null) {
        if (StringUtils.isEmpty(dataFormatString)) {
            return JSONObject.toJSONString(object);
        }
        return JSON.toJSONStringWithDateFormat(object, dataFormatString);
    } else {
        return null;
    }
}
 
Example 16
Source File: AdminServiceImpl.java    From product-recommendation-system with MIT License 5 votes vote down vote up
@Override
@Transactional(isolation=Isolation.DEFAULT, propagation = Propagation.REQUIRED)
public boolean updatePassword(Long adminId, String oldPassword,
		String newPassword, String confirmPassword) {
	// 1.确定密码用户id是否为空
	if (StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword) || 
		StringUtils.isEmpty(confirmPassword) || adminId == null) {
		return false; 
	}
	
	// 2.确定旧密码是否正确
	String dbPassword = this.adminMapper.getAdminByAdminId(adminId).getPassword();
	boolean flag = this.validatePsd(oldPassword, dbPassword);
	if (!flag) {
		return false;
	}
	
	// 3.确定两次输入的新密码是否一致
	if (!newPassword.equals(confirmPassword)) {
		return false;
	}
	
	// 将密码加下密
	String encryptPassword = encryptPsd(newPassword);
	int rows = this.adminMapper.updatePassword(adminId, encryptPassword);
	if (rows > 0) {
		return true;
	}
	return false;
}
 
Example 17
Source File: ExcelUtils.java    From jshERP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 从第i行开始到最后检测指定列的唯一性
 *
 * @param src
 * @param colNum
 * @param fromRow
 *            起始行
 * @return
 */
public static Boolean checkUnique(Sheet src, int colNum, int fromRow) {
	Cell[] colCells = src.getColumn(colNum);
	Set<String> set = new HashSet<String>();
	for (int i = fromRow; i < colCells.length; i++) {
		if (!StringUtils.isEmpty(colCells[i].getContents())
				&& !set.add(colCells[i].getContents())) {
			return false;
		}
	}
	return true;
}
 
Example 18
Source File: SqlUtils.java    From eladmin with Apache License 2.0 5 votes vote down vote up
private static String getKey(String jdbcUrl, String username, String password) {
	StringBuilder sb = new StringBuilder();
	if (!StringUtils.isEmpty(username)) {
		sb.append(username);
	}
	if (!StringUtils.isEmpty(password)) {
		sb.append(COLON).append(password);
	}
	sb.append(COLON).append(jdbcUrl.trim());

	return SecureUtil.md5(sb.toString());
}
 
Example 19
Source File: EventProcessor.java    From openmessaging-connect-odar with Apache License 2.0 4 votes vote down vote up
public void start() throws Exception {

        initDataSource();

        binlogPositionManager = new BinlogPositionManager(config, dataSource);
        binlogPositionManager.initBeginPosition();

        schema = new Schema(dataSource);
        String whiteDataBases = config.getWhiteDataBase();
        String whiteTables = config.getWhiteTable();

        if (!StringUtils.isEmpty(whiteDataBases)){
            Arrays.asList(whiteDataBases.trim().split(",")).forEach(whiteDataBase ->{
                Collections.addAll(schema.dataBaseWhiteList, whiteDataBase);
            });
        }

        if (!StringUtils.isEmpty(whiteTables)){
            Arrays.asList(whiteTables.trim().split(",")).forEach(whiteTable ->{
                Collections.addAll(schema.tableWhiteList, whiteTable);
            });
        }
        schema.load();

        eventListener = new EventListener(queue);
        binaryLogClient = new BinaryLogClient(config.mysqlAddr,
            config.mysqlPort,
            config.mysqlUsername,
            config.mysqlPassword);
        binaryLogClient.setBlocking(true);
        binaryLogClient.setServerId(1001);

        EventDeserializer eventDeserializer = new EventDeserializer();
        eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG,
            EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY);
        binaryLogClient.setEventDeserializer(eventDeserializer);
        binaryLogClient.registerEventListener(eventListener);
        binaryLogClient.setBinlogFilename(binlogPositionManager.getBinlogFilename());
        binaryLogClient.setBinlogPosition(binlogPositionManager.getPosition());

        binaryLogClient.connect(3000);

        LOGGER.info("Started.");

        stopped = false;

        doProcess();
    }
 
Example 20
Source File: JSONUtils.java    From yyblog with MIT License 3 votes vote down vote up
/**
 * 将json字符串转换成对象
 * 
 * @param json
 * @param clazz
 * @return
 */
public static <T> T jsonToBean(String json, Class<T> clazz) {
    if (StringUtils.isEmpty(json) || clazz == null) {
        return null;
    }
    return JSON.parseObject(json, clazz);
}