diff --git a/README.md b/README.md index c02ffa7..9098c34 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,11 @@ -# 预览 -[](https://imgchr.com/i/sykhy4) +# 预览(预留) # 简介 -基于JAVA,使用SpringBoot + H2 Database + Semantic-UI + Freemarker 构建,官网:[[www.jiscuss.com]](http://www.jiscuss.com/) +基于JAVA 构建,官网:[[www.jiscuss.com]](http://www.jiscuss.com/) # 在线体验 @@ -44,7 +43,7 @@ ``` -## [三]、运行启动(默认使用H2数据库,可以在配置文件切换MYSQL) +## [三]、运行启动(默认使用MYSQL数据库) ``` // 1、代码导入IDE diff --git a/pom.xml b/pom.xml index 53573ee..b206464 100644 --- a/pom.xml +++ b/pom.xml @@ -1,118 +1,35 @@ - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.8.RELEASE - - - com.yaoyuan - jiscuss - - 0.0.1-SNAPSHOT - jiccuss - jiccuss project for Spring Boot + + 4.0.0 - - 1.8 - + com.yaoyuan + jiscuss + 2.0 + jar - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-freemarker - - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-websocket - - - - com.h2database - h2 - runtime - + + org.noear + solon-parent + 2.4.1 + + - - - mysql - mysql-connector-java - 5.1.30 - - - - - org.json - json - 20180813 - - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - - - org.projectlombok - lombok - compile - - - - - com.alibaba - druid-spring-boot-starter - 1.1.18 - - - - - org.springframework.boot - spring-boot-starter-cache + + + org.noear + solon-api - net.sf.ehcache - ehcache + org.noear + solon.auth - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - - - + + org.noear + solon.view.beetl + + + \ No newline at end of file diff --git a/src/main/java/com/jiscuss/Config.java b/src/main/java/com/jiscuss/Config.java new file mode 100644 index 0000000..d899057 --- /dev/null +++ b/src/main/java/com/jiscuss/Config.java @@ -0,0 +1,18 @@ +package com.jiscuss; + +import com.jiscuss.dso.AuthProcessorImpl; +import org.noear.solon.annotation.Bean; +import org.noear.solon.annotation.Configuration; +import org.noear.solon.auth.AuthUtil; + +/** + * @author cyy 2023/7/12 created + */ +@Configuration +public class Config { + @Bean + public void authAdapter(){ + AuthUtil.adapter() + .processor(new AuthProcessorImpl()); + } +} diff --git a/src/main/java/com/jiscuss/JiscussApp.java b/src/main/java/com/jiscuss/JiscussApp.java new file mode 100644 index 0000000..91fde1c --- /dev/null +++ b/src/main/java/com/jiscuss/JiscussApp.java @@ -0,0 +1,13 @@ +package com.jiscuss; + +import org.noear.solon.Solon; + +/** + * @author cyy 2023/7/12 created + */ +public class JiscussApp { + public static void main(String[] args) { + Solon.start(JiscussApp.class, args) + .onError(e -> e.printStackTrace()); + } +} diff --git a/src/main/java/com/jiscuss/controller/DemoController.java b/src/main/java/com/jiscuss/controller/DemoController.java new file mode 100644 index 0000000..fb5815a --- /dev/null +++ b/src/main/java/com/jiscuss/controller/DemoController.java @@ -0,0 +1,20 @@ +package com.jiscuss.controller; + +import org.noear.solon.annotation.Controller; +import org.noear.solon.annotation.Mapping; +import org.noear.solon.core.handle.ModelAndView; + +/** + * @author cyy 2023/7/12 created + */ +@Controller +public class DemoController { + @Mapping("/") + public Object test(){ + ModelAndView model = new ModelAndView("index.htm"); + model.put("title","jiscuss"); + model.put("message","你好 jiscuss!"); + + return model; + } +} diff --git a/src/main/java/com/jiscuss/dso/AuthProcessorImpl.java b/src/main/java/com/jiscuss/dso/AuthProcessorImpl.java new file mode 100644 index 0000000..a1114d8 --- /dev/null +++ b/src/main/java/com/jiscuss/dso/AuthProcessorImpl.java @@ -0,0 +1,36 @@ +package com.jiscuss.dso; + +import org.noear.solon.auth.AuthProcessorBase; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author cyy 2023/7/12 created + */ +public class AuthProcessorImpl extends AuthProcessorBase { + @Override + public boolean verifyLogined() { + return true; + } + + @Override + protected List getPermissions() { + List list = new ArrayList<>(); + + list.add("user:add"); + list.add("user:demo"); + + return list; + } + + @Override + protected List getRoles() { + List list = new ArrayList<>(); + + list.add("admin1"); + list.add("admin2"); + + return list; + } +} diff --git a/src/main/java/com/yaoyuan/jiscuss/JiccussApplication.java b/src/main/java/com/yaoyuan/jiscuss/JiccussApplication.java deleted file mode 100644 index c5dbb41..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/JiccussApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.yaoyuan.jiscuss; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cache.annotation.EnableCaching; - -@SpringBootApplication -@EnableCaching -public class JiccussApplication { - - public static void main(String[] args) { - SpringApplication.run(JiccussApplication.class, args); - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/common/Node.java b/src/main/java/com/yaoyuan/jiscuss/common/Node.java deleted file mode 100644 index 6c85f10..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/common/Node.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.yaoyuan.jiscuss.common; - -import com.yaoyuan.jiscuss.entity.custom.PostCustom; -import lombok.Data; -import org.springframework.beans.BeanUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.common - * @Description: - * @date 2020/8/17 14:51 - */ -@Data -public class Node { - - /** - * Node - * 空方法 - **/ - public Node() { - } - - private Integer id; - - private Integer discussionId; - - private Integer number; - - private Date time; - - private Integer userId; - - private String type; - - private String content; - - private Integer parentId; - - private Date editTime; - - private Integer editUserId; - - private String ipAddress; - - private String copyright; - - private Integer isApproved; - - private Integer createId; - - private Date createTime; - - /** - * avatar - * 用户表相关 - **/ - private String avatar; - - private String username; - - private String realname; - - private String avatarReply; - - private String usernameReply; - - private String realnameReply; - - //下一条回复 - private List nextNodes = new ArrayList(); - - - /** - * 将单个node添加到链表中 - * - * @param list - * @param node - * @return - */ - public static boolean addNode(List list, Node node) { - for (Node node1 : list) { //循环添加 - if (node1.getId().equals(node.getParentId())) { //判断留言的上一段是都是这条留言 - node1.getNextNodes().add(node); //是,添加,返回true; - System.out.println("添加了一个"); - return true; - } else { //否则递归继续判断 - if (node1.getNextNodes().size() != 0) { - if (Node.addNode(node1.getNextNodes(), node)) { - return true; - } - } - } - } - return false; - } - - /** - * 将查出来的lastId不为null的回复都添加到第一层Node集合中 - * - * @param firstList - * @param thenList - * @return - */ - public static List addAllNode(List firstList, List thenList) { - while (thenList.size() != 0) { - int size = thenList.size(); - for (int i = 0; i < size; i++) { - Node node = new Node(); - BeanUtils.copyProperties(thenList.get(i), node); - if (Node.addNode(firstList, node)) { - thenList.remove(i); - i--; - size--; - } - } - } - return firstList; - } - - /** - * 打印 - * show - **/ - public static void show(List list) { - for (Node node : list) { - System.out.println(node.getUserId() + " 用户回复了你:" + node.getContent()); - if (node.getNextNodes().size() != 0) { - Node.show(node.getNextNodes()); - } - } - } - - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/common/PostCommonUtil.java b/src/main/java/com/yaoyuan/jiscuss/common/PostCommonUtil.java deleted file mode 100644 index 17436d9..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/common/PostCommonUtil.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.yaoyuan.jiscuss.common; - -import com.yaoyuan.jiscuss.entity.custom.PostCustom; -import org.springframework.beans.BeanUtils; - -import java.io.BufferedReader; -import java.io.Reader; -import java.sql.Clob; -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @author yaoyuan2.chu - * @Title: 工具类 - * @Package com.yaoyuan.jiscuss.common - * @Description: 通用工具类 - * @date 2020/9/10 15:47 - */ -public class PostCommonUtil { - - public static List getNewPostsObjMap(List> posts) { - List postCustomList = new ArrayList<>(); - for (Map mapObj : posts) { - PostCustom postCustom = new PostCustom(); - postCustom.setId(Integer.parseInt(String.valueOf(mapObj.get("id")))); - postCustom.setParentId(mapObj.get("parent_id") != null ? Integer.parseInt(String.valueOf(mapObj.get("parent_id"))) : null); - if (null != mapObj.get("create_time")) { - postCustom.setCreateTime((Date) mapObj.get("create_time")); - } - 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); - postCustom.setRealnameReply(mapObj.get("user_realname") != null ? String.valueOf(mapObj.get("user_realname")) : null); - - postCustomList.add(postCustom); - } - return postCustomList; - } - - /** - * 获取post - * @param postCustomList - * @return List - */ - public static List getNewPostsObjCustom(List postCustomList) { - List mainList = new ArrayList<>(); - Map postMap = new LinkedHashMap<>(); - for (PostCustom mapObj : postCustomList) { - if (null == mapObj.getParentId()) { - mainList.add(mapObj); - } else { - List tempList = new ArrayList<>(); - if (postMap.containsKey(String.valueOf(mapObj.getParentId()))) { - tempList = (List) postMap.get(String.valueOf(mapObj.getParentId())); - tempList.add(mapObj); - postMap.put(String.valueOf(mapObj.getParentId()), tempList); - } else { - tempList.add(mapObj); - postMap.put(String.valueOf(mapObj.getParentId()), tempList); - } - } - } - List mainListResult = new ArrayList<>(); - for (PostCustom mapObj : mainList) { - if (postMap.containsKey(String.valueOf(mapObj.getId()))) { - PostCustom newObj = new PostCustom(); - BeanUtils.copyProperties(mapObj, newObj); - newObj.setChild((List) postMap.get(String.valueOf(mapObj.getId()))); - mainListResult.add(newObj); - } else { - mainListResult.add(mapObj); - } - } - return mainListResult; - } - - /** - * Clob类型转换成String类型 - * @param clob - * @return - */ - public static String clobToString(final Clob clob) { - if (clob == null) { - return null; - } - Reader is = null; - try { - is = clob.getCharacterStream(); - } catch (Exception e) { - e.printStackTrace(); - } - BufferedReader br = new BufferedReader(is); - String str = null; - try { - str = br.readLine(); // 读取第一行 - } catch (Exception e) { - e.printStackTrace(); - } - StringBuffer sb = new StringBuffer(); - while (str != null) { // 如果没有到达流的末尾,则继续读取下一行 - sb.append(str); - try { - str = br.readLine(); - } catch (Exception e) { - e.printStackTrace(); - } - } - String returnString = sb.toString(); - return returnString; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/config/MyMvcConfig.java b/src/main/java/com/yaoyuan/jiscuss/config/MyMvcConfig.java deleted file mode 100644 index 229f94f..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/config/MyMvcConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -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; - -@Configuration -public class MyMvcConfig implements WebMvcConfigurer { - - /* - * addResourceHandlers - * void - */ - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - - registry.addResourceHandler("swagger-ui.html") - .addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**") - .addResourceLocations("classpath:/META-INF/resources/webjars/"); - registry.addResourceHandler("/static/**") - .addResourceLocations("classpath:/static/"); - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/config/SwaggerConfiguration.java b/src/main/java/com/yaoyuan/jiscuss/config/SwaggerConfiguration.java deleted file mode 100644 index b22e95a..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/config/SwaggerConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.yaoyuan.jiscuss.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfiguration { - - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() - .apis(RequestHandlerSelectors.basePackage("com.yaoyuan.jiscuss.controller")).paths(PathSelectors.any()) - .build(); - } - - @SuppressWarnings("deprecation") - private ApiInfo apiInfo() { - return new ApiInfoBuilder().title("swagger-ui RESTful APIs").description("Jiscuss") - .termsOfServiceUrl("http://localhost/").contact("developer@mail.com").version("1.0").build(); - } - - -} \ No newline at end of file diff --git a/src/main/java/com/yaoyuan/jiscuss/config/WebSecurityConfig.java b/src/main/java/com/yaoyuan/jiscuss/config/WebSecurityConfig.java deleted file mode 100644 index 38a6888..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/config/WebSecurityConfig.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.yaoyuan.jiscuss.config; - -import com.yaoyuan.jiscuss.handler.CustomAccessDeniedHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Configurable; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -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..] 是否可用. - * 开启 Spring Security 方法级安全注解 @EnableGlobalMethodSecurity - */ -@Configurable -@EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Autowired - private CustomAccessDeniedHandler customAccessDeniedHandler; - - @Qualifier("userDetailServiceImpl") - @Autowired - private UserDetailsService userDetailsService; - - /** - * 静态资源设置 - */ - @Override - public void configure(WebSecurity webSecurity) { - //不拦截静态资源,所有用户均可访问的资源 - webSecurity.ignoring().antMatchers( - "/", - "/css/**", - "/js/**", - "/images/**", - "/static/**", - "/h2-console/**", - "/test/**", - "/druid/**" - ); - } - - /** - * http请求设置 - */ - @Override - public void configure(HttpSecurity http) throws Exception { - //http.csrf().disable(); //注释就是使用 csrf 功能 - http.headers().frameOptions().disable();//解决 in a frame because it set 'X-Frame-Options' to 'DENY' 问题 - //http.anonymous().disable(); - http.authorizeRequests() - .antMatchers("/login/**", "/initUserData")//不拦截登录相关方法 - .permitAll() - //.antMatchers("/user").hasRole("ADMIN") // user接口只有ADMIN角色的可以访问 - //.anyRequest() - //.authenticated()// 任何尚未匹配的URL只需要验证用户即可访问 - .anyRequest() - .access("@rbacPermission.hasPermission(request, authentication)")//根据账号权限访问 - .and() - .formLogin() - //.loginPage("/") - .loginPage("/login") //登录请求页 - .loginProcessingUrl("/login") //登录POST请求路径 - .usernameParameter("username") //登录用户名参数 - .passwordParameter("password") //登录密码参数 - .defaultSuccessUrl("/index") //默认登录成功页面 - .and() - .exceptionHandling() - .accessDeniedHandler(customAccessDeniedHandler) //无权限处理器 - .and() - .logout() - .logoutSuccessUrl("/login?logout"); //退出登录成功URL - - } - - /** - * 自定义获取用户信息接口 - */ - @Override - public void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder()); - } - - /** - * 密码加密算法 - * @return - */ - @Bean - public BCryptPasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/AdminSystemController.java b/src/main/java/com/yaoyuan/jiscuss/controller/AdminSystemController.java deleted file mode 100644 index 4182e86..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/AdminSystemController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import com.yaoyuan.jiscuss.entity.UserInfo; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author yaoyuan2.chu - * 后台系统控制器 - */ -@Controller -public class AdminSystemController { - - /** - * 后台登录 - */ - - /** - * 后台退出 - */ - @RequestMapping("/admin/logout") - public String logout(@RequestParam(defaultValue = "discussion") String type, HttpServletRequest request, ModelMap map) { - return "admin/logout"; - } - - /** - * 后台设置管理 - */ - - /** - * 后台页面 - * @return - */ - @RequestMapping("/admin/home") - public String home(@RequestParam(defaultValue = "discussion") String type, HttpServletRequest request, ModelMap map) { - return "admin/home"; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/BaseController.java b/src/main/java/com/yaoyuan/jiscuss/controller/BaseController.java deleted file mode 100644 index c77e29d..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/BaseController.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import com.yaoyuan.jiscuss.entity.UserInfo; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.util.Enumeration; - -/** - * @author yaoyuan2.chu - * @Title: BaseController - * @Package com.yaoyuan.jiscuss.controller - * @Description: BaseController - * @date 2020/7/16 14:36 - */ -public class BaseController { - - /** - * 获取当前用户 - * - * @return - */ - protected UserInfo getUserInfo(HttpServletRequest request) { - UserInfo user = null; - //获得session对象 - HttpSession session = request.getSession(); - //取出session域中所有属性名 - Enumeration attributeNames = session.getAttributeNames(); - while (attributeNames.hasMoreElements()) { - System.out.println(attributeNames.nextElement()); - } - //SPRING_SECURITY_CONTEXT - Object spring_security_context = session.getAttribute("SPRING_SECURITY_CONTEXT"); - System.out.println(spring_security_context); - SecurityContext securityContext = (SecurityContext) spring_security_context; - if (securityContext != null) { - //获得认证信息 - Authentication authentication = securityContext.getAuthentication(); - //获得用户详情 - Object principal = authentication.getPrincipal(); - user = (UserInfo) principal; - } - return user; - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/UserMsgController.java b/src/main/java/com/yaoyuan/jiscuss/controller/UserMsgController.java deleted file mode 100644 index 7aff4bc..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/UserMsgController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import org.springframework.stereotype.Controller; - -/** - * @author yaoyuan2.chu - * 用户消息控制器 - */ -@Controller -public class UserMsgController extends BaseController { - - /** - * 首页最新消息 - */ -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/UserOtherController.java b/src/main/java/com/yaoyuan/jiscuss/controller/UserOtherController.java deleted file mode 100644 index 926ab69..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/UserOtherController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import org.springframework.stereotype.Controller; - -/** - * @author yaoyuan2.chu - * 其他控制器——积分/权限等 - */ -@Controller -public class UserOtherController extends BaseController { - - /** - * 用户积分获取 - */ -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/UserPageController.java b/src/main/java/com/yaoyuan/jiscuss/controller/UserPageController.java deleted file mode 100644 index 5a2b897..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/UserPageController.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import com.yaoyuan.jiscuss.entity.UserInfo; -import com.yaoyuan.jiscuss.service.IDiscussionsService; -import com.yaoyuan.jiscuss.service.ITagsService; -import com.yaoyuan.jiscuss.service.IUsersService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.controller - * @Description: - * @date - */ -@Controller -public class UserPageController extends BaseController { - - private static Logger logger = LoggerFactory.getLogger(UserPageController.class); - - @Autowired - private IUsersService usersService; - - @Autowired - private IDiscussionsService discussionsService; - - @Autowired - private ITagsService tagsService; - - /** - * 用户页面 - * - * @return - */ - @RequestMapping("/user") - public String user(@RequestParam(defaultValue = "discussion") String type, HttpServletRequest request, ModelMap map) { - - // type 判断 - if (type.equals("discussion")) { - map.put("discussion", "active"); - } - - if (type.equals("change")) { - map.put("change", "active"); - } - - if (type.equals("like")) { - map.put("like", "active"); - } - - UserInfo user = getUserInfo(request); - if (user != null) { - map.put("username", user.getUsername()); - map.put("data", "Jiscuss 用户:" + user.getUsername()); - } - - - return "user"; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/UserPostController.java b/src/main/java/com/yaoyuan/jiscuss/controller/UserPostController.java deleted file mode 100644 index 1d0cf66..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/UserPostController.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import com.yaoyuan.jiscuss.entity.Discussion; -import com.yaoyuan.jiscuss.entity.DiscussionTag; -import com.yaoyuan.jiscuss.entity.Post; -import com.yaoyuan.jiscuss.entity.Tag; -import com.yaoyuan.jiscuss.entity.User; -import com.yaoyuan.jiscuss.entity.UserInfo; -import com.yaoyuan.jiscuss.entity.custom.DiscussionCustom; -import com.yaoyuan.jiscuss.service.IDiscussionsService; -import com.yaoyuan.jiscuss.service.IDiscussionsTagsService; -import com.yaoyuan.jiscuss.service.IPostsService; -import com.yaoyuan.jiscuss.service.ITagsService; -import com.yaoyuan.jiscuss.service.IUsersService; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.List; - -/** - * @author yaoyuan2.chu - * 主题帖子评论控制器 - */ -@Controller -public class UserPostController extends BaseController { - - private static Logger logger = LoggerFactory.getLogger(UserPostController.class); - - @Autowired - private IDiscussionsService discussionsService; - - @Autowired - private ITagsService tagsService; - - @Autowired - private IDiscussionsTagsService iDiscussionsTagsService; - - @Autowired - private IPostsService postsService; - - @Autowired - private IUsersService usersService; - - - /** - * 首页查看主题列表(各种条件筛选,最热最新标签等) - */ - - - /** - * 查看主题详情 - * @param request - * @param map - * @param id - * @return - */ - @RequestMapping("/getdiscussionsbyid") - public String getDiscussionsById(HttpServletRequest request, ModelMap map, @RequestParam("id") Integer id) { - logger.info(">>> getDiscussionsById{}", id); - - Discussion discussion = discussionsService.findOne(id); - // 获取此主题下的评论 - List posts = postsService.findOneBy(id); - - DiscussionCustom newdd = new DiscussionCustom(); - 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()) { - User lastUser = usersService.findOne(newdd.getLastUserId()); - newdd.setAvatarLast(lastUser.getAvatar()); - newdd.setRealnameLast(lastUser.getRealname()); - newdd.setUsernameLast(lastUser.getUsername()); - } - - List tags = tagsService.findByDId(id); - List postsObj = postsService.findPostCustomById(id); - map.put("tags", tags); - map.put("discussions", newdd); - map.put("posts", postsObj); - UserInfo user = getUserInfo(request); - if (user != null) { - map.put("username", user.getUsername()); - } - return "discussions"; - } - - /** - * 新建主题 - * @param discussion - * @return - */ - @PostMapping(value = "/newDiscussions") - @ResponseBody - public String newDiscussions(@RequestBody DiscussionCustom discussion) { - logger.info(">>> newPost" + discussion); - - ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - HttpServletRequest request = servletRequestAttributes.getRequest(); - UserInfo user = getUserInfo(request); - 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 discussionOne = new Discussion(); - BeanUtils.copyProperties(discussion, discussionOne); - Discussion saveDiscussion = discussionsService.insert(discussionOne); - - 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); - resultobj.put("msg", "添加主题成功"); - resultobj.put("flag", true); - return resultobj.toString(); // - - } - - - /** - * 编辑主题 - * @param post - * @return - */ - - /** - * 删除主题 - * @param post - * @return - */ - - /** - * 新建评论 - * @param post - * @return - */ - @PostMapping(value = "/newPost") - @ResponseBody - public String newPosts(@RequestBody Post post) { - logger.info(">>> newpost" + post); - - ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - HttpServletRequest request = servletRequestAttributes.getRequest(); - - UserInfo user = getUserInfo(request); - if (user != null) { - post.setCreateId(user.getId()); - } - post.setCreateTime(new Date()); - if (null != post.getParentId()) { - Post temp = postsService.findOneByid(post.getParentId()); - post.setUserId(temp.getCreateId()); - } - - Post savePost = postsService.insert(post); - JSONObject resultobj = new JSONObject(); - - logger.info(">>>{}", savePost); - resultobj.put("msg", "添加评论成功"); - resultobj.put("flag", true); - return resultobj.toString(); // - } - - /** - * 删除评论 - * @param tag - * @return - */ - - /** - * 新建标签 - * @param tag - * @return - */ - @PostMapping(value = "/newtags") - @ResponseBody - public String newTags(@RequestBody Tag tag) { - logger.info(">>> newTags" + tag); - ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - HttpServletRequest request = servletRequestAttributes.getRequest(); - - UserInfo user = getUserInfo(request); - if (user != null) { - tag.setCreateId(user.getId()); - } - tag.setCreateTime(new Date()); - - Tag saveTag = tagsService.insert(tag); - JSONObject resultobj = new JSONObject(); - - logger.info(">>>{}", saveTag); - resultobj.put("msg", "添加标签成功"); - resultobj.put("flag", true); - return resultobj.toString(); - } - - /** - * 排行榜等 - */ - - /** - * 新建主题页 - * - * @param request - * @param map - * @return - */ - @RequestMapping({"/newDiscussionsPage"}) - public String newdiccuss(HttpServletRequest request, ModelMap map) { - //获取所有标签(以后尝试去缓存中取) - List allTags = tagsService.getAllListDiscussions(); - map.put("allTags", allTags); - - UserInfo user = getUserInfo(request); - if (user != null) { - map.put("username", user.getUsername()); - map.put("data", "Jiscuss 用户:" + user.getUsername()); - } - return "newdiccuss"; - } - - /** - * 新建标签页 - * - * @param request - * @param map - * @return - */ - @RequestMapping({"/newTagPage"}) - public String newtag(HttpServletRequest request, ModelMap map) { - - //获取所有标签(以后尝试去缓存中取) - List allTags = tagsService.getAllList(); - map.put("allTags", allTags); - - UserInfo user = getUserInfo(request); - if (user != null) { - map.put("username", user.getUsername()); - map.put("data", "Jiscuss 用户:" + user.getUsername()); - } - return "newtag"; - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/UserSystemController.java b/src/main/java/com/yaoyuan/jiscuss/controller/UserSystemController.java deleted file mode 100644 index c182c95..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/UserSystemController.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.yaoyuan.jiscuss.controller; - -import com.yaoyuan.jiscuss.entity.Discussion; -import com.yaoyuan.jiscuss.entity.Tag; -import com.yaoyuan.jiscuss.entity.User; -import com.yaoyuan.jiscuss.entity.UserInfo; -import com.yaoyuan.jiscuss.entity.custom.DiscussionCustom; -import com.yaoyuan.jiscuss.entity.custom.TagCustom; -import com.yaoyuan.jiscuss.service.IDiscussionsService; -import com.yaoyuan.jiscuss.service.ITagsService; -import com.yaoyuan.jiscuss.service.IUsersService; -import com.yaoyuan.jiscuss.util.DelTagsUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author yaoyuan2.chu - * 首页页面系统控制器 - */ -@Controller -public class UserSystemController extends BaseController { - private static Logger logger = LoggerFactory.getLogger(UserSystemController.class); - - @Autowired - private IUsersService usersService; - - @Autowired - private IDiscussionsService discussionsService; - - @Autowired - private ITagsService tagsService; - - /** - * 首页index - * @param tag - * @param type - * @param pageNum - * @param request - * @param map - * @return - */ - @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); - int pageSiz = 10; - int pageNumNew = pageNum - 1; - Discussion discussion = new Discussion(); - //分页获取主题帖子-默认 - Page allDiscussionsPage = discussionsService.queryAllDiscussionsList(discussion, pageNumNew, pageSiz, tag, type); - - List allDiscussions = allDiscussionsPage.getContent(); - List newAllD = new ArrayList<>(); - setTagAndUserList(newAllD, allDiscussions); - logger.info("全部主题==>:{}", allDiscussions); - - Long total = allDiscussionsPage.getTotalElements(); - - //获取主题帖子的分页数据(以后尝试去缓存中取) - List pageNumList = getPageNumList(allDiscussionsPage.getTotalPages()); - - //获取所有标签(以后尝试去缓存中取) - List allTags = tagsService.getAllList(); - logger.info("全部标签==>:{}", allTags); - - if (!tag.equals("all")) { - //获取是否有子标签 - List allChildTags = tagsService.findByParentId(tag); - map.put("allChildTags", allChildTags); - } - - map.put("data", "Jiscuss 用户"); - map.put("allDiscussions", newAllD); - map.put("allUser", usersService.getAllList()); - map.put("pageDiscussions", pageNumList); - map.put("allTags", allTags); - map.put("tag", tag); - map.put("type", type); - - if (type.equals("all")) { - map.put("typeAll", "active"); - } - if (type.equals("hot")) { - map.put("typeHot", "active"); - } - if (type.equals("new")) { - map.put("typeNew", "active"); - } - map.put("pageSize", pageSiz); - map.put("pageTotal", total); - map.put("pageNum", pageNum); - map.put("pageTotalPages", allDiscussionsPage.getTotalPages()); - UserInfo user = getUserInfo(request); - if (user != null) { - map.put("username", user.getUsername()); - map.put("data", "Jiscuss 用户:" + user.getUsername()); - } - return "index"; - } - - /** - * 组装DiscussionCustom - * - * @param newAllD - * @param allDiscussions - */ - private void setTagAndUserList(List newAllD, List allDiscussions) { - - List discussionIdLsit = new ArrayList<>(); - for (Discussion dd : allDiscussions) { - discussionIdLsit.add(dd.getId()); - } - List TagCustomList = tagsService.findByDiscussionIdlistId(discussionIdLsit); - - Map> tagMap = new HashMap<>(); - for (TagCustom tc : TagCustomList) { - List tagCustomListTemp = new ArrayList<>(); - if (tagMap.containsKey(tc.getDiscussionId())) { - tagCustomListTemp = tagMap.get(tc.getDiscussionId()); - tagCustomListTemp.add(tc); - tagMap.put(tc.getDiscussionId(), tagCustomListTemp); - } else { - tagCustomListTemp.add(tc); - tagMap.put(tc.getDiscussionId(), tagCustomListTemp); - } - } - for (Discussion dd : allDiscussions) { - DiscussionCustom newdd = new DiscussionCustom(); - BeanUtils.copyProperties(dd, newdd); - String newCon = ""; - String content = DelTagsUtil.getTextFromHtml(newdd.getContent()); - if (null != content && content.length() > 30) { - newCon = content.substring(0, 29); - } else { - newCon = content; - } - newdd.setContent(newCon); - if (null != newdd.getStartUserId()) { - User startUser = usersService.findOne(newdd.getStartUserId()); - newdd.setAvatar(startUser != null && startUser.getAvatar() != null ? startUser.getAvatar() : ""); - newdd.setRealname(startUser != null && startUser.getRealname() != null ? startUser.getRealname() : ""); - newdd.setUsername(startUser != null && startUser.getUsername() != null ? startUser.getUsername() : ""); - } - if (null != newdd.getLastUserId()) { - User lastUser = usersService.findOne(newdd.getLastUserId()); - newdd.setAvatarLast(lastUser != null && lastUser.getAvatar() != null ? lastUser.getAvatar() : ""); - newdd.setRealnameLast(lastUser != null && lastUser.getRealname() != null ? lastUser.getRealname() : ""); - newdd.setUsernameLast(lastUser != null && lastUser.getUsername() != null ? lastUser.getUsername() : ""); - } - // 组装tag - newdd.setTagList(tagMap.get(dd.getId())); - newAllD.add(newdd); - } - } - - /** - * 分页信息 - * - * @param size - * @return - */ - private List getPageNumList(int size) { - List pageNumList = new ArrayList(); - for (int i = 0; i < size; i++) { - pageNumList.add("" + (i + 1)); - } - return pageNumList; - } - - - /** - * 登录页 - * - * @param error - * @param logout - * @param map - * @return - */ - @GetMapping("/login") - public String login(@RequestParam(value = "error", required = false) String error, - @RequestParam(value = "logout", required = false) String logout, ModelMap map) { - if (error != null) { - map.put("msg", "您输入的用户名密码错误!"); - return "login"; - } - if (logout != null) { - map.put("msg", "退出成功!"); - return "login"; - } - - return "login"; - } - - - /** - * 注册提交 - * @param username - * @param email - * @param password - * @param map - * @return - */ - @PostMapping("/registerDo") - public String registerDo(@RequestParam String username, @RequestParam String email, - @RequestParam String password, ModelMap map) { - //验证用户名是否存在 - if (null != usersService.getByUsername(username)) { - map.put("msg", "用户已存在,请重试!"); - return "register"; - } else { - User user = new User(); - user.setEmail(email); - user.setPassword(password); - user.setUsername(username); - user.setRealname(username); - user.setJoinTime(new Date()); - User userInsert = usersService.insert(user); - map.put("msg", "注册成功,请登陆!"); - return "login"; - } - } - - /** - * 注册页面 - * - * @return - */ - @RequestMapping("/register") - public String register() { - return "register"; - } - - //获取设置信息 - - //获取首页统计 -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/api/RestPostController.java b/src/main/java/com/yaoyuan/jiscuss/controller/api/RestPostController.java deleted file mode 100644 index 58df1d1..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/api/RestPostController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.yaoyuan.jiscuss.controller.api; - -import com.yaoyuan.jiscuss.entity.Discussion; -import com.yaoyuan.jiscuss.exception.BaseException; -import com.yaoyuan.jiscuss.response.ResponseCode; -import com.yaoyuan.jiscuss.service.IDiscussionsService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -@RestController -@RequestMapping(path = "/other_api", produces = "application/json;charset=utf-8") -@Api(value = "主题帖子(其他)接口管理", tags = {"主题帖子(其他)接口管理"}) -public class RestPostController { - private static Logger logger = LoggerFactory.getLogger(RestPostController.class); - - @Autowired - private IDiscussionsService discussionsService; - - @PostMapping("/discussion") - @ApiOperation("新增主题") - public Discussion save(@RequestBody Discussion discussion) { - Discussion saveDiscussion = discussionsService.insert(discussion); - if (saveDiscussion != null) { - return saveDiscussion; - } else { - throw new BaseException(ResponseCode.RESOURCES_NOT_EXIST); - } - } - - @GetMapping("/discussion/{id}") - @ApiOperation("获取主题") - public Discussion getDiscussions(@PathVariable Integer id) { - Discussion discussion = discussionsService.findOne(id); - return discussion; - } - - @GetMapping("/discussions") - @ApiOperation("获取全部主题") - public List getAllDiscussions() { - List allDiscussions = discussionsService.getAllList(); - logger.info("全部主题==>:{}", allDiscussions); - return allDiscussions; - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/controller/api/RestUserController.java b/src/main/java/com/yaoyuan/jiscuss/controller/api/RestUserController.java deleted file mode 100644 index d776261..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/controller/api/RestUserController.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.yaoyuan.jiscuss.controller.api; - -import com.yaoyuan.jiscuss.entity.User; -import com.yaoyuan.jiscuss.exception.BaseException; -import com.yaoyuan.jiscuss.response.ResponseCode; -import com.yaoyuan.jiscuss.service.IUsersService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -@RestController -@RequestMapping("/user_api") -@Api(value = "用户接口管理", tags = {"用户接口管理"}) -public class RestUserController { - - private static Logger logger = LoggerFactory.getLogger(RestUserController.class); - - @Autowired - private IUsersService usersService; - - @PostMapping("/user") - @ApiOperation("新增用户") - public User save(@RequestBody User user) { - User saveUser = usersService.insert(user); - if (saveUser != null) { - return saveUser; - } else { - throw new BaseException(ResponseCode.RESOURCES_NOT_EXIST); - } - - } - - @DeleteMapping("/user/{id}") - @ApiOperation("删除用户") - public Boolean delete(@PathVariable Integer id) { - Boolean delete = true; - usersService.remove(id); - if (delete) { - return delete; - } else { - throw new BaseException(ResponseCode.RESOURCES_NOT_EXIST); - } - } - - @PutMapping("/user/{id}") - @ApiOperation("修改用户") - public User update(@RequestBody User user, @PathVariable Integer id) { - User updateuser = usersService.update(user, id); - if (updateuser != null) { - return updateuser; - } else { - throw new BaseException(ResponseCode.RESOURCES_NOT_EXIST); - } - } - - @GetMapping("/user/{id}") - @ApiOperation("获取用户") - public User getUser(@PathVariable Integer id) { - User user = usersService.findOne(id); - logger.info("获取用户==>:{}", JSONObject.valueToString(user)); - return user; - } - - @GetMapping("/user") - @ApiOperation("获取全部用户") - public List getUser(User user) { - List userall = usersService.getAllList(); - logger.info("全部用户==>:{}", JSONObject.valueToString(userall)); - return userall; - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/Discussion.java b/src/main/java/com/yaoyuan/jiscuss/entity/Discussion.java deleted file mode 100644 index e29cdbc..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/Discussion.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.util.Date; - -@Data -@Entity -@Table(name = "discussion") -public class Discussion implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", unique = true) - private Integer id; - - @Column(name = "title") - private String title; - - @Column(name = "content") - private String content; - - @Column(name = "comments_count") - private Integer commentsCount; - - @Column(name = "participants_count") - private Integer participantsCount; - - @Column(name = "number_index") - private Integer numberIndex; - - @Column(name = "start_time") - private Date startTime; - - @Column(name = "start_user_id") - private Integer startUserId; - - @Column(name = "start_post_id") - private Integer startPostId; - - @Column(name = "last_time") - private Date lastTime; - - @Column(name = "last_user_id") - private Integer lastUserId; - - @Column(name = "last_post_id") - private Integer lastPostId; - - @Column(name = "last_post_number") - private Integer lastPostNumber; - - @Column(name = "is_approved") - private Integer isApproved; - - @Column(name = "like_count") - private Integer likeCount; - - - @Column(name = "ip_address") - private String ipAddress; - - @Column(name = "create_id") - private Integer createId; - - @Column(name = "create_time") - private Date createTime; - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/DiscussionTag.java b/src/main/java/com/yaoyuan/jiscuss/entity/DiscussionTag.java deleted file mode 100644 index b272be9..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/DiscussionTag.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; - -@Data -@Entity -@Table(name = "discussiontag") -public class DiscussionTag implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "discussion_id") - private Integer discussionId; - - @Column(name = "tag_id") - private Integer tagId; - - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/LikeCollect.java b/src/main/java/com/yaoyuan/jiscuss/entity/LikeCollect.java deleted file mode 100644 index b7bce26..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/LikeCollect.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.util.Date; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.entity - * @Description: - * @date 2020/10/21 12:00 - */ -@Data -@Entity -@Table(name = "likecollect") -public class LikeCollect implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "discussion_id") - private Integer discussionId; - - @Column(name = "discussion_name") - private String discussionName; - - @Column(name = "tag_id") - private Integer tagId; - - @Column(name = "post_id") - private Integer postId; - - @Column(name = "post_content") - private String postContent; - - @Column(name = "user_id") - private Integer userId; - - @Column(name = "user_name") - private String userName; - - @Column(name = "type") - private String type; - - @Column(name = "like_type") - private String likeType; - - @Column(name = "collect_type") - private String collectType; - - @Column(name = "create_id") - private Integer createId; - - @Column(name = "create_time") - private Date createTime; - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/Post.java b/src/main/java/com/yaoyuan/jiscuss/entity/Post.java deleted file mode 100644 index 8dda459..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/Post.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.util.Date; - -@Data -@Entity -@Table(name = "post") -public class Post implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "discussion_id") - private Integer discussionId; - - @Column(name = "number") - private Integer number; - - @Column(name = "time") - private Date time; - - @Column(name = "user_id") - private Integer userId; - - @Column(name = "type") - private String type; - - @Column(name = "content") - private String content; - - @Column(name = "parent_id") - private Integer parentId; - - @Column(name = "edit_time") - private Date editTime; - - @Column(name = "edit_user_id") - private Integer editUserId; - - @Column(name = "ip_address") - private String ipAddress; - - @Column(name = "copyright") - private String copyright; - - @Column(name = "is_approved") - private Integer isApproved; - - @Column(name = "create_id") - private Integer createId; - - @Column(name = "create_time") - private Date createTime; -} - diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/Setting.java b/src/main/java/com/yaoyuan/jiscuss/entity/Setting.java deleted file mode 100644 index b280ed4..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/Setting.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; - -@Data -@Entity -@Table(name = "setting") -public class Setting implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "setting_key") - private String settingKey; - - @Column(name = "setting_value") - private String settingValue; -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/Tag.java b/src/main/java/com/yaoyuan/jiscuss/entity/Tag.java deleted file mode 100644 index 1606c25..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/Tag.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.util.Date; - -@Data -@Entity -@Table(name = "tag") -public class Tag implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "name") - private String name; - - @Column(name = "description") - private String description; - - @Column(name = "color") - private String color; - - @Column(name = "icon") - private String icon; - - @Column(name = "position") - private Integer position; - - @Column(name = "parent_id") - private Integer parentId; - - @Column(name = "discussions_count") - private String discussionsCount; - - @Column(name = "last_time") - private Date lastTime; - - @Column(name = "last_discussion_id") - private Integer lastDiscussionId; - - @Column(name = "create_id") - private Integer createId; - - @Column(name = "create_time") - private Date createTime; -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/User.java b/src/main/java/com/yaoyuan/jiscuss/entity/User.java deleted file mode 100644 index 86914ed..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/User.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - - -import lombok.Data; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.util.Date; - -@Data -@Entity -@Table(name = "user") -public class User implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "username") - private String username; - - @Column(name = "realname") - private String realname; - - @Column(name = "email") - private String email; - - @Column(name = "password") - private String password; - - @Column(name = "join_time") - private Date joinTime; - - @Column(name = "age") - private Integer age; - - @Column(name = "gender") - private String gender; - - @Column(name = "avatar") - private String avatar; - - @Column(name = "phone") - private String phone; - - @Column(name = "discussions_count") - private Integer discussionsCount; - - @Column(name = "comments_count") - private Integer commentsCount; - - @Column(name = "last_seen_time") - private Date lastSeenTime; - - @Column(name = "flag") - private Integer flag; - - @Column(name = "level") - private Integer level; - -} \ No newline at end of file diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/UserInfo.java b/src/main/java/com/yaoyuan/jiscuss/entity/UserInfo.java deleted file mode 100644 index 631ad31..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/UserInfo.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.yaoyuan.jiscuss.entity; - -import lombok.Data; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import java.util.Collection; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.entity - * @Description: - * @date 2020/7/16 14:55 - */ -@Data -public class UserInfo implements UserDetails { - - private Collection authorities; - private String password; - private String username; - private String phone; - private Integer age; - private Integer id; - private String realname; - private String email; - private String gender; - private Integer level; - private Integer flag; - - public UserInfo() { - } - - public UserInfo(Collection authorities, Integer id, String password, String username, String phone) { - this.authorities = authorities; - this.id = id; - this.password = password; - this.username = username; - this.phone = phone; - } - - @Override - public Collection extends GrantedAuthority> getAuthorities() { - return authorities; - } - - @Override - public String getPassword() { - return password; - } - - @Override - public String getUsername() { - return username; - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String toString() { - return "UserInfo{" + - "authorities=" + authorities + - ", password='" + password + '\'' + - ", username='" + username + '\'' + - ", id='" + id + '\'' + - '}'; - } -} - diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/custom/DiscussionCustom.java b/src/main/java/com/yaoyuan/jiscuss/entity/custom/DiscussionCustom.java deleted file mode 100644 index 5a586d7..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/custom/DiscussionCustom.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.yaoyuan.jiscuss.entity.custom; - -import com.yaoyuan.jiscuss.entity.Discussion; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -import java.util.List; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.entity.custom - * @Description: - * @date 2020/9/9 14:44 - */ - -@Data -@Setter -@Getter -public class DiscussionCustom extends Discussion { - - private String avatar; - - private String username; - - private String realname; - - private String avatarLast; - - private String usernameLast; - - private String realnameLast; - - private String tag; - - private List tagList; - - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/custom/PostCustom.java b/src/main/java/com/yaoyuan/jiscuss/entity/custom/PostCustom.java deleted file mode 100644 index 4fac8eb..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/custom/PostCustom.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.yaoyuan.jiscuss.entity.custom; - -import com.yaoyuan.jiscuss.entity.Post; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -import java.util.List; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.entity.custom - * @Description: - * @date 2020/9/9 14:44 - */ -@Data -@Setter -@Getter -public class PostCustom extends Post { - - private String avatar; - - private String username; - - private String realname; - - private String avatarReply; - - private String usernameReply; - - private String realnameReply; - - private List child; - - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/entity/custom/TagCustom.java b/src/main/java/com/yaoyuan/jiscuss/entity/custom/TagCustom.java deleted file mode 100644 index 54ed72a..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/entity/custom/TagCustom.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.yaoyuan.jiscuss.entity.custom; - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -import javax.persistence.Column; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.entity.custom - * @Description: - * @date 2020/10/21 10:05 - */ -@Data -@Setter -@Getter -public class TagCustom { - - @Column(name = "name") - private String name; - - @Column(name = "description") - private String description; - - @Column(name = "color") - private String color; - - @Column(name = "icon") - private String icon; - - @Column(name = "discussion_id") - private Integer discussionId; - - - public TagCustom(String name, String color, String icon, String description, Integer discussionId) { - this.name = name; - this.color = color; - this.icon = icon; - this.description = description; - this.discussionId = discussionId; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/exception/BaseException.java b/src/main/java/com/yaoyuan/jiscuss/exception/BaseException.java deleted file mode 100644 index 3b5fc9e..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/exception/BaseException.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.yaoyuan.jiscuss.exception; - -import com.yaoyuan.jiscuss.response.ResponseCode; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 业务异常类,继承运行时异常,确保事务正常回滚 - * - * @author NULL - * @since 2019-07-16 - */ -@Data -@EqualsAndHashCode(callSuper = false) -public class BaseException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - private ResponseCode code; - - /** - * BaseException - * ResponseCode code - **/ - public BaseException(ResponseCode code) { - this.code = code; - } - - /** - * BaseException - * ResponseCode code - * Throwable cause - **/ - public BaseException(Throwable cause, ResponseCode code) { - super(cause); - this.code = code; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/handler/CustomAccessDeniedHandler.java b/src/main/java/com/yaoyuan/jiscuss/handler/CustomAccessDeniedHandler.java deleted file mode 100644 index 69fd38c..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/handler/CustomAccessDeniedHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.yaoyuan.jiscuss.handler; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.WebAttributes; -import org.springframework.security.web.access.AccessDeniedHandler; -import org.springframework.stereotype.Component; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; - -/** - * 处理无权请求 - * - * @author charlie - */ -@Component -public class CustomAccessDeniedHandler implements AccessDeniedHandler { - - private Logger log = LoggerFactory.getLogger(CustomAccessDeniedHandler.class); - - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, - AccessDeniedException accessDeniedException) throws IOException, ServletException { - boolean isAjax = ControllerTools.isAjaxRequest(request); - System.out.println("CustomAccessDeniedHandler handle"); - if (!response.isCommitted()) { - if (isAjax) { - String msg = accessDeniedException.getMessage(); - log.info("accessDeniedException.message:" + msg); - String accessDenyMsg = "{\"code\":\"403\",\"msg\":\"没有权限\"}"; - ControllerTools.print(response, accessDenyMsg); - } else { - request.setAttribute(WebAttributes.ACCESS_DENIED_403, accessDeniedException); - response.setStatus(HttpStatus.FORBIDDEN.value()); - RequestDispatcher dispatcher = request.getRequestDispatcher("/403"); - dispatcher.forward(request, response); - } - } - } - - public static class ControllerTools { - public static boolean isAjaxRequest(HttpServletRequest request) { - return "XMLHttpRequest".equals(request.getHeader("X-Requested-With")); - } - - public static void print(HttpServletResponse response, String msg) throws IOException { - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json; charset=utf-8"); - PrintWriter writer = response.getWriter(); - writer.write(msg); - writer.flush(); - writer.close(); - } - } - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/handler/RbacPermission.java b/src/main/java/com/yaoyuan/jiscuss/handler/RbacPermission.java deleted file mode 100644 index 6bd5aa1..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/handler/RbacPermission.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.yaoyuan.jiscuss.handler; - -import org.springframework.security.core.Authentication; -import org.springframework.stereotype.Component; -import org.springframework.util.AntPathMatcher; - -import javax.servlet.http.HttpServletRequest; - -/** - * RBAC数据模型控制权限 - * - * @author charlie - */ -@Component("rbacPermission") -public class RbacPermission { - - private AntPathMatcher antPathMatcher = new AntPathMatcher(); - - public boolean hasPermission(HttpServletRequest request, Authentication authentication) { - Object principal = authentication.getPrincipal(); - boolean hasPermission = false; - - hasPermission = true; -// if (principal instanceof UserEntity) { -// // 读取用户所拥有的权限菜单 -// List menus = ((UserEntity) principal).getRoleMenus(); -// System.out.println(menus.size()); -// for (Menu menu : menus) { -// if (antPathMatcher.match(menu.getMenuUrl(), request.getRequestURI())) { -// hasPermission = true; -// break; -// } -// } -// } - return hasPermission; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/repository/DiscussionsRepository.java b/src/main/java/com/yaoyuan/jiscuss/repository/DiscussionsRepository.java deleted file mode 100644 index c1df9d7..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/repository/DiscussionsRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.yaoyuan.jiscuss.repository; - -import com.yaoyuan.jiscuss.entity.Discussion; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Repository; - -@Repository -public interface DiscussionsRepository extends JpaRepository { - - @Query(value = "SELECT * from discussion where id in (\n" + - "SELECT discussion_id from discussiontag where tag_id = ?1 ) ", nativeQuery = true) - Page findByQuery(String tagId, Pageable pageable); - - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/repository/DiscussionsTagsRepository.java b/src/main/java/com/yaoyuan/jiscuss/repository/DiscussionsTagsRepository.java deleted file mode 100644 index d2a83d4..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/repository/DiscussionsTagsRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.yaoyuan.jiscuss.repository; - -import com.yaoyuan.jiscuss.entity.DiscussionTag; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - - -@Repository -public interface DiscussionsTagsRepository extends JpaRepository { -} diff --git a/src/main/java/com/yaoyuan/jiscuss/repository/PostsRepository.java b/src/main/java/com/yaoyuan/jiscuss/repository/PostsRepository.java deleted file mode 100644 index fcbead1..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/repository/PostsRepository.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.yaoyuan.jiscuss.repository; - -import com.yaoyuan.jiscuss.entity.Post; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Map; - -@Repository -public interface PostsRepository extends JpaRepository { - - /** - * @param dId - * @return - */ - @Query("from Post where discussionId = :dId") - List findOneBy(@Param("dId") Integer dId); - - @Query(value = "select p.*,u.avatar as user_avatar ,u.username as user_username ,u.realname as user_realname ," + - "u2.avatar as create_avatar ,u2.username as create_username ,u2.realname as create_realname \n" + - "from post p \n" + - "left join user u on p.user_id = u.id \n" + - "left join user u2 on p.create_id = u2.id \n" + - "where p.discussion_id = :dId order by p.create_time desc" - , nativeQuery = true) - List> findPostCustomById(@Param("dId") Integer dId); - - - @Query(value = "select p.*,u.avatar as user_avatar ,u.username as user_username ,u.realname as user_realname ," + - "u2.avatar as create_avatar ,u2.username as create_username ,u2.realname as create_realname \n" + - "from post p \n" + - "left join user u on p.user_id = u.id \n" + - "left join user u2 on p.create_id = u2.id \n" + - "where p.discussion_id = :dId and p.parent_id is null order by p.create_time desc" - , nativeQuery = true) - List> findAllByDIdAndparentIdNull(@Param("dId") Integer dId); - - @Query(value = "select p.*,u.avatar as user_avatar ,u.username as user_username ,u.realname as user_realname ," + - "u2.avatar as create_avatar ,u2.username as create_username ,u2.realname as create_realname \n" + - "from post p \n" + - "left join user u on p.user_id = u.id \n" + - "left join user u2 on p.create_id = u2.id \n" + - "where p.discussion_id = :dId and p.parent_id is not null order by p.create_time desc" - , nativeQuery = true) - List> findAllByDIdAndparentIdNotNull(@Param("dId") Integer dId); - - -// @Query("from Post where parentId is null and discussionId = :dId") -// List findAllByDIdAndparentIdNull(@Param("dId")Integer dId); -// -// @Query("from Post where parentId is not null and discussionId = :dId") -// List findAllByDIdAndparentIdNotNull(@Param("dId")Integer dId); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/repository/SettingsRepository.java b/src/main/java/com/yaoyuan/jiscuss/repository/SettingsRepository.java deleted file mode 100644 index 4d95e26..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/repository/SettingsRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.yaoyuan.jiscuss.repository; - -import com.yaoyuan.jiscuss.entity.Setting; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface SettingsRepository extends JpaRepository { -} diff --git a/src/main/java/com/yaoyuan/jiscuss/repository/TagsRepository.java b/src/main/java/com/yaoyuan/jiscuss/repository/TagsRepository.java deleted file mode 100644 index 8dd5cff..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/repository/TagsRepository.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.yaoyuan.jiscuss.repository; - -import com.yaoyuan.jiscuss.entity.Tag; -import com.yaoyuan.jiscuss.entity.custom.TagCustom; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface TagsRepository extends JpaRepository { - - @Query(value = "FROM Tag a, DiscussionTag b WHERE a.id = b.tagId and b.discussionId = :dId") - List findByDId(@Param("dId") Integer dId); - - @Query("select new com.yaoyuan.jiscuss.entity.custom.TagCustom(" + - "u.name,u.color,u.icon,u.description, d.discussionId" + - ") " + - "from Tag u, DiscussionTag d " + - "where u.id=d.tagId and d.discussionId in (:discussionIdlist)") - List findByDiscussionIdlistId(@Param(value = "discussionIdlist") List discussionIdlist); - - List findByParentId(Integer tagId); - - @Query(value = "FROM Tag a WHERE a.parentId is null") - List findAllIsNull(); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/repository/UsersRepository.java b/src/main/java/com/yaoyuan/jiscuss/repository/UsersRepository.java deleted file mode 100644 index 4f93731..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/repository/UsersRepository.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.yaoyuan.jiscuss.repository; - -import com.yaoyuan.jiscuss.entity.User; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface UsersRepository extends JpaRepository { - /** - * @param username - * @return - */ - @Query("from User where username like %:username%") - List getByUsernameIsLike(@Param("username") String username); - - /** - * @param id - * @return - */ - User getById(Integer id); - - /** - * @param username - * @return - */ - @Query("from User where username = :username") - User getByUsername(String username); - - /** - * @param username - * @param password - * @return - */ - @Query("from User where username = :username and password = :password") - User checkByUsernameAndPassword(String username, String password); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/response/ResponseCode.java b/src/main/java/com/yaoyuan/jiscuss/response/ResponseCode.java deleted file mode 100644 index 6e87ee7..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/response/ResponseCode.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.yaoyuan.jiscuss.response; - -/** - * 返回状态码 - * - * @author NULL - * @date 2019-12-16 - */ -public enum ResponseCode { - /** - * 成功返回的状态码 - */ - SUCCESS(10000, "success"), - /** - * 资源不存在的状态码 - */ - RESOURCES_NOT_EXIST(10001, "资源不存在"), - /** - * 所有无法识别的异常默认的返回状态码 - */ - SERVICE_ERROR(50000, "服务器异常"); - /** - * 状态码 - */ - private int code; - /** - * 返回信息 - */ - private String msg; - - ResponseCode(int code, String msg) { - this.code = code; - this.msg = msg; - } - - public int getCode() { - return code; - } - - public String getMsg() { - return msg; - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/response/ResponseResult.java b/src/main/java/com/yaoyuan/jiscuss/response/ResponseResult.java deleted file mode 100644 index e2757c2..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/response/ResponseResult.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.yaoyuan.jiscuss.response; - -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.io.Serializable; - -/** - * 统一的公共响应体 - * - * @author NULL - * @date 2019-12-16 - */ -@Data -@AllArgsConstructor -public class ResponseResult implements Serializable { - - /** - * serialVersionUID - */ - private static final long serialVersionUID = 1L; - - /** - * 返回状态码 - */ - private Integer code; - /** - * 返回信息 - */ - private String msg; - /** - * 数据 - */ - private Object data; - -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/IDiscussionsService.java b/src/main/java/com/yaoyuan/jiscuss/service/IDiscussionsService.java deleted file mode 100644 index 04459dd..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/IDiscussionsService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.yaoyuan.jiscuss.service; - -import com.yaoyuan.jiscuss.entity.Discussion; -import org.springframework.data.domain.Page; - -import java.util.List; - -public interface IDiscussionsService { - - List getAllList(); - - Discussion insert(Discussion discussion); - - Discussion findOne(Integer id); - - Page queryAllDiscussionsList(Discussion discussion, int pageNumNew, int pageSiz, String tag, String type); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/IDiscussionsTagsService.java b/src/main/java/com/yaoyuan/jiscuss/service/IDiscussionsTagsService.java deleted file mode 100644 index 9dc3f3b..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/IDiscussionsTagsService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.yaoyuan.jiscuss.service; - -import com.yaoyuan.jiscuss.entity.DiscussionTag; - -import java.util.List; - -public interface IDiscussionsTagsService { - - List getAllList(); - - DiscussionTag insert(DiscussionTag discussionTag); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/IPostsService.java b/src/main/java/com/yaoyuan/jiscuss/service/IPostsService.java deleted file mode 100644 index b58772c..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/IPostsService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.yaoyuan.jiscuss.service; - -import com.yaoyuan.jiscuss.entity.Post; -import com.yaoyuan.jiscuss.entity.custom.PostCustom; - -import java.util.List; - -public interface IPostsService { - List getAllList(); - - Post insert(Post post); - - List findOneBy(Integer id); - - List findPostCustomById(Integer id); - - Post findOneByid(Integer parentId); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/ISettingsService.java b/src/main/java/com/yaoyuan/jiscuss/service/ISettingsService.java deleted file mode 100644 index 9f453d7..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/ISettingsService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.yaoyuan.jiscuss.service; - -import com.yaoyuan.jiscuss.entity.Setting; - -import java.util.List; - -public interface ISettingsService { - - List getAllList(); - - Setting insert(Setting setting); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/ITagsService.java b/src/main/java/com/yaoyuan/jiscuss/service/ITagsService.java deleted file mode 100644 index 732400e..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/ITagsService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.yaoyuan.jiscuss.service; - -import com.yaoyuan.jiscuss.entity.Tag; -import com.yaoyuan.jiscuss.entity.custom.TagCustom; - -import java.util.List; - -public interface ITagsService { - - List getAllList(); - - Tag insert(Tag tag); - - List findByDId(Integer id); - - List findByDiscussionIdlistId(List discussionIdLsit); - - List findByParentId(String tag); - - List getAllListDiscussions(); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/IUsersService.java b/src/main/java/com/yaoyuan/jiscuss/service/IUsersService.java deleted file mode 100644 index ae39169..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/IUsersService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.yaoyuan.jiscuss.service; - -import com.yaoyuan.jiscuss.entity.User; -import org.springframework.data.domain.Page; -import java.util.List; - -public interface IUsersService { - - List getAllList(); - - Page queryAllUsersList(int pageNum, int pageSize); - - //Cacheable - List getByUsernameIsLike(String name); - - //@Cacheable("myCache") - User findOne(Integer id); - - User insert(User user); - - void remove(Integer id); - - void deleteAll(); - - User getByUsername(String username); - - User checkByUsernameAndPassword(String username, String password); - - User update(User user, Integer id); -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/DiscussionsServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/DiscussionsServiceImpl.java deleted file mode 100644 index 6f5adcf..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/DiscussionsServiceImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.entity.Discussion; -import com.yaoyuan.jiscuss.repository.DiscussionsRepository; -import com.yaoyuan.jiscuss.service.IDiscussionsService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -import javax.transaction.Transactional; -import java.util.List; - -@Service -@Transactional -public class DiscussionsServiceImpl implements IDiscussionsService { - @Autowired - private DiscussionsRepository discussionsRepository; - - @Override - public List getAllList() { - return discussionsRepository.findAll(); - } - - @Override - public Discussion insert(Discussion discussion) { - - return discussionsRepository.save(discussion); - } - - @Override - public Discussion findOne(Integer id) { - Discussion discussion = new Discussion(); - discussion.setId(id); - return discussionsRepository.getOne(id); - } - - @Override - public Page queryAllDiscussionsList(Discussion discussion, int pageNum, int pageSize, String tag, String type) { - Sort sort = new Sort(Sort.Direction.DESC, "id"); - if (type.equals("hot")) { - sort = new Sort(Sort.Direction.DESC, "likeCount"); - } else if (type.equals("new")) { - sort = new Sort(Sort.Direction.DESC, "startTime"); - } - @SuppressWarnings("deprecation") - Pageable pageable = new PageRequest(pageNum, pageSize, sort); - //将匹配对象封装成Example对象 - Example example = Example.of(discussion); - if (null != tag && !"all".equals(tag)) { - Page pageList = discussionsRepository.findByQuery(tag, pageable); - return pageList; - } else { - Page pageList = discussionsRepository.findAll(example, pageable); - return pageList; - } - - - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/DiscussionsTagsServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/DiscussionsTagsServiceImpl.java deleted file mode 100644 index 6e40515..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/DiscussionsTagsServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.entity.DiscussionTag; -import com.yaoyuan.jiscuss.repository.DiscussionsTagsRepository; -import com.yaoyuan.jiscuss.service.IDiscussionsTagsService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.transaction.Transactional; -import java.util.List; - -@Service -@Transactional -public class DiscussionsTagsServiceImpl implements IDiscussionsTagsService { - - @Autowired - private DiscussionsTagsRepository discussionsTagsRepository; - - @Override - public List getAllList() { - return discussionsTagsRepository.findAll(); - } - - @Override - public DiscussionTag insert(DiscussionTag discussionTag) { - return discussionsTagsRepository.save(discussionTag); - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java deleted file mode 100644 index bbe4582..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.common.Node; -import com.yaoyuan.jiscuss.common.PostCommonUtil; -import com.yaoyuan.jiscuss.entity.Post; -import com.yaoyuan.jiscuss.entity.custom.PostCustom; -import com.yaoyuan.jiscuss.repository.PostsRepository; -import com.yaoyuan.jiscuss.service.IPostsService; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Example; -import org.springframework.stereotype.Service; - -import javax.transaction.Transactional; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -@Service -@Transactional -public class PostsServiceImpl implements IPostsService { - - @Autowired - private PostsRepository postsRepository; - - @Override - public List getAllList() { - return postsRepository.findAll(); - } - - @Override - public List findOneBy(Integer id) { - List posts = postsRepository.findOneBy(id); - return posts; - } - - @Override - public Post findOneByid(Integer id) { - Post post = new Post(); - post.setId(id); - Example example = Example.of(post); - Optional postRes = postsRepository.findOne(example); - return postRes.get(); - } - - @Override - public List findPostCustomById(Integer id) { - //查询id为1且parentId为null的评论 - List> firstposts = postsRepository.findAllByDIdAndparentIdNull(id); - List firstpostCustomList = PostCommonUtil.getNewPostsObjMap(firstposts); -// List firstpostCustomListNew = PostCommonUtil.getNewPostsObjCustom(firstpostCustomList); - - //查询id为1且parentId不为null的评论 - List> thenposts = postsRepository.findAllByDIdAndparentIdNotNull(id); - List thenpostCustomList = PostCommonUtil.getNewPostsObjMap(thenposts); - -// List thenpostCustomListNew = PostCommonUtil.getNewPostsObjCustom(thenpostCustomList); - //新建一个Node集合。 - ArrayList nodes = new ArrayList<>(); - //将第一层评论都添加都Node集合中 - for (PostCustom post : firstpostCustomList) { - Node node = new Node(); - BeanUtils.copyProperties(post, node); - nodes.add(node); - } - //将回复添加到对应的位置 - List list = Node.addAllNode(nodes, thenpostCustomList); - System.out.println(); - //打印回复链表 - Node.show(list); - -// List> posts = postsRepository.findPostCustomById(id); -// List postCustomList = PostCommonUtil.getNewPostsObjMap(posts); -// List postCustomListNew = PostCommonUtil.getNewPostsObjCustom(postCustomList); - return list; - } - - @Override - public Post insert(Post post) { - return postsRepository.save(post); - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/SettingsServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/SettingsServiceImpl.java deleted file mode 100644 index eb67906..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/SettingsServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.entity.Setting; -import com.yaoyuan.jiscuss.repository.SettingsRepository; -import com.yaoyuan.jiscuss.service.ISettingsService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.transaction.Transactional; -import java.util.List; - -@Service -@Transactional -public class SettingsServiceImpl implements ISettingsService { - @Autowired - private SettingsRepository settingsRepository; - - @Override - public List getAllList() { - return settingsRepository.findAll(); - } - - @Override - public Setting insert(Setting setting) { - return settingsRepository.save(setting); - } -} diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/TagsServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/TagsServiceImpl.java deleted file mode 100644 index c340f79..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/TagsServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.entity.Tag; -import com.yaoyuan.jiscuss.entity.custom.TagCustom; -import com.yaoyuan.jiscuss.repository.TagsRepository; -import com.yaoyuan.jiscuss.service.ITagsService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.transaction.Transactional; -import java.util.List; - -@Service -@Transactional -public class TagsServiceImpl implements ITagsService { - @Autowired - private TagsRepository tagsRepository; - - @Override - public List getAllList() { - return tagsRepository.findAllIsNull(); - } - - @Override - public List getAllListDiscussions() { - return tagsRepository.findAll(); - } - - @Override - public Tag insert(Tag tag) { - return tagsRepository.save(tag); - } - - @Override - public List findByDId(Integer id) { - return tagsRepository.findByDId(id); - } - - @Override - public List findByDiscussionIdlistId(List discussionIdLsit) { - return tagsRepository.findByDiscussionIdlistId(discussionIdLsit); - } - - @Override - public List findByParentId(String tag) { - int tagId = Integer.parseInt(tag); - return tagsRepository.findByParentId(tagId); - } -} - - diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/UserDetailServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/UserDetailServiceImpl.java deleted file mode 100644 index c5cc22a..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/UserDetailServiceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.entity.User; -import com.yaoyuan.jiscuss.entity.UserInfo; -import com.yaoyuan.jiscuss.service.IUsersService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author yaoyuan2.chu - * @Title: - * @Package com.yaoyuan.jiscuss.service.impl - * @Description: - * @date 2020/7/15 16:34 - */ -@Component -public class UserDetailServiceImpl implements UserDetailsService { - @Autowired - private IUsersService userInfoService; - - /** - * 需新建配置类注册一个指定的加密方式Bean,或在下一步Security配置类中注册指定 - */ - @Autowired - private PasswordEncoder passwordEncoder; - - @Override - public UserInfo loadUserByUsername(String username) throws UsernameNotFoundException { - // 通过用户名从数据库获取用户信息 - User userInfo = userInfoService.getByUsername(username); - if (userInfo == null) { - throw new UsernameNotFoundException("用户不存在"); - } - - // 得到用户角色 - String role = "admin"; - - // 角色集合 - List authorities = new ArrayList<>(); - // 角色必须以`ROLE_`开头,数据库中没有,则在这里加 - authorities.add(new SimpleGrantedAuthority("ROLE_" + role)); - - return new UserInfo( - authorities, - userInfo.getId(), - // 因为数据库是明文,所以这里需加密密码 - passwordEncoder.encode(userInfo.getPassword()), - userInfo.getUsername(), - userInfo.getPhone() - ); - } -} \ No newline at end of file diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/UsersServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/UsersServiceImpl.java deleted file mode 100644 index d5120ec..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/UsersServiceImpl.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.yaoyuan.jiscuss.service.impl; - -import com.yaoyuan.jiscuss.entity.User; -import com.yaoyuan.jiscuss.repository.UsersRepository; -import com.yaoyuan.jiscuss.service.IUsersService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -import javax.transaction.Transactional; -import java.util.List; - -@Service -@Transactional -public class UsersServiceImpl implements IUsersService { - - @Autowired - private UsersRepository usersRepository; - - /** - * 获取全部用户 - * - * @return - */ - @Cacheable(value = "user") - @Override - public List getAllList() { - return usersRepository.findAll(); - } - - /** - * 分页查询 - * - * @param pageNum - * @param pageSize - * @return - */ - @Override - public Page queryAllUsersList(int pageNum, int pageSize) { - Sort sort = new Sort(Sort.Direction.DESC, "id"); - @SuppressWarnings("deprecation") - Pageable pageable = new PageRequest(pageNum, pageSize, sort); - return usersRepository.findAll(pageable); - } - - /** - * 根据名称模糊查询 - * - * @param name - * @return - */ - @Override - public List getByUsernameIsLike(String name) { - return usersRepository.getByUsernameIsLike(name); - } - - /** - * 根据id查询 - * - * @param id - * @return - */ - @Cacheable(value = "user", key = "#id") - @Override - public User findOne(Integer id) { - return usersRepository.getById(id); - } - - /** - * 新增 - * - * @param user - * @return - */ - @CachePut(value = "user", key = "#user.id") - @Override - public User insert(User user) { - return usersRepository.save(user); - } - - /** - * 更新修改 - * - * @param user - * @param id - * @return - */ - @CachePut(value = "user", key = "#user.id") - @Override - public User update(User user, Integer id) { - return usersRepository.saveAndFlush(user); - } - - /** - * 移除 - * - * @param id - */ - @CacheEvict(value = "user", key = "#id") - @Override - public void remove(Integer id) { - usersRepository.deleteById(id); - } - - /** - * 删除所有 - * - */ - @Override - public void deleteAll() { - usersRepository.deleteAll(); - } - - /** - * 根据名称查询 - * - * @param username - * @return - */ - @Override - public User getByUsername(String username) { - return usersRepository.getByUsername(username); - } - - /** - * 验证用户名密码 - * - * @param username - * @param password - * @return - */ - @Override - public User checkByUsernameAndPassword(String username, String password) { - return usersRepository.checkByUsernameAndPassword(username, password); - } - - -} - diff --git a/src/main/java/com/yaoyuan/jiscuss/util/DelTagsUtil.java b/src/main/java/com/yaoyuan/jiscuss/util/DelTagsUtil.java deleted file mode 100644 index 78bc33f..0000000 --- a/src/main/java/com/yaoyuan/jiscuss/util/DelTagsUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.yaoyuan.jiscuss.util; - -/** - * @author yaoyuan2.chu - * @Title: 去除内容页代码里的HTML标签 - * @Package com.yaoyuan.jiscuss.util - * @Description: - * @date 2020/8/31 20:52 - */ -public class DelTagsUtil { - /** - * 去除html代码中含有的标签 - * - * @param htmlStr - * @return - */ - public static String delHtmlTags(String htmlStr) { - //定义script的正则表达式,去除js可以防止注入 - String scriptRegex = " - -<#--semantic-ui--> - -<#-- --> - - -<#-- -<#-- href="https://lib.baomitu.com/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet">--> - -<#----> - -<#--tinymce--> - - - -<#--layx--> - - - - - - - - diff --git a/src/main/resources/templates/admin/home.ftl b/src/main/resources/templates/admin/home.ftl deleted file mode 100644 index 161dc18..0000000 --- a/src/main/resources/templates/admin/home.ftl +++ /dev/null @@ -1,338 +0,0 @@ - - -后台管理首页 - - - - - <#--jquery--> - - - <#--semantic-ui--> - - - - - - <#--tinymce--> - - - - <#--layx--> - - - - - - - - - - - - - - Jiscuss后台管理 - - - - - 常用管理 设置 - 用户 主题 注销 - - - - - - Project Name - - - - - - - - - Dashboard Settings - Profile Help - - - - - - - - - - - 常用管理 设置 - - 用户 主题 - - Jiscuss文档 - 返回首页 - - - - - - Dashboard - - - - - Label - Something else - - - - Label - Something else - - - - Label - Something else - - - - Label - Something else - - - - - Section title - - - - - - # - Header - Header - Header - Header - - - - - 1,001 - Lorem - ipsum - dolor - sit - - - 1,002 - amet - consectetur - adipiscing - elit - - - 1,003 - Integer - nec - odio - Praesent - - - 1,003 - libero - Sed - cursus - ante - - - 1,004 - dapibus - diam - Sed - nisi - - - 1,005 - Nulla - quis - sem - at - - - 1,006 - nibh - elementum - imperdiet - Duis - - - 1,007 - sagittis - ipsum - Praesent - mauris - - - 1,008 - Fusce - nec - tellus - sed - - - 1,009 - augue - semper - porta - Mauris - - - 1,010 - massa - Vestibulum - lacinia - arcu - - - 1,011 - eget - nulla - Class - aptent - - - 1,012 - taciti - sociosqu - ad - litora - - - 1,013 - torquent - per - conubia - nostra - - - 1,014 - per - inceptos - himenaeos - Curabitur - - - 1,015 - sodales - ligula - in - libero - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/admin/login.ftl b/src/main/resources/templates/admin/login.ftl deleted file mode 100644 index 67849a7..0000000 --- a/src/main/resources/templates/admin/login.ftl +++ /dev/null @@ -1,38 +0,0 @@ - - - - - 后台管理登录页 - - - - -后台管理登录页 - - 用户名: - 密 码: - - - 登录 - - - - - - diff --git a/src/main/resources/templates/comm/commjs.ftl b/src/main/resources/templates/comm/commjs.ftl deleted file mode 100644 index 0dff638..0000000 --- a/src/main/resources/templates/comm/commjs.ftl +++ /dev/null @@ -1,29 +0,0 @@ -<#--jquery--> - - -<#--semantic-ui--> - -<#-- --> - - -<#-- -<#-- href="https://lib.baomitu.com/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet">--> - -<#----> - -<#--tinymce--> - - - -<#--layx--> - - - - - - - - diff --git a/src/main/resources/templates/comm/footer.ftl b/src/main/resources/templates/comm/footer.ftl deleted file mode 100644 index 228d316..0000000 --- a/src/main/resources/templates/comm/footer.ftl +++ /dev/null @@ -1,48 +0,0 @@ -<#----> - - - diff --git a/src/main/resources/templates/comm/header.ftl b/src/main/resources/templates/comm/header.ftl deleted file mode 100644 index 2bbedba..0000000 --- a/src/main/resources/templates/comm/header.ftl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Jiscuss - - 首页 - 论坛 - - 更多 - - - 用户页 - - 分割链接 - - 后台管理 - - - - - - - - - - - <#if username??> - - - - ${username} 注销 - <#else> - 登录 & 注册 - #if> - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/comm/page.ftl b/src/main/resources/templates/comm/page.ftl deleted file mode 100644 index 1a52993..0000000 --- a/src/main/resources/templates/comm/page.ftl +++ /dev/null @@ -1,76 +0,0 @@ -<#-- - 参数解释: - page:当前页码,从1开始 - pagesize:分页大小 - totalpages:总页数。也可以放到模板里计算。这里在MyPager类里已计算过了。 - totalrecords:总记录数 - url:链接地址,自动拼接page参数。为了简单,没有判断当前页面是否有get参数了,直接做了&连接,默认认为原来就有参数。当前你也可以用servlet自己获取当前url及参数,就不用传了。 - - 以上这些参数除url外均可以从MyPager实例中获取。其实可以直接把mypager实例传进来,为了便于以后扩展,分字段传过来。 ---> -<#macro fpage page pagesize totalpages totalrecords url> - - - -<#-- 共条${totalrecords}记录 第${page}页/共${totalpages}页--> - 共条${totalrecords}记录 第${page}页/共${totalpages}页 - -<#--startpage:起始页码就是page,endpage:结束页码,showfirstpage是否显示首页按钮,showlastpage:是否显示末页按钮,showpre是否显示前...,shownext是否显示后...--> - <#assign startpage = page,endpage=10,showfirstpage=false,showlastpage=false,showpre=false,shownext=false,prepage = 1,nextpage=11> -<#--是否显示首页按钮及计算初始页码--> - <#if page gt 1> - <#assign showfirstpage = true> - <#--startpage向前挪4页,如果不足4页,则startpage=1--> - <#assign startpage=(page-4)> - <#if startpage lte 0> - <#assign startpage = 1> - #if> - #if> -<#--是否显示前n页的...,以及...的链接--> - <#if page gt 5> - <#assign showpre = true,prepage=page-5> - #if> -<#--计算endpage--> - <#if page+pagesize-1 lt totalpages> - <#assign endpage = page+pagesize-1> - <#--显示后面的...按钮--> - <#assign shownext = true> - <#--后面...的页面码--> - <#assign nextpage=page+pagesize> - <#--显示末页--> - <#assign showlastpage = true> - <#else> - <#assign endpage = totalpages> - #if> - <#if endpage lte 0> - <#assign endpage = 1> - #if> - -<#--开始展示--> - -<#--首页--> - <#if showfirstpage> - <#-- 首页--> - 首页 - #if> -<#--前面的...--> - <#if showpre> - <#-- ...--> - ... - #if> -<#--显示的页码按钮--> - <#list startpage..endpage as p> - <#-- ${p}--> - ${p} - #list> -<#--后面的...--> - <#if shownext> - <#-- ...--> - ... - #if> -<#--显示尾页--> - <#if showlastpage> - <#-- 末页--> - 末页 - #if> -#macro> \ No newline at end of file diff --git a/src/main/resources/templates/discussions.ftl b/src/main/resources/templates/discussions.ftl deleted file mode 100644 index 83253c6..0000000 --- a/src/main/resources/templates/discussions.ftl +++ /dev/null @@ -1,308 +0,0 @@ - - -主题详情页 - - - - - - - - - <#include "comm/commjs.ftl"/> - - -<#include "comm/header.ftl"/> - - - - - 欢迎来到这里 - - JAVA + DISCUSS = JISCUSS 。 - 简单的,易用的JAVA论坛。 - 请享受发帖回帖带来的乐趣吧! - - - - - - - - - - - ${discussions.title} - <#list tags as tag> - ${tag.name} - #list> - - - - - - ${discussions.content} - - - - - 赞这个主题 - - - 1,048 - - - - - - - - - - - - 用户 ${discussions.realname} 发布于 - - ${discussions.startTime} - - - - - - - - - - - - - 用户 ${discussions.realnameLast} 最后回复于 - - ${discussions.lastTime} - - - - - - - - 评论区 - - - - <#macro bpTree posts> - <#if posts?? && posts?size gt 0> - - <#list posts as post> - <#if post.nextNodes?? && post.nextNodes?size gt 0> - - - - - - - ${post.username} - - ${post.createTime} - - - ${post.content} - - - 回复 - - - - <@bpTree posts=post.nextNodes /> - - - <#else> - - - - - - - ${post.username} - - ${post.createTime} - - - ${post.content} - - - 回复 - - - - #if> - #list> - #if> - #macro> - <@bpTree posts=posts /> - - - - - - - - - - 添加评论 - - - - - - - - - - - 搜索 - - - - - - - 作者 - - - 测试人员1 - - - - - Jiscuss 一直, Jiscuss 一感谢支持! - - - - - - - - 2019 测试内容 - - - - - - - 预留按钮 - - - - - - 作者热门主题 - - - - - - - its here - - - - - - 他的测试主题2 - - - - - - 他的测试主题3 - - - - - - 预留信息 - - - - - - - - Jiscuss Demo - 简单、易用、开源 - 一款基于JAVA的开源论坛 框架采用:Spring Boot + H2 - + Semantic UI - - - - - - - 1 - 用户数 - - - - - 10 - 发帖数 - - - - - - - - - - - - Jiscuss手机可见,内容正在编写中,pc端可正常访问 - - - - - - 1 - - - 2 - - - ... - - - 10 - - - 11 - - - - - - - - - - - -<#include "comm/footer.ftl"/> - - - - - - diff --git a/src/main/resources/templates/index.ftl b/src/main/resources/templates/index.ftl deleted file mode 100644 index 6845ee7..0000000 --- a/src/main/resources/templates/index.ftl +++ /dev/null @@ -1,558 +0,0 @@ - - -Jiscuss Demo - - - - - - <#include "comm/commjs.ftl"/> - - - -<#include "comm/header.ftl"/> - - - - - 欢迎来到这里,${data} ,当前页主题数: ${allDiscussions?size} ,主题页数:${pageDiscussions?size} - ,标签数 ${allTags?size} - - JAVA + DISCUSS = JISCUSS 。 - 简单的,易用的JAVA论坛。 - 请享受发帖回帖带来的乐趣吧! - - - - - - - - - - 创建新帖 - - - 您是最棒的 - - - - - - - 创建新帖 - - - - - - 标题 - - - - 选择标签 - - 选择标签 - <#list allTags as tags> - ${tags.name} - #list> - - - - - <#-- 新增标签--> - <#-- 登录 & 注册--> - 新增标签 - - - - 标签名 - - - - - 描述 - - - - 父标签 - - <#list allTags as tag> - {tag.name} - #list> - - - - - - 选择颜色 - - - - 选择颜色 - - - - 红色 - - - - 橙色 - - - - 黄色 - - - - 橄榄绿 - - - - 纯绿 - - - - 水鸭蓝 - - - - 纯蓝 - - - - 紫罗兰 - - - - 纯紫 - - - - 粉红 - - - - 棕色 - - - - 灰色 - - - - 黑色 - - - - - - 选择图标 - - - - 选择图标 - - bullhorn - coffee - edit - fax - bug - keyboard - folder open outline - - comment - outline - - - - - - - 保存 - 取消 - - - - 内容 - - - - 提交内容 - - - - - <#-- --> - - - - 全部标签 - - - - <#list allTags as tags> - - - - ${tags.name} - ${tags.description} - - - - <#list allChildTags as childTags> - <#if childTags.parentId == tags.id> - - - - ${childTags.name} - ${childTags.description} - - - #if> - #list> - - - - - - - #list> - - - - - - - - 预留功能 - - - Jiscuss - - - - - Jiscuss 会持续更新, Jiscuss 将一直更新完善,感谢支持! - - - - - - - - 2019 测试内容 - - - - - - - 预留按钮 - - - - - - - - Jiscuss Demo - 简单、易用、开源 - 一款基于JAVA的开源论坛 框架采用:Spring Boot + H2 - + Semantic UI - - - - - - - ${allUser?size} - 用户数 - - - - - ${allDiscussions?size} - 发帖数 - - - - - - - - - - - - - - <#if username??> - - - 最新回复 - 1 - - 热门 - 新帖 - <#else> - - 最新回复 - 1 - - 热门 - 新帖 - #if> - - - - - <#list allDiscussions as discussions> - - - - - - - - ${discussions.title} - - - - ${discussions.startTime} - - - <#list discussions.tagList as tags> - - ${tags.name} - - #list> - - - - ${discussions.content} - - - - ${discussions.username} • - 最后由 ${discussions.usernameLast} - 回复于${discussions.lastTime}. - - - - - ${discussions.likeCount} 喜欢 - - - ${discussions.commentsCount} 回复 - - - - - - #list> - - - - - - <#list allDiscussions as discussions> - - - - - - - - ${discussions.title} - - - - ${discussions.startTime} - - - <#list discussions.tagList as tags> - - ${tags.name} - - #list> - - - - ${discussions.content} - - - - ${discussions.username} • - 最后由 ${discussions.usernameLast} - 回复于${discussions.lastTime}. - - - - - ${discussions.likeCount} 喜欢 - - - ${discussions.commentsCount} 回复 - - - - - - #list> - - - - - <#list allDiscussions as discussions> - - - - - - - - ${discussions.title} - - - - ${discussions.startTime} - - - <#list discussions.tagList as tags> - - ${tags.name} - - #list> - - - - ${discussions.content} - - - - ${discussions.username} • - 最后由 ${discussions.usernameLast} - 回复于${discussions.lastTime}. - - - - - ${discussions.likeCount} 喜欢 - - - ${discussions.commentsCount} 回复 - - - - - - #list> - - - - - - - - - - <#list pageDiscussions as page> - <#if page == pageNum && !(username)??> - - ${page} - - #if> - <#if page != pageNum && !(username)??> - - ${page} - - #if> - <#if page == pageNum && username??> - - ${page} - - #if> - <#if page != pageNum && username??> - - ${page} - - #if> - #list> - - - - - <#-- - - <#import "./comm/page.ftl" as page /> - <@page.fpage page=pageNum pagesize=pageSize totalpages=pageTotalPages totalrecords=pageTotal url="/" /> - - --> - - - - - Jiscuss手机可见,内容正在编写中,pc端可正常访问 - - - - - - 1 - - - 2 - - - ... - - - 10 - - - 11 - - - - - - - - - - -<#include "comm/footer.ftl"/> - - - - - - diff --git a/src/main/resources/templates/login.ftl b/src/main/resources/templates/login.ftl deleted file mode 100644 index ad0c2a3..0000000 --- a/src/main/resources/templates/login.ftl +++ /dev/null @@ -1,79 +0,0 @@ - - -Jiscuss Demo - - <#include "comm/commjs.ftl"/> - - - - - - - - - - 登录到账号 - - - - - - - - - - - - - - - - - - - - ${msg} - - - - 登 录 - - - - - - - - <——Jiscuss首页 新用户? 注册 - - - - - - - diff --git a/src/main/resources/templates/newdiccuss.ftl b/src/main/resources/templates/newdiccuss.ftl deleted file mode 100644 index 415b8c1..0000000 --- a/src/main/resources/templates/newdiccuss.ftl +++ /dev/null @@ -1,118 +0,0 @@ - - -新建主题页 - - - - - - - - <#include "comm/commjs.ftl"/> - - - - - - - - 标题 - - - - 选择标签 - - 选择标签 - <#list allTags as tag> - ${tag.name} - #list> - - - - 新增标签 - - - - 内容 - - - - 提交内容 - - - - - - - - - - - diff --git a/src/main/resources/templates/newtag.ftl b/src/main/resources/templates/newtag.ftl deleted file mode 100644 index e8ed3f8..0000000 --- a/src/main/resources/templates/newtag.ftl +++ /dev/null @@ -1,204 +0,0 @@ - - -新建标签页 - - - - - - - - - <#include "comm/commjs.ftl"/> - - - - - - - - - 标签名 - - - - - 描述 - - - - 父标签 - - 选择父标签 - <#list allTags as tag> - ${tag.name} - #list> - - - - - - 选择颜色 - - - - 选择颜色 - - - - 红色 - - - - 橙色 - - - - 黄色 - - - - 橄榄绿 - - - - 纯绿 - - - - 水鸭蓝 - - - - 纯蓝 - - - - 紫罗兰 - - - - 纯紫 - - - - 粉红 - - - - 棕色 - - - - 灰色 - - - - 黑色 - - - - - - 选择图标 - - - - 选择图标 - - bullhorn - coffee - edit - fax - bug - keyboard - folder - open outline - - comment - outline - - - - - - - 保存 - 取消 - - - - - - - - - - - - - diff --git a/src/main/resources/templates/register.ftl b/src/main/resources/templates/register.ftl deleted file mode 100644 index 7d35397..0000000 --- a/src/main/resources/templates/register.ftl +++ /dev/null @@ -1,94 +0,0 @@ - - -Jiscuss Demo - - <#include "comm/commjs.ftl"/> - - - - - - - - - - - 注册账号 - - - - - - - 用户名 - - - - 邮箱地址 - - - - 密码 - - - - 确认密码 - - - - - - - 我同意Jiscuss条款 - - - - - - ${msg} - - - - 注册 - - - - - - - - <——Jiscuss首页 已有用户? 登陆 - - - - - - - diff --git a/src/main/resources/templates/user.ftl b/src/main/resources/templates/user.ftl deleted file mode 100644 index a1c700f..0000000 --- a/src/main/resources/templates/user.ftl +++ /dev/null @@ -1,118 +0,0 @@ - - -用户详情页 - - - - - - - <#include "comm/commjs.ftl"/> - - -<#include "comm/header.ftl"/> - - - ${username}的个人主页 - - 详情 - - - <#-- --> - - - - - 主题 - 动态 - 喜欢收藏 - - - - 主题... - - - 动态... - - - 喜欢收藏... - - - - - - - - - - Matt Giampietro - - Friends - - - Matthew is an interior designer living in New York. - - - - - Joined in 2013 - - - - 75 Friends - - - - - - - - - - - 小按钮·点下试试 - - - - - - - -<#include "comm/footer.ftl"/> - -<#-- --> - - <#-- --> - - - - 主题 - - - - 动态 - - - - 喜欢收藏 - - - - - - -
Something else
预留信息