use of com.zyd.blog.business.entity.User in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method doPraise.
/**
* 文章点赞
*
* @param id
*/
@Override
@RedisCache(flush = true)
public void doPraise(Long id) {
String ip = IpUtil.getRealIp(RequestHolder.getRequest());
String key = ip + "_doPraise_" + id;
ValueOperations<String, Object> operations = redisTemplate.opsForValue();
if (redisTemplate.hasKey(key)) {
throw new ZhydArticleException("一个小时只能点赞一次哈,感谢支持~~");
}
User user = SessionUtil.getUser();
BizArticleLove love = new BizArticleLove();
if (null != user) {
love.setUserId(user.getId());
}
love.setArticleId(id);
love.setUserIp(IpUtil.getRealIp(RequestHolder.getRequest()));
love.setLoveTime(new Date());
love.setCreateTime(new Date());
love.setUpdateTime(new Date());
bizArticleLoveMapper.insert(love);
operations.set(key, id, 1, TimeUnit.HOURS);
}
use of com.zyd.blog.business.entity.User in project OneBlog by zhangyd-c.
the class BizCommentServiceImpl method commentForAdmin.
/**
* admin发表评论
*
* @param comment
* @return
*/
@Override
@RedisCache(flush = true)
public void commentForAdmin(Comment comment) throws ZhydCommentException {
Map config = configService.getConfigs();
User user = SessionUtil.getUser();
comment.setQq(user.getQq());
comment.setEmail(user.getEmail());
comment.setNickname(user.getNickname());
comment.setAvatar(user.getAvatar());
comment.setUrl((String) config.get(ConfigKeyEnum.SITE_URL.getKey()));
comment.setUserId(user.getId());
comment.setStatus(CommentStatusEnum.APPROVED.toString());
comment.setPid(comment.getId());
comment.setId(null);
this.comment(comment);
}
use of com.zyd.blog.business.entity.User in project OneBlog by zhangyd-c.
the class BizCommentServiceImpl method setCurrentLoginUserInfo.
/**
* 保存当前登录用户的信息
*
* @param comment
*/
private void setCurrentLoginUserInfo(Comment comment) {
User loginUser = SessionUtil.getUser();
comment.setNickname(HtmlUtil.html2Text(loginUser.getNickname()));
comment.setQq(HtmlUtil.html2Text(loginUser.getQq()));
comment.setAvatar(HtmlUtil.html2Text(loginUser.getAvatar()));
comment.setEmail(HtmlUtil.html2Text(loginUser.getEmail()));
comment.setUrl(HtmlUtil.html2Text(loginUser.getBlog()));
comment.setUserId(loginUser.getId());
}
use of com.zyd.blog.business.entity.User in project OneBlog by zhangyd-c.
the class SysLogServiceImpl method asyncSaveSystemLog.
@Async
@Override
public void asyncSaveSystemLog(PlatformEnum platform, String bussinessName) {
String ua = RequestUtil.getUa();
Log sysLog = new Log();
sysLog.setLogLevel(LogLevelEnum.INFO);
sysLog.setType(platform.equals(PlatformEnum.WEB) ? LogTypeEnum.VISIT : LogTypeEnum.SYSTEM);
sysLog.setIp(RequestUtil.getIp());
sysLog.setReferer(RequestUtil.getReferer());
sysLog.setRequestUrl(RequestUtil.getRequestUrl());
sysLog.setUa(ua);
sysLog.setSpiderType(WebSpiderUtils.parseUa(ua));
sysLog.setParams(JSONObject.toJSONString(RequestUtil.getParametersMap()));
User user = SessionUtil.getUser();
if (user != null) {
sysLog.setUserId(user.getId());
sysLog.setContent(String.format("用户: [%s] | 操作: %s", user.getUsername(), bussinessName));
} else {
sysLog.setContent(String.format("访客: [%s] | 操作: %s", sysLog.getIp(), bussinessName));
}
try {
UserAgent agent = UserAgent.parseUserAgentString(ua);
sysLog.setBrowser(agent.getBrowser().getName());
sysLog.setOs(agent.getOperatingSystem().getName());
this.insert(sysLog);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.zyd.blog.business.entity.User in project OneBlog by zhangyd-c.
the class SysUserServiceImpl method listByRoleId.
/**
* 通过角色Id获取用户列表
*
* @param roleId
* @return
*/
@Override
public List<User> listByRoleId(Long roleId) {
List<SysUser> sysUsers = sysUserMapper.listByRoleId(roleId);
if (CollectionUtils.isEmpty(sysUsers)) {
return null;
}
List<User> users = new ArrayList<>();
for (SysUser su : sysUsers) {
su.setUserType(new User(su).getUserTypeDescEnum().toString());
users.add(new User(su));
}
return users;
}
Aggregations