代码提交--标签相关

This commit is contained in:
2020-09-27 17:35:31 +08:00
parent ba3c813106
commit fde1079d74
30 changed files with 788 additions and 290 deletions
@@ -1,4 +1,5 @@
package com.yaoyuan.jiscuss.common;
import com.yaoyuan.jiscuss.entity.custom.PostCustom;
import lombok.Data;
import org.springframework.beans.BeanUtils;
@@ -7,6 +8,7 @@ import javax.persistence.Column;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author yaoyuan2.chu
* @Title:
@@ -77,7 +79,7 @@ public class Node {
*/
public static boolean addNode(List<Node> list, Node node) {
for (Node node1 : list) { //循环添加
if (node1.getId() .equals(node.getParentId()) ) { //判断留言的上一段是都是这条留言
if (node1.getId().equals(node.getParentId())) { //判断留言的上一段是都是这条留言
node1.getNextNodes().add(node); //是,添加,返回true;
System.out.println("添加了一个");
return true;
@@ -30,22 +30,34 @@ public class PostCommonUtil {
}
String content = "";
if (mapObj.get("content") != null) {
if (mapObj.get("content") instanceof Clob) {
Clob clob = (Clob) mapObj.get("content");
content = PostCommonUtil.clobToString(clob);
} else if (mapObj.get("content") instanceof String) {
content = String.valueOf(mapObj.get("content"));
}
}
postCustom.setContent(content);
String avatar = "";
if (mapObj.get("create_avatar") != null) {
if (mapObj.get("create_avatar") instanceof Clob) {
Clob clob = (Clob) mapObj.get("create_avatar");
avatar = PostCommonUtil.clobToString(clob);
} else if (mapObj.get("create_avatar") instanceof String) {
avatar = String.valueOf(mapObj.get("create_avatar"));
}
}
postCustom.setAvatar(avatar);
postCustom.setUsername(mapObj.get("create_username") != null ? String.valueOf(mapObj.get("create_username")) : null);
postCustom.setRealname(mapObj.get("create_realname") != null ? String.valueOf(mapObj.get("create_realname")) : null);
String avatarReply = "";
if (mapObj.get("user_avatar") != null) {
if (mapObj.get("user_avatar") instanceof Clob) {
Clob clob = (Clob) mapObj.get("user_avatar");
avatarReply = PostCommonUtil.clobToString(clob);
} else if (mapObj.get("user_avatar") instanceof String) {
avatarReply = String.valueOf(mapObj.get("user_avatar"));
}
}
postCustom.setAvatarReply(avatarReply);
postCustom.setUsernameReply(mapObj.get("user_username") != null ? String.valueOf(mapObj.get("user_username")) : null);
@@ -59,29 +71,29 @@ public class PostCommonUtil {
public static List<PostCustom> getNewPostsObjCustom(List<PostCustom> postCustomList) {
List<PostCustom> mainList = new ArrayList<>();
Map<String, Object> postMap = new LinkedHashMap<>();
for(PostCustom mapObj : postCustomList){
if(null == mapObj.getParentId() ){
for (PostCustom mapObj : postCustomList) {
if (null == mapObj.getParentId()) {
mainList.add(mapObj);
}else{
} else {
List<PostCustom> tempList = new ArrayList<>();
if(postMap.containsKey(String.valueOf(mapObj.getParentId()))){
if (postMap.containsKey(String.valueOf(mapObj.getParentId()))) {
tempList = (List<PostCustom>) postMap.get(String.valueOf(mapObj.getParentId()));
tempList.add(mapObj);
postMap.put(String.valueOf(mapObj.getParentId()),tempList);
}else{
postMap.put(String.valueOf(mapObj.getParentId()), tempList);
} else {
tempList.add(mapObj);
postMap.put(String.valueOf(mapObj.getParentId()),tempList);
postMap.put(String.valueOf(mapObj.getParentId()), tempList);
}
}
}
List<PostCustom> mainListResult = new ArrayList<>();
for(PostCustom mapObj : mainList){
if(postMap.containsKey(String.valueOf(mapObj.getId()))){
for (PostCustom mapObj : mainList) {
if (postMap.containsKey(String.valueOf(mapObj.getId()))) {
PostCustom newObj = new PostCustom();
BeanUtils.copyProperties(mapObj , newObj);
BeanUtils.copyProperties(mapObj, newObj);
newObj.setChild((List<PostCustom>) postMap.get(String.valueOf(mapObj.getId())));
mainListResult.add(newObj);
}else{
} else {
mainListResult.add(mapObj);
}
}
@@ -1,4 +1,5 @@
package com.yaoyuan.jiscuss.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -15,15 +15,15 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
prePostEnabled :决定Spring Security的前注解是否可用 [@PreAuthorize,@PostAuthorize,..]
secureEnabled : 决定是否Spring Security的保障注解 [@Secured] 是否可用
jsr250Enabled :决定 JSR-250 annotations 注解[@RolesAllowed..] 是否可用.
* prePostEnabled :决定Spring Security的前注解是否可用 [@PreAuthorize,@PostAuthorize,..]
* secureEnabled : 决定是否Spring Security的保障注解 [@Secured] 是否可用
* jsr250Enabled :决定 JSR-250 annotations 注解[@RolesAllowed..] 是否可用.
*/
@Configurable
@EnableWebSecurity
//开启 Spring Security 方法级安全注解 @EnableGlobalMethodSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled = true,jsr250Enabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomAccessDeniedHandler customAccessDeniedHandler;
@@ -44,9 +44,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
"/images/**",
"/static/**",
"/h2-console/**",
"/test/**",
"/druid/**"
);
}
/**
* http请求设置
*/
@@ -56,7 +58,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
http.headers().frameOptions().disable();//解决 in a frame because it set 'X-Frame-Options' to 'DENY' 问题
//http.anonymous().disable();
http.authorizeRequests()
.antMatchers("/login/**","/initUserData")//不拦截登录相关方法
.antMatchers("/login/**", "/initUserData")//不拦截登录相关方法
.permitAll()
//.antMatchers("/user").hasRole("ADMIN") // user接口只有ADMIN角色的可以访问
// .anyRequest()
@@ -79,6 +81,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
.logoutSuccessUrl("/login?logout"); //退出登录成功URL
}
/**
* 自定义获取用户信息接口
*/
@@ -89,6 +92,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
/**
* 密码加密算法
*
* @return
*/
@Bean
@@ -20,9 +20,10 @@ public class BaseController {
/**
* 获取当前用户
*
* @return
*/
protected UserInfo getUserInfo(HttpServletRequest request){
protected UserInfo getUserInfo(HttpServletRequest request) {
UserInfo user = null;
//获得session对象
HttpSession session = request.getSession();
@@ -35,7 +36,7 @@ public class BaseController {
Object spring_security_context = session.getAttribute("SPRING_SECURITY_CONTEXT");
System.out.println(spring_security_context);
SecurityContext securityContext = (SecurityContext) spring_security_context;
if(securityContext!=null){
if (securityContext != null) {
//获得认证信息
Authentication authentication = securityContext.getAuthentication();
//获得用户详情
@@ -10,9 +10,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class TestController {
/**
* 登录页面跳转
*
* @return
*/
@GetMapping("loginpage")
@@ -23,7 +23,7 @@ public class TestController {
@RequestMapping("/world")
public String world(Map<String, Object> model) {
model.put("data","2019");
model.put("data", "2019");
// request.setAttribute("name", "xxxxxxxxx");
model.put("msg", "xxxxxxx2222xx");
return "world";
@@ -7,8 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import com.yaoyuan.jiscuss.entity.*;
import com.yaoyuan.jiscuss.entity.custom.DiscussionCustom;
import com.yaoyuan.jiscuss.entity.custom.PostCustom;
import com.yaoyuan.jiscuss.service.IPostsService;
import com.yaoyuan.jiscuss.service.IUsersService;
import com.yaoyuan.jiscuss.service.*;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,9 +23,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.yaoyuan.jiscuss.service.IDiscussionsService;
import com.yaoyuan.jiscuss.service.ITagsService;
/**
* 主题帖子评论控制器
*/
@@ -42,6 +38,9 @@ public class UserPostController extends BaseController {
@Autowired
private ITagsService tagsService;
@Autowired
private IDiscussionsTagsService iDiscussionsTagsService;
@Autowired
private IPostsService postsService;
@@ -52,25 +51,24 @@ public class UserPostController extends BaseController {
//首页查看主题列表(各种条件筛选,最热最新标签等)
//查看主题详情
@RequestMapping("/getdiscussionsbyid")
public String getDiscussionsById(HttpServletRequest request, ModelMap map, @RequestParam("id") Integer id) {
logger.info(">>> getDiscussionsById{}",id);
logger.info(">>> getDiscussionsById{}", id);
Discussion discussion = discussionsService.findOne(id);
// 获取此主题下的评论
List<Post> posts = postsService.findOneBy(id);
DiscussionCustom newdd = new DiscussionCustom();
BeanUtils.copyProperties(discussion , newdd);
if (null != newdd.getStartUserId()){
BeanUtils.copyProperties(discussion, newdd);
if (null != newdd.getStartUserId()) {
User startUser = usersService.findOne(newdd.getStartUserId());
newdd.setAvatar(startUser.getAvatar());
newdd.setRealname(startUser.getRealname());
newdd.setUsername(startUser.getUsername());
}
if (null != newdd.getLastUserId()){
if (null != newdd.getLastUserId()) {
User lastUser = usersService.findOne(newdd.getLastUserId());
newdd.setAvatarLast(lastUser.getAvatar());
newdd.setRealnameLast(lastUser.getRealname());
@@ -87,30 +85,46 @@ public class UserPostController extends BaseController {
map.put("discussions", newdd);
map.put("posts", postsObj);
UserInfo user = getUserInfo(request);
if(user != null){
if (user != null) {
map.put("username", user.getUsername());
}
return "discussions";
}
//新建主题
@PostMapping(value = "/newdiscussions")
@ResponseBody
public String newDiscussions(@RequestBody Discussion discussion) {
logger.info(">>> newPost"+ discussion);
public String newDiscussions(@RequestBody DiscussionCustom discussion) {
logger.info(">>> newPost" + discussion);
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
UserInfo user = getUserInfo(request);
if(user != null){
discussion.setLastUserId( user.getId());
discussion.setCreateId( user.getId());
if (user != null) {
discussion.setStartUserId(user.getId());
discussion.setLastUserId(user.getId());
discussion.setCreateId(user.getId());
}
discussion.setCreateTime(new Date());
discussion.setStartTime(new Date());
discussion.setLastTime(new Date());
Discussion saveDiscussion = discussionsService.insert(discussion);
if (null != discussion.getTag()) {
//执行组装标签
String[] strArray = discussion.getTag().split(",");
for(String str : strArray){
DiscussionTag dtag= new DiscussionTag();
dtag.setDiscussionId(saveDiscussion.getId());
dtag.setTagId(Integer.parseInt(str));
iDiscussionsTagsService.insert(dtag);
}
}
JSONObject resultobj = new JSONObject();
logger.info(">>>{}", saveDiscussion);
@@ -129,18 +143,18 @@ public class UserPostController extends BaseController {
@PostMapping(value = "/newpost")
@ResponseBody
public String newPosts(@RequestBody Post post) {
logger.info(">>> newpost"+ post);
logger.info(">>> newpost" + post);
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
UserInfo user = getUserInfo(request);
if(user != null){
post.setCreateId( user.getId());
if (user != null) {
post.setCreateId(user.getId());
}
post.setCreateTime(new Date());
if(null != post.getParentId()){
Post temp =postsService.findOneByid(post.getParentId());
if (null != post.getParentId()) {
Post temp = postsService.findOneByid(post.getParentId());
post.setUserId(temp.getCreateId());
}
@@ -148,7 +162,7 @@ public class UserPostController extends BaseController {
Post savePost = postsService.insert(post);
JSONObject resultobj = new JSONObject();
logger.info(">>>{}",savePost );
logger.info(">>>{}", savePost);
resultobj.put("msg", "添加成功");
resultobj.put("flag", true);
return resultobj.toString(); //
@@ -160,14 +174,14 @@ public class UserPostController extends BaseController {
@PostMapping(value = "/newtags")
@ResponseBody
public String newTags(@RequestBody Tag tag) {
logger.info(">>> newTags"+ tag);
logger.info(">>> newTags" + tag);
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
UserInfo user = getUserInfo(request);
if(user != null){
tag.setCreateId( user.getId());
if (user != null) {
tag.setCreateId(user.getId());
}
tag.setCreateTime(new Date());
@@ -42,45 +42,45 @@ public class UserSystemController extends BaseController {
private ITagsService tagsService;
//首页
@RequestMapping({"/","/main","/index"})
public String home(@RequestParam(defaultValue = "all") String tag, @RequestParam(defaultValue = "all") String type,@RequestParam(defaultValue = "1") Integer
@RequestMapping({"/", "/main", "/index"})
public String home(@RequestParam(defaultValue = "all") String tag, @RequestParam(defaultValue = "all") String type, @RequestParam(defaultValue = "1") Integer
pageNum, HttpServletRequest request, ModelMap map) {
logger.info(">>> index");
logger.info(">>> tag:" + tag);
logger.info(">>> pageNum:" + pageNum);
List<User> userall = usersService.getAllList();
logger.info(">>> 第一遍的全部用户:"+userall);
logger.info(">>> 第一遍的全部用户:" + userall);
List<User> useral2 = usersService.getAllList();
logger.info(">>> 第二遍的全部用户:"+useral2);
logger.info(">>> 第二遍的全部用户:" + useral2);
int pageSiz = 10;
int pageNumNew = pageNum - 1;
Discussion discussion = new Discussion();
//分页获取主题帖子
Page<Discussion> allDiscussionsPage = discussionsService.queryAllDiscussionsList(discussion,pageNumNew,pageSiz);
Page<Discussion> allDiscussionsPage = discussionsService.queryAllDiscussionsList(discussion, pageNumNew, pageSiz);
List<Discussion> allDiscussions = allDiscussionsPage.getContent();
List<DiscussionCustom> newAllD = new ArrayList<>();
for (Discussion dd : allDiscussions){
for (Discussion dd : allDiscussions) {
DiscussionCustom newdd = new DiscussionCustom();
BeanUtils.copyProperties(dd , newdd);
BeanUtils.copyProperties(dd, newdd);
String newCon = "";
String content = DelTagsUtil.getTextFromHtml(newdd.getContent());
if(null != content && content.length()>30){
newCon = content.substring(0,29);
}else{
if (null != content && content.length() > 30) {
newCon = content.substring(0, 29);
} else {
newCon = content;
}
newdd.setContent(newCon);
if (null != newdd.getStartUserId()){
if (null != newdd.getStartUserId()) {
User startUser = usersService.findOne(newdd.getStartUserId());
newdd.setAvatar(startUser.getAvatar());
newdd.setRealname(startUser.getRealname());
newdd.setUsername(startUser.getUsername());
}
if (null != newdd.getLastUserId()){
if (null != newdd.getLastUserId()) {
User lastUser = usersService.findOne(newdd.getLastUserId());
newdd.setAvatarLast(lastUser.getAvatar());
newdd.setRealnameLast(lastUser.getRealname());
@@ -90,7 +90,7 @@ public class UserSystemController extends BaseController {
newAllD.add(newdd);
}
logger.info("全部主题==>{}",allDiscussions);
logger.info("全部主题==>{}", allDiscussions);
Long total = allDiscussionsPage.getTotalElements();
@@ -99,7 +99,7 @@ public class UserSystemController extends BaseController {
//获取所有标签(以后尝试去缓存中取)
List<Tag> allTags = tagsService.getAllList();
logger.info("全部标签==>{}",allTags);
logger.info("全部标签==>{}", allTags);
System.out.println(userall.toString());
map.put("data", "Jiscuss 用户");
@@ -109,12 +109,12 @@ public class UserSystemController extends BaseController {
map.put("tag", tag);
map.put("type", type);
map.put("pageSize",pageSiz);
map.put("pageSize", pageSiz);
map.put("pageTotal", total);
map.put("pageNum", pageNum);
map.put("pageTotalPages", allDiscussionsPage.getTotalPages());
UserInfo user = getUserInfo(request);
if(user != null){
if (user != null) {
map.put("username", user.getUsername());
map.put("data", "Jiscuss 用户:" + user.getUsername());
}
@@ -124,17 +124,23 @@ public class UserSystemController extends BaseController {
private List<String> getPageNumList(int size) {
List<String> pageNumList = new ArrayList<String>();
for(int i = 0;i<size;i++) {
pageNumList.add(""+(i+1));
for (int i = 0; i < size; i++) {
pageNumList.add("" + (i + 1));
}
return pageNumList;
}
//登录页
@GetMapping("/test")
public String test() {
return "test";
}
//登录页
@GetMapping("/login")
public String login(@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout,ModelMap map) {
@RequestParam(value = "logout", required = false) String logout, ModelMap map) {
if (error != null) {
map.put("msg", "您输入的用户名密码错误!");
return "login";
@@ -2,10 +2,7 @@ package com.yaoyuan.jiscuss.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import lombok.Data;
@@ -19,9 +16,12 @@ public class Setting implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@Column(name="key")
private String key;
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name="value")
private String value;
@Column(name="setting_key")
private String settingKey;
@Column(name="setting_value")
private String settingValue;
}
@@ -1,8 +1,11 @@
package com.yaoyuan.jiscuss.entity.custom;
import com.yaoyuan.jiscuss.entity.Discussion;
import com.yaoyuan.jiscuss.entity.Tag;
import lombok.Data;
import java.util.List;
/**
* @author yaoyuan2.chu
* @Title:
@@ -26,4 +29,9 @@ public class DiscussionCustom extends Discussion {
private String realnameLast;
private String tag;
private List<Tag> tagList;
}
@@ -38,12 +38,12 @@ public class DiscussionsServiceImpl implements IDiscussionsService {
@Override
public Page<Discussion> queryAllDiscussionsList(Discussion discussion, int pageNum, int pageSize) {
Sort sort=new Sort(Sort.Direction.DESC,"id");
Sort sort = new Sort(Sort.Direction.DESC, "id");
@SuppressWarnings("deprecation")
Pageable pageable=new PageRequest(pageNum,pageSize,sort);
Pageable pageable = new PageRequest(pageNum, pageSize, sort);
//将匹配对象封装成Example对象
Example<Discussion> example = Example.of(discussion);
return discussionsRepository.findAll(example,pageable);
return discussionsRepository.findAll(example, pageable);
}
}
@@ -42,7 +42,7 @@ public class PostsServiceImpl implements IPostsService {
@Override
public Post findOneByid(Integer id) {
Post post =new Post();
Post post = new Post();
post.setId(id);
Example<Post> example = Example.of(post);
Optional<Post> postRes = postsRepository.findOne(example);
@@ -66,7 +66,6 @@ public class PostsServiceImpl implements IPostsService {
// List<PostCustom> thenpostCustomListNew = PostCommonUtil.getNewPostsObjCustom(thenpostCustomList);
//新建一个Node集合。
ArrayList<Node> nodes = new ArrayList<>();
//将第一层评论都添加都Node集合中
@@ -82,8 +81,6 @@ public class PostsServiceImpl implements IPostsService {
Node.show(list);
// List<Map<String, Object>> posts = postsRepository.findPostCustomById(id);
//
// List<PostCustom> postCustomList = PostCommonUtil.getNewPostsObjMap(posts);
+76
View File
@@ -0,0 +1,76 @@
#h2 配置
spring:
cache:
type: ehcache
ehcache:
config: classpath:ehcache.xml
jpa:
generate-ddl: false
show-sql: true
hibernate:
ddl-auto: none
h2:
console:
path: /h2-console
enabled: true
settings:
web-allow-others: true
datasource:
platform: h2
url: jdbc:h2:~/testjiscuss
username: sa
password:
schema: classpath:schema.sql
data: classpath:data.sql
driver-class-name: org.h2.Driver
type: com.alibaba.druid.pool.DruidDataSource
druid:
min-idle: 2
initial-size: 5
max-active: 10
max-wait: 5000
validation-query: select 1SS
# 状态监控
filter:
stat:
enabled: true
db-type: h2
log-slow-sql: true
slow-sql-millis: 2000
# 监控过滤器
web-stat-filter:
enabled: true
exclusions:
- "*.js"
- "*.gif"
- "*.jpg"
- "*.png"
- "*.css"
- "*.ico"
- "/druid/*"
# druid 监控页面
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# reset-enable: false
# login-username: root
# login-password: root
freemarker:
# 设置模板后缀名
suffix: .ftl
# 设置文档类型
content-type: text/html
# 设置页面编码格式
charset: UTF-8
# 设置页面缓存
cache: false
# 设置ftl文件路径
template-loader-path:
- classpath:/templates
settings:
classic_compatible: true
# 设置静态文件路径,js,css等
mvc:
static-path-pattern: /static/**
server:
port: 80
+69
View File
@@ -0,0 +1,69 @@
#mysql 配置
spring:
cache:
type: ehcache
ehcache:
config: classpath:ehcache.xml
jpa:
database: MYSQL
show-sql: true
hibernate:
ddl-auto: update
datasource:
url: jdbc:mysql://127.0.0.1:3306/jiscuss?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
tomcat:
init-s-q-l: SET NAMES utf8mb4
druid:
min-idle: 2
initial-size: 5
max-active: 10
max-wait: 5000
validation-query: select 1SS
# 状态监控
filter:
stat:
enabled: true
db-type: mysql
log-slow-sql: true
slow-sql-millis: 2000
# 监控过滤器
web-stat-filter:
enabled: true
exclusions:
- "*.js"
- "*.gif"
- "*.jpg"
- "*.png"
- "*.css"
- "*.ico"
- "/druid/*"
# druid 监控页面
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# reset-enable: false
# login-username: root
# login-password: root
freemarker:
# 设置模板后缀名
suffix: .ftl
# 设置文档类型
content-type: text/html
# 设置页面编码格式
charset: UTF-8
# 设置页面缓存
cache: false
# 设置ftl文件路径
template-loader-path:
- classpath:/templates
settings:
classic_compatible: true
# 设置静态文件路径,js,css等
mvc:
static-path-pattern: /static/**
server:
port: 80
+13 -19
View File
@@ -1,28 +1,22 @@
#mysql 配置
spring:
cache:
type: ehcache
ehcache:
config: classpath:ehcache.xml
jpa:
generate-ddl: false
database: MYSQL
show-sql: true
hibernate:
ddl-auto: none
h2:
console:
path: /h2-console
enabled: true
settings:
web-allow-others: true
ddl-auto: update
datasource:
platform: h2
url: jdbc:h2:~/testjiscuss
username: sa
password:
schema: classpath:schema.sql
data: classpath:data.sql
driver-class-name: org.h2.Driver
url: jdbc:mysql://127.0.0.1:3306/jiscuss?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&autoReconnect=true&useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
tomcat:
init-s-q-l: SET NAMES utf8mb4
druid:
min-idle: 2
initial-size: 5
@@ -33,7 +27,7 @@ spring:
filter:
stat:
enabled: true
db-type: h2
db-type: mysql
log-slow-sql: true
slow-sql-millis: 2000
# 监控过滤器
@@ -51,9 +45,9 @@ spring:
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# reset-enable: false
# login-username: root
# login-password: root
# reset-enable: false
# login-username: root
# login-password: root
freemarker:
# 设置模板后缀名
suffix: .ftl
+3 -2
View File
@@ -67,8 +67,9 @@ create_time datetime
-- 设置表5
drop table if exists setting;
CREATE TABLE setting(
key varchar(20) primary key,
value text
id INTEGER not null primary key auto_increment ,
setting_key varchar(20) ,
setting_value text
);
-- 标签表6
drop table if exists tag;
+11 -2
View File
@@ -63,6 +63,7 @@ $("#newdiscussions").click(function(){
console.warn(header)
console.warn(token)
var title = $("#discussionstitle").val();
var tag = $("#selectTag").val();
// $("#discussionscontent").val();
console.log(tinyMCE.editors[0].getContent());
var content =tinyMCE.editors[0].getContent();
@@ -107,7 +108,16 @@ $("#commitnewtags").click(function(){
var header = $("meta[name='_csrf_header']").attr("content");
var token =$("meta[name='_csrf']").attr("content");
var name = $("#tagsname").val();
var tagColor = $("#tagColor").val();
var tagIcon = $("#tagIcon").val();
var parentTag = $("#parentTag").val();
console.log(tagColor);
console.log(tagIcon);
console.log(parentTag);
console.log(name);
$.ajax({
type: "POST",
@@ -124,10 +134,9 @@ $("#commitnewtags").click(function(){
console.log(data);
if(data.flag){
massage(name+',添加成功!','');
return false;
$("#selectTag").html("");
}else{
massage(name+',添加失败!','');
return false;
}
}
});
@@ -0,0 +1,36 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
</profile>
</component>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/templates.iml" filepath="$PROJECT_DIR$/.idea/templates.iml" />
</modules>
</component>
</project>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
</component>
</project>
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="755544fc-90a1-4d60-9093-335fc4c5e923" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../../java/com/yaoyuan/jiscuss/config/WebSecurityConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../java/com/yaoyuan/jiscuss/config/WebSecurityConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../java/com/yaoyuan/jiscuss/controller/UserSystemController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../java/com/yaoyuan/jiscuss/controller/UserSystemController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/comm/footer.ftl" beforeDir="false" afterPath="$PROJECT_DIR$/comm/footer.ftl" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.ftl" beforeDir="false" afterPath="$PROJECT_DIR$/index.ftl" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../../.." />
</component>
<component name="ProjectId" id="1hzVfIl0oebNSYJlVoYCSm1cyrz" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../../../../../other_project/h2&amp;mysql/spb-jpa-mysql-master" />
</component>
<component name="SvnConfiguration">
<configuration>C:\Users\A11200321050045\AppData\Roaming\Subversion</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="755544fc-90a1-4d60-9093-335fc4c5e923" name="Default Changelist" comment="" />
<created>1601014009683</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1601014009683</updated>
<workItem from="1601014011056" duration="15000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="2" />
</component>
<component name="WindowStateProjectService">
<state x="740" y="274" key="FileChooserDialogImpl" timestamp="1601014023451">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="740" y="274" key="FileChooserDialogImpl/1920.137.1366.728/0.0.1920.1040@0.0.1920.1040" timestamp="1601014023451" />
</component>
</project>
+2 -1
View File
@@ -1,7 +1,8 @@
<div class="ui section divider"></div>
<#--<div class="ui section divider"></div>-->
<div class="ui vertical footer segment">
<div class="ui center aligned container">
<div class="ui section divider"></div>
<div class="ui stackable divided grid">
<div class="three wide column">
<h4 class="ui header">关于遥远</h4>
+10 -1
View File
@@ -50,6 +50,15 @@
${discussions.content}
</div>
<div class="ui labeled button" tabindex="0">
<div class="ui red button">
<i class="heart icon"></i> 赞这个主题
</div>
<a class="ui basic red left pointing label">
1,048
</a>
</div>
<div class="ui feed">
<div class="event">
@@ -71,7 +80,7 @@
</div>
<div class="meta">
<a class="like">
<i class="like icon"></i> 0 喜欢
<i class="like icon"></i> 0 喜欢作者
</a>
</div>
</div>
+140 -76
View File
@@ -56,12 +56,10 @@
</div>
<div class="field">
<label>选择标签</label>
<select multiple="" class="ui dropdown">
<select multiple="" class="ui dropdown" id="selectTag">
<option value="">选择标签</option>
<#list allTags as tags>
<option value=${tags.id}>${tags.name}</option>
</#list>
</select>
</div>
@@ -74,15 +72,65 @@
<label>标签名</label>
<input type="text" placeholder="标签名" id="tagsname">
</div>
<div class="field" id="createNewtagsDiv" style="display:none">
<label>父标签</label>
<select class="ui fluid dropdown" id="parentTag">
<#list allTags as tag>
<option value="{tag.id}">{tag.name}</option>
</#list>
</select>
</div>
<div class="two fields">
<div class="field">
<label>选择颜色</label>
<div class="ui fluid search selection dropdown">
<input type="hidden" id="tagColor">
<i class="dropdown icon"></i>
<div class="default text">选择颜色</div>
<div class="menu">
<div class="item" data-value="red"><div class="ui red empty circular label"></div>红色</div>
<div class="item" data-value="orange"><div class="ui orange empty circular label"></div>橙色</div>
<div class="item" data-value="yellow"><div class="ui yellow empty circular label"></div>黄色</div>
<div class="item" data-value="olive"><div class="ui olive empty circular label"></div>橄榄绿</div>
<div class="item" data-value="green"><div class="ui green empty circular label"></div>纯绿</div>
<div class="item" data-value="teal"><div class="ui teal empty circular label"></div>水鸭蓝</div>
<div class="item" data-value="blue"><div class="ui blue empty circular label"></div>纯蓝</div>
<div class="item" data-value="violet"><div class="ui violet empty circular label"></div>紫罗兰</div>
<div class="item" data-value="purple"><div class="ui purple empty circular label"></div>纯紫</div>
<div class="item" data-value="pink"><div class="ui pink empty circular label"></div>粉红</div>
<div class="item" data-value="brown"><div class="ui brown empty circular label"></div>棕色</div>
<div class="item" data-value="grey"><div class="ui grey empty circular label"></div>灰色</div>
<div class="item" data-value="black"><div class="ui black empty circular label"></div>黑色</div>
</div>
</div>
</div>
<div class="field">
<label>选择图标</label>
<div class="ui fluid search selection dropdown">
<input type="hidden" id="tagIcon">
<i class="dropdown icon"></i>
<div class="default text">选择图标</div>
<div class="menu">
<div class="item" data-value="bullhorn"><i class="bullhorn"></i>bullhorn</div>
<div class="item" data-value="coffee"><i class="coffee"></i>coffee</div>
<div class="item" data-value="edit"><i class="edit"></i>edit</div>
<div class="item" data-value="fax"><i class="fax"></i>fax</div>
<div class="item" data-value="bug"><i class="bug"></i>bug</div>
<div class="item" data-value="keyboard"><i class="keyboard"></i>keyboard</div>
<div class="item" data-value="folder open outline"><i class="folder open outline"></i>folder open outline</div>
<div class="item" data-value="comment outline"><i class="comment outline"></i>comment outline</div>
</div>
</div>
</div>
</div>
<div class="field" id="createNewtagsBtn" style="display:none">
<button class="ui teal button" id="commitnewtags">保存</button>
<button class="ui grey button" id="cancelnewtags">取消</button>
</div>
<div class="field">
<label>内容</label>
<textarea id="discussionscontent"></textarea>
</div>
<div class="ui fluid large blue button" id="newdiscussions">提交内容</div>
@@ -90,72 +138,90 @@
</div>
</div>
<div class="ui list">
<div class="item">下面这个按钮可以过滤帖子呦</div>
</div>
<div class="fluid ui floating dropdown labeled icon orange button">
<i class="filter icon"></i> <span class="text">过滤帖子标签</span>
<div class="menu">
<div class="ui icon search input">
<i class="search icon"></i> <input type="text"
placeholder="搜索标签...">
</div>
<div class="divider"></div>
<div class="header">
<i class="tags icon"></i> 标签
</div>
<div class="scrolling menu">
<div class="item">
<div class="ui red empty circular label"></div>
重要
</div>
<div class="item">
<div class="ui blue empty circular label"></div>
通知
</div>
<div class="item">
<div class="ui black empty circular label"></div>
无法修复
</div>
<div class="item">
<div class="ui purple empty circular label"></div>
新闻
</div>
<div class="item">
<div class="ui orange empty circular label"></div>
交换
</div>
<div class="item">
<div class="ui empty circular label"></div>
改变下降
</div>
<div class="item">
<div class="ui yellow empty circular label"></div>
题外话
</div>
<div class="item">
<div class="ui pink empty circular label"></div>
有趣
</div>
<div class="item">
<div class="ui green empty circular label"></div>
讨论
</div>
</div>
</div>
</div>
<div class="ui section divider"></div>
<div class="ui fluid action input">
<input type="text" placeholder="搜索...">
<div class="ui button">搜索</div>
<div class="ui card red ">
<div class="content">
<div class="header">全部标签</div>
</div>
<div class="content">
<div class="ui ordered list">
<div class="item">
<i class="folder icon"></i>
<div class="content">
<div class="header">src</div>
<div class="description">Source files for project</div>
<div class="list">
<div class="item">
<i class="folder icon"></i>
<div class="content">
<div class="header">site</div>
<div class="description">Your site's theme</div>
</div>
</div>
<div class="item">
<i class="blue folder icon"></i>
<div class="content">
<div class="header">themes</div>
<div class="description">Packaged theme files</div>
<div class="list">
<div class="item">
<i class="folder icon"></i>
<div class="content">
<div class="header">default</div>
<div class="description">Default packaged theme</div>
</div>
</div>
<div class="item">
<i class="folder icon"></i>
<div class="content">
<div class="header">my_theme</div>
<div class="description">Packaged themes are also available in
this folder
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<i class="file icon"></i>
<div class="content">
<a class="header">theme.config</a>
<div class="description">Config file for setting packaged themes</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<i class="red folder icon"></i>
<div class="content">
<a class="header">dist</a>
<div class="description">Compiled CSS and JS files</div>
<div class="list">
<div class="item">
<i class="folder icon"></i>
<div class="content">
<a class="header">components</a>
<div class="description">Individual component CSS and JS</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<i class="file icon red"></i>
<div class="content">
<div class="header">semantic.json</div>
<div class="description">Contains build settings for gulp</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui card">
<div class="ui card black ">
<div class="content">
<div class="header">预留功能</div>
</div>
@@ -185,7 +251,7 @@
</div>
<div class="ui card">
<div class="ui card violet ">
<div class="content">
<img class="right floated mini ui image"
src="static/assets/images/logo.png">
@@ -430,14 +496,12 @@
</div>
</div>
<div class="ui button" data-tooltip="预留" data-position="top center">
<div class="ui button" data-tooltip="预留" data-position="top center">
预留
</div>
</div>
<#include "comm/footer.ftl"/>
<script type="text/javascript">
@@ -449,12 +513,12 @@
console.log('pageNum' + '${pageNum}');
console.log('pageNumAll' + '${pageNumAll}');
setpageNum('${pageNum}','${pageNumAll}');
setpageNum('${pageNum}', '${pageNumAll}');
var token = $("meta[name='_csrf']").attr("content");
if(token == '' && username && username != null){
if (token == '' && username && username != null) {
console.log('因为默认页没有_csrf_token,跳页');
location.href="/main";
location.href = "/main";
}
});
+108
View File
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html>
<title>Jiscuss Demo</title>
<head>
<!-- <link rel="stylesheet" type="text/css" href="static/semanticui/semantic.css"> -->
<!-- <script src="static/jquery/jquery-3.4.1.min.js"></script> -->
<!-- <script src="static/semanticui/semantic.min.js"></script> -->
<!-- default header name is X-CSRF-TOKEN -->
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<#include "comm/commjs.ftl"/>
</head>
<body>
<div class="ui fixed inverted menu">
<div class="ui container">
<a href="fixed.php#" class="header item">
<img class="logo" src="assets/images/logo.png">
项目名
</a>
<a href="fixed.php#" class="item">主页</a>
<div class="ui simple dropdown item">
Dropdown <i class="dropdown icon"></i>
<div class="menu">
<a class="item" href="fixed.php#">链接选项</a>
<a class="item" href="fixed.php#">链接选项</a>
<div class="divider"></div>
<div class="header">标题项</div>
<div class="item">
<i class="dropdown icon"></i>
子菜单
<div class="menu">
<a class="item" href="fixed.php#">链接选项</a>
<a class="item" href="fixed.php#">链接选项</a>
</div>
</div>
<a class="item" href="fixed.php#">链接选项</a>
</div>
</div>
</div>
</div>
<div class="ui main text container">
<h1 class="ui header">Semantic UI Fixed Template</h1>
<p>This is a basic fixed menu template using fixed size containers.</p>
<p>A text container is used for the main container, which is useful for single column layouts</p>
<img class="wireframe" src="assets/images/wireframe/media-paragraph.png">
<img class="wireframe" src="assets/images/wireframe/paragraph.png">
<img class="wireframe" src="assets/images/wireframe/paragraph.png">
<img class="wireframe" src="assets/images/wireframe/paragraph.png">
<img class="wireframe" src="assets/images/wireframe/paragraph.png">
<img class="wireframe" src="assets/images/wireframe/paragraph.png">
<img class="wireframe" src="assets/images/wireframe/paragraph.png">
</div>
<div class="ui inverted vertical footer segment">
<div class="ui center aligned container">
<div class="ui stackable inverted divided grid">
<div class="three wide column">
<h4 class="ui inverted header">Group 1</h4>
<div class="ui inverted link list">
<a href="fixed.php#" class="item">Link One</a>
<a href="fixed.php#" class="item">Link Two</a>
<a href="fixed.php#" class="item">Link Three</a>
<a href="fixed.php#" class="item">Link Four</a>
</div>
</div>
<div class="three wide column">
<h4 class="ui inverted header">Group 2</h4>
<div class="ui inverted link list">
<a href="fixed.php#" class="item">Link One</a>
<a href="fixed.php#" class="item">Link Two</a>
<a href="fixed.php#" class="item">Link Three</a>
<a href="fixed.php#" class="item">Link Four</a>
</div>
</div>
<div class="three wide column">
<h4 class="ui inverted header">Group 3</h4>
<div class="ui inverted link list">
<a href="fixed.php#" class="item">Link One</a>
<a href="fixed.php#" class="item">Link Two</a>
<a href="fixed.php#" class="item">Link Three</a>
<a href="fixed.php#" class="item">Link Four</a>
</div>
</div>
<div class="seven wide column">
<h4 class="ui inverted header">Footer Header</h4>
<p>Extra space for a call to action inside the footer that could help re-engage users.</p>
</div>
</div>
<div class="ui inverted section divider"></div>
<img src="assets/images/logo.png" class="ui centered mini image">
<div class="ui horizontal inverted small divided link list">
<a class="item" href="fixed.php#">Site Map</a>
<a class="item" href="fixed.php#">Contact Us</a>
<a class="item" href="fixed.php#">Terms and Conditions</a>
<a class="item" href="fixed.php#">Privacy Policy</a>
</div>
</div>
</div>
</body>
</html>