更新后端
This commit is contained in:
parent
336103e7aa
commit
61496447b3
@ -35,7 +35,8 @@ public class Applications {
|
||||
log.info("\n----------------------------------------------------------------\n\t" +
|
||||
"林风社交论坛开源版 '{}' 运行成功! 访问连接:\n\t" +
|
||||
"Swagger文档: \t\thttp://{}:{}/doc.html\n\t" +
|
||||
"数据库监控: \t\thttp://{}:{}/druid\n" +
|
||||
"数据库监控: \t\thttp://{}:{}/druid\n\t" +
|
||||
"此开源版禁止商业使用,详情查看: \thttps://net.linfeng.tech/version/version.html\n" +
|
||||
"----------------------------------------------------------------",
|
||||
env.getProperty("spring.application.name"),
|
||||
InetAddress.getLocalHost().getHostAddress(),
|
||||
|
@ -1,61 +0,0 @@
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* IP查询工具类
|
||||
* @author linfeng
|
||||
* @date 2022/2/7 19:18
|
||||
*/
|
||||
public class IPUtil {
|
||||
|
||||
|
||||
private static final String UNKNOWN = "unknown";
|
||||
// IP归属地查询
|
||||
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
|
||||
/**
|
||||
* 获取ip地址
|
||||
*/
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
String comma = ",";
|
||||
String localhost = "127.0.0.1";
|
||||
if (ip.contains(comma)) {
|
||||
ip = ip.split(",")[0];
|
||||
}
|
||||
if (localhost.equals(ip)) {
|
||||
// 获取本机真正的ip地址
|
||||
try {
|
||||
ip = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ip获取详细地址
|
||||
*/
|
||||
public static String getCityInfo(String ip) {
|
||||
String api = String.format(IP_URL,ip);
|
||||
JSONObject object = JSONUtil.parseObj(HttpUtil.get(api));
|
||||
return object.get("addr", String.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
@ -43,13 +42,6 @@ public class IPUtils {
|
||||
logger.error("IPUtils ERROR ", e);
|
||||
}
|
||||
|
||||
// //使用代理,则获取第一个IP地址
|
||||
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
|
||||
// if(ip.indexOf(",") > 0) {
|
||||
// ip = ip.substring(0, ip.indexOf(","));
|
||||
// }
|
||||
// }
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -1,53 +0,0 @@
|
||||
|
||||
package io.linfeng.common.utils;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
import io.linfeng.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
* Shiro工具类
|
||||
*
|
||||
*/
|
||||
public class ShiroUtils {
|
||||
|
||||
public static Session getSession() {
|
||||
return SecurityUtils.getSubject().getSession();
|
||||
}
|
||||
|
||||
public static Subject getSubject() {
|
||||
return SecurityUtils.getSubject();
|
||||
}
|
||||
|
||||
public static SysUserEntity getUserEntity() {
|
||||
return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
public static Long getUserId() {
|
||||
return getUserEntity().getUserId();
|
||||
}
|
||||
|
||||
public static void setSessionAttribute(Object key, Object value) {
|
||||
getSession().setAttribute(key, value);
|
||||
}
|
||||
|
||||
public static Object getSessionAttribute(Object key) {
|
||||
return getSession().getAttribute(key);
|
||||
}
|
||||
|
||||
public static boolean isLogin() {
|
||||
return SecurityUtils.getSubject().getPrincipal() != null;
|
||||
}
|
||||
|
||||
public static String getKaptcha(String key) {
|
||||
Object kaptcha = getSessionAttribute(key);
|
||||
if(kaptcha == null){
|
||||
throw new LinfengException("验证码已失效");
|
||||
}
|
||||
getSession().removeAttribute(key);
|
||||
return kaptcha.toString();
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点: https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有 ,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.dao;
|
||||
|
||||
import io.linfeng.modules.app.entity.PostFabulousEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-24 20:49:32
|
||||
*/
|
||||
@Mapper
|
||||
public interface PostFabulousDao extends BaseMapper<PostFabulousEntity> {
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点: https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得专卖或非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有 ,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.linfeng.modules.app.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserDao extends BaseMapper<UserEntity> {
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-24 20:49:32
|
||||
*/
|
||||
@Data
|
||||
@TableName("lf_post_fabulous")
|
||||
public class PostFabulousEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 帖子id
|
||||
*/
|
||||
private Integer postId;
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-23 20:33:29
|
||||
*/
|
||||
@Data
|
||||
@TableName("lf_topic_admin")
|
||||
public class TopicAdminEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
private Integer topicId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-23 20:33:29
|
||||
*/
|
||||
@Data
|
||||
@TableName("lf_topic_top")
|
||||
public class TopicTopEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 圈子id
|
||||
*/
|
||||
private Integer topicId;
|
||||
/**
|
||||
* 内容id
|
||||
*/
|
||||
private Integer postId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_user")
|
||||
public class UserEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.modules.app.entity.PostFabulousEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author linfeng
|
||||
* @email 3582996245@qq.com
|
||||
* @date 2022-01-24 20:49:32
|
||||
*/
|
||||
public interface PostFabulousService extends IService<PostFabulousEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
Boolean isThumb(Integer uid, Integer id);
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.Query;
|
||||
|
||||
import io.linfeng.modules.app.dao.PostFabulousDao;
|
||||
import io.linfeng.modules.app.entity.PostFabulousEntity;
|
||||
import io.linfeng.modules.app.service.PostFabulousService;
|
||||
|
||||
|
||||
@Service("postFabulousService")
|
||||
public class PostFabulousServiceImpl extends ServiceImpl<PostFabulousDao, PostFabulousEntity> implements PostFabulousService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PostFabulousEntity> page = this.page(
|
||||
new Query<PostFabulousEntity>().getPage(params),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isThumb(Integer uid, Integer id) {
|
||||
PostFabulousEntity entity = baseMapper.selectOne(
|
||||
new LambdaQueryWrapper<PostFabulousEntity>()
|
||||
.eq(PostFabulousEntity::getPostId, id)
|
||||
.eq(PostFabulousEntity::getUid, uid));
|
||||
return entity != null;
|
||||
}
|
||||
|
||||
}
|
@ -88,7 +88,7 @@ linfeng:
|
||||
#文件大小限制
|
||||
oss:
|
||||
# 文件大小用户端和后台管理端 单位M
|
||||
max-size: 30
|
||||
max-size: 10
|
||||
admin-max-size: 5
|
||||
|
||||
# 是否开启短信验证码
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.linfeng.modules.app.dao.PostFabulousDao">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="io.linfeng.modules.app.entity.PostFabulousEntity" id="postFabulousMap">
|
||||
<result property="id" column="id"/>
|
||||
<result property="uid" column="uid"/>
|
||||
<result property="postId" column="post_id"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.linfeng.modules.app.dao.UserDao">
|
||||
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user