0314提交
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.yaoyuan.jiscuss;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class JiccussApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(JiccussApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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 {
|
||||
|
||||
|
||||
@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/");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 后台系统控制器
|
||||
*/
|
||||
@Controller
|
||||
public class AdminSystemController {
|
||||
|
||||
//后台登录
|
||||
|
||||
//后台退出
|
||||
|
||||
//后台设置管理
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.yaoyuan.jiscuss.entity.Discussions;
|
||||
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;
|
||||
|
||||
@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 Discussions save(@RequestBody Discussions discussions) {
|
||||
Discussions saveDiscussions = discussionsService.insert(discussions);
|
||||
if (saveDiscussions!=null) {
|
||||
return saveDiscussions;
|
||||
} else {
|
||||
throw new BaseException(ResponseCode.RESOURCES_NOT_EXIST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/discussion/{id}")
|
||||
@ApiOperation("获取主题")
|
||||
public Discussions getDiscussions(@PathVariable Integer id) {
|
||||
Discussions discussions = discussionsService.findOne(id);
|
||||
return discussions;
|
||||
}
|
||||
|
||||
@GetMapping("/discussions")
|
||||
@ApiOperation("获取全部主题")
|
||||
public List<Discussions> getAllDiscussions() {
|
||||
List<Discussions> allDiscussions = discussionsService.getAllList();
|
||||
logger.info("全部主题==>:{}",allDiscussions);
|
||||
return allDiscussions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Staff;
|
||||
import com.yaoyuan.jiscuss.exception.Error;
|
||||
import com.yaoyuan.jiscuss.exception.StaffNotFoundException;
|
||||
import com.yaoyuan.jiscuss.service.IStaffService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path="/staffRest",produces="application/json;charset=utf-8")
|
||||
public class RestServiceController {
|
||||
@Autowired
|
||||
private IStaffService staffService;
|
||||
|
||||
@ExceptionHandler(StaffNotFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public Error staffNotFound(StaffNotFoundException e){
|
||||
Integer id=e.getStaffId();
|
||||
return new Error(4,"Staff ["+id+"] not found");
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Staff staffById(@PathVariable Integer id){
|
||||
Staff staff=staffService.findOne(id);
|
||||
if(staff==null){
|
||||
throw new StaffNotFoundException(id);
|
||||
}
|
||||
return staff;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<Staff> getAllStaffs(){
|
||||
return staffService.getAllList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Staff createStaff(Staff staff){
|
||||
return staffService.insert(staff);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Staff updateStaff(Staff staff){
|
||||
return staffService.insert(staff);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public Staff deleteStaffById(@PathVariable Integer id){
|
||||
Staff staff=staffService.findOne(id);
|
||||
if(staff==null){
|
||||
throw new StaffNotFoundException(id);
|
||||
}
|
||||
staffService.remove(id);
|
||||
return staff;
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public List<Staff> deleteAllStaffs(){
|
||||
List<Staff> staffList=staffService.getAllList();
|
||||
staffService.deleteAll();
|
||||
return staffList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.yaoyuan.jiscuss.entity.Users;
|
||||
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;
|
||||
|
||||
@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 Users save(@RequestBody Users user) {
|
||||
Users 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 Users update(@RequestBody Users user, @PathVariable Integer id) {
|
||||
Users updateuser = usersService.update(user, id);
|
||||
if (updateuser!=null) {
|
||||
return updateuser;
|
||||
} else {
|
||||
throw new BaseException(ResponseCode.RESOURCES_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/user/{id}")
|
||||
@ApiOperation("获取用户")
|
||||
public Users getUser(@PathVariable Integer id) {
|
||||
Users user = usersService.findOne(id);
|
||||
return user;
|
||||
}
|
||||
|
||||
@GetMapping("/user")
|
||||
@ApiOperation("获取全部用户")
|
||||
public List<Users> getUser(Users user) {
|
||||
List<Users> userall = usersService.getAllList();
|
||||
logger.info("全部用户==>:{}",userall);
|
||||
return userall;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class TestController {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 登录页面跳转
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("loginpage")
|
||||
public String loginpage() {
|
||||
return "login";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/world")
|
||||
|
||||
public String world(Map<String, Object> model) {
|
||||
model.put("data","2019");
|
||||
// request.setAttribute("name", "xxxxxxxxx");
|
||||
model.put("msg", "xxxxxxx2222xx");
|
||||
return "world";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 用户消息控制器
|
||||
*/
|
||||
@Controller
|
||||
public class UserMsgController {
|
||||
//首页最新消息
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 其他控制器——积分/权限等
|
||||
*/
|
||||
@Controller
|
||||
public class UserOtherController {
|
||||
|
||||
//用户积分获取
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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 com.yaoyuan.jiscuss.entity.Discussions;
|
||||
import com.yaoyuan.jiscuss.entity.Tags;
|
||||
import com.yaoyuan.jiscuss.service.IDiscussionsService;
|
||||
import com.yaoyuan.jiscuss.service.ITagsService;
|
||||
|
||||
/**
|
||||
* 主题帖子评论控制器
|
||||
*/
|
||||
@Controller
|
||||
public class UserPostController {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UserPostController.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private IDiscussionsService discussionsService;
|
||||
|
||||
@Autowired
|
||||
private ITagsService tagsService;
|
||||
|
||||
|
||||
|
||||
//首页查看主题列表(各种条件筛选,最热最新标签等)
|
||||
|
||||
|
||||
|
||||
//查看主题详情
|
||||
@RequestMapping("/getdiscussionsbyid")
|
||||
public String getDiscussionsById(HttpServletRequest request,Map<String, Object> map,@RequestParam("id") Integer id) {
|
||||
logger.info(">>> getDiscussionsById{}",id);
|
||||
|
||||
Discussions discussions = discussionsService.findOne(id);
|
||||
HttpSession session=request.getSession();
|
||||
map.put("discussions", discussions);
|
||||
map.put("username", session.getAttribute("username"));
|
||||
return "discussions";
|
||||
}
|
||||
|
||||
|
||||
//新建主题
|
||||
@PostMapping(value = "/newdiscussions")
|
||||
@ResponseBody
|
||||
public String newDiscussions(@RequestBody Discussions discussions) {
|
||||
logger.info(">>> newPost"+discussions);
|
||||
|
||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
|
||||
HttpSession session=request.getSession();
|
||||
discussions.setLast_user_id( (Integer)session.getAttribute("userid"));
|
||||
discussions.setCreate_id( (Integer)session.getAttribute("userid"));
|
||||
discussions.setCreate_time(new Date());
|
||||
|
||||
Discussions saveDiscussions = discussionsService.insert(discussions);
|
||||
JSONObject resultobj = new JSONObject();
|
||||
|
||||
logger.info(">>>{}",saveDiscussions );
|
||||
resultobj.put("msg", "添加成功");
|
||||
resultobj.put("flag", true);
|
||||
return resultobj.toString(); //
|
||||
|
||||
}
|
||||
|
||||
|
||||
//编辑主题
|
||||
|
||||
//删除主题
|
||||
|
||||
//新建评论
|
||||
|
||||
//删除评论
|
||||
|
||||
//新建标签
|
||||
@PostMapping(value = "/newtags")
|
||||
@ResponseBody
|
||||
public String newTags(@RequestBody Tags tags) {
|
||||
logger.info(">>> newTags"+tags);
|
||||
|
||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
|
||||
HttpSession session=request.getSession();
|
||||
tags.setCreate_id( (Integer)session.getAttribute("userid"));
|
||||
tags.setCreate_time(new Date());
|
||||
|
||||
Tags saveTags = tagsService.insert(tags);
|
||||
JSONObject resultobj = new JSONObject();
|
||||
|
||||
logger.info(">>>{}",saveTags );
|
||||
resultobj.put("msg", "添加成功");
|
||||
resultobj.put("flag", true);
|
||||
return resultobj.toString(); //
|
||||
|
||||
}
|
||||
|
||||
//排行榜等
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.yaoyuan.jiscuss.controller;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Discussions;
|
||||
import com.yaoyuan.jiscuss.entity.Tags;
|
||||
import com.yaoyuan.jiscuss.entity.Users;
|
||||
import com.yaoyuan.jiscuss.service.IDiscussionsService;
|
||||
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.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户页面系统控制器
|
||||
*/
|
||||
@Controller
|
||||
public class UserSystemController {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UserSystemController.class);
|
||||
|
||||
@Autowired
|
||||
private IUsersService usersService;
|
||||
|
||||
@Autowired
|
||||
private IDiscussionsService discussionsService;
|
||||
|
||||
@Autowired
|
||||
private ITagsService tagsService;
|
||||
|
||||
//首页
|
||||
@RequestMapping("/")
|
||||
public String home(HttpServletRequest request,Map<String, Object> map) {
|
||||
logger.info(">>> index");
|
||||
List<Users> userall = usersService.getAllList();
|
||||
logger.info(">>> 第一遍的全部用户:"+userall);
|
||||
|
||||
List<Users> useral2 = usersService.getAllList();
|
||||
logger.info(">>> 第二遍的全部用户:"+useral2);
|
||||
|
||||
//分页获取主题帖子
|
||||
// List<Discussions> allDiscussions = discussionsService.getAllList();
|
||||
|
||||
Page<Discussions> allDiscussionsPage = discussionsService.queryAllDiscussionsList(0,20);
|
||||
|
||||
List<Discussions> allDiscussions =allDiscussionsPage.getContent();
|
||||
|
||||
logger.info("全部主题==>:{}",allDiscussions);
|
||||
|
||||
//获取主题帖子的分页数据
|
||||
List<String> pageNumList = getPageNumList(allDiscussionsPage.getTotalPages());
|
||||
|
||||
|
||||
//获取所有标签(以后尝试去缓存中取)
|
||||
List<Tags> allTags = tagsService.getAllList();
|
||||
logger.info("全部标签==>:{}",allTags);
|
||||
|
||||
HttpSession session=request.getSession();
|
||||
System.out.println(userall.toString());
|
||||
map.put("data", "Jiscuss 用户");
|
||||
map.put("allDiscussions", allDiscussions);
|
||||
map.put("pageDiscussions", pageNumList);
|
||||
map.put("allTags", allTags);
|
||||
map.put("username", session.getAttribute("username"));
|
||||
return "index";
|
||||
}
|
||||
|
||||
|
||||
private List<String> getPageNumList(int size) {
|
||||
List<String> pageNumList = new ArrayList<String>();
|
||||
if(size>5) {
|
||||
pageNumList.add("1");
|
||||
pageNumList.add("2");
|
||||
pageNumList.add("...");
|
||||
pageNumList.add(""+(size-1));
|
||||
pageNumList.add(""+(size));
|
||||
|
||||
}else {
|
||||
for(int i = 0;i<size;i++) {
|
||||
pageNumList.add(""+(i+1));
|
||||
}
|
||||
}
|
||||
return pageNumList;
|
||||
}
|
||||
|
||||
|
||||
//登录
|
||||
@PostMapping(value = "/login")
|
||||
@ResponseBody
|
||||
public String login(@RequestParam("username") String username, @RequestParam("password") String password,
|
||||
HttpSession session) {
|
||||
JSONObject resultobj = new JSONObject();
|
||||
Users user = usersService.checkByUsernameAndPassword(username, password);
|
||||
if (user!=null) {
|
||||
//用户名和密码完成校验
|
||||
session.setAttribute("username", username); //缓存session
|
||||
session.setAttribute("userid", user.getId()); //缓存session
|
||||
resultobj.put("username", username);
|
||||
resultobj.put("msg", "登录成功");
|
||||
resultobj.put("flag", true);
|
||||
} else {
|
||||
//用户名和密码未完成校验
|
||||
resultobj.put("msg", "用户名或密码错误");
|
||||
resultobj.put("flag", false);
|
||||
}
|
||||
return resultobj.toString();
|
||||
}
|
||||
|
||||
//退出
|
||||
@PostMapping(value = "/loginout")
|
||||
@ResponseBody
|
||||
public String logout(HttpServletRequest request, HttpServletResponse response){
|
||||
JSONObject resultobj = new JSONObject();
|
||||
HttpSession session=request.getSession();
|
||||
session.invalidate();
|
||||
resultobj.put("msg", "用户退出成功");
|
||||
resultobj.put("flag", true);
|
||||
return resultobj.toString(); //
|
||||
}
|
||||
|
||||
//注册
|
||||
|
||||
//获取设置信息
|
||||
|
||||
//获取首页统计
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
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 lombok.Data;
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="discussions")
|
||||
public class Discussions 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 comments_count;
|
||||
|
||||
@Column(name="participants_count")
|
||||
private Integer participants_count;
|
||||
|
||||
@Column(name="number_index")
|
||||
private Integer number_index;
|
||||
|
||||
@Column(name="start_time")
|
||||
private Date start_time;
|
||||
|
||||
@Column(name="start_user_id")
|
||||
private Integer start_user_id;
|
||||
|
||||
@Column(name="start_post_id")
|
||||
private Integer start_post_id;
|
||||
|
||||
@Column(name="last_time")
|
||||
private Date last_time;
|
||||
|
||||
@Column(name="last_user_id")
|
||||
private Integer last_user_id;
|
||||
|
||||
@Column(name="last_post_id")
|
||||
private Integer last_post_id;
|
||||
|
||||
@Column(name="last_post_number")
|
||||
private Integer last_post_number;
|
||||
|
||||
@Column(name="is_approved")
|
||||
private Integer is_approved;
|
||||
|
||||
@Column(name="like_count")
|
||||
private Integer like_count;
|
||||
|
||||
|
||||
@Column(name="ip_address")
|
||||
private String ip_address;
|
||||
|
||||
@Column(name="create_id")
|
||||
private Integer create_id;
|
||||
|
||||
@Column(name="create_time")
|
||||
private Date create_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="discussionstags")
|
||||
public class DiscussionsTags implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column(name="discussion_id")
|
||||
private Integer discussion_id;
|
||||
|
||||
@Column(name="tag_id")
|
||||
private Integer tag_id;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
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 lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="posts")
|
||||
public class Posts implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name="discussion_id")
|
||||
private Integer discussion_id;
|
||||
|
||||
@Column(name="number")
|
||||
private Integer number;
|
||||
|
||||
@Column(name="time")
|
||||
private Date time;
|
||||
|
||||
@Column(name="user_id")
|
||||
private Integer user_id;
|
||||
|
||||
@Column(name="type")
|
||||
private String type;
|
||||
|
||||
@Column(name="content")
|
||||
private String content;
|
||||
|
||||
@Column(name="edit_time")
|
||||
private Date edit_time;
|
||||
|
||||
@Column(name="edit_user_id")
|
||||
private Integer edit_user_id;
|
||||
|
||||
@Column(name="ip_address")
|
||||
private String ip_address;
|
||||
|
||||
@Column(name="copyright")
|
||||
private String copyright;
|
||||
|
||||
@Column(name="is_approved")
|
||||
private Integer is_approved;
|
||||
|
||||
@Column(name="create_id")
|
||||
private Integer create_id;
|
||||
|
||||
@Column(name="create_time")
|
||||
private Date create_time;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="settings")
|
||||
public class Settings implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column(name="key")
|
||||
private String key;
|
||||
|
||||
@Column(name="value")
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
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 lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="staff")
|
||||
public class Staff implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="age")
|
||||
private Integer age;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
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 lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="tags")
|
||||
public class Tags 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="position")
|
||||
private Integer position;
|
||||
|
||||
@Column(name="parent_id")
|
||||
private Integer parent_id;
|
||||
|
||||
@Column(name="discussions_count")
|
||||
private String discussions_count;
|
||||
|
||||
@Column(name="last_time")
|
||||
private Date last_time;
|
||||
|
||||
@Column(name="last_discussion_id")
|
||||
private Integer last_discussion_id;
|
||||
|
||||
@Column(name="create_id")
|
||||
private Integer create_id;
|
||||
|
||||
@Column(name="create_time")
|
||||
private Date create_time;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.yaoyuan.jiscuss.entity;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
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 lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="users")
|
||||
public class Users 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 join_time;
|
||||
|
||||
@Column(name="age")
|
||||
private Integer age;
|
||||
|
||||
@Column(name="gender")
|
||||
private String gender;
|
||||
|
||||
@Column(name="phone")
|
||||
private String phone;
|
||||
|
||||
@Column(name="discussions_count")
|
||||
private Integer discussions_count;
|
||||
|
||||
@Column(name="comments_count")
|
||||
private Integer comments_count;
|
||||
|
||||
@Column(name="last_seen_time")
|
||||
private Date last_seen_time;
|
||||
|
||||
@Column(name="flag")
|
||||
private Integer flag;
|
||||
|
||||
@Column(name="level")
|
||||
private Integer level;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
|
||||
public BaseException(ResponseCode code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public BaseException(Throwable cause, ResponseCode code) {
|
||||
super(cause);
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yaoyuan.jiscuss.exception;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class Error {
|
||||
private int code;
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yaoyuan.jiscuss.exception;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class StaffNotFoundException extends RuntimeException {
|
||||
private Integer staffId;
|
||||
public StaffNotFoundException(Integer staffId){
|
||||
this.staffId=staffId;
|
||||
}
|
||||
public Integer getStaffId(){
|
||||
return staffId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Discussions;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DiscussionsRepository extends JpaRepository<Discussions,Integer> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.DiscussionsTags;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public interface DiscussionsTagsRepository extends JpaRepository<DiscussionsTags,Integer> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Posts;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PostsRepository extends JpaRepository<Posts,Integer> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Settings;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface SettingsRepository extends JpaRepository<Settings,Integer> {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.yaoyuan.jiscuss.entity.Staff;
|
||||
|
||||
@Repository
|
||||
public interface StaffRepository extends JpaRepository<Staff,Integer> {
|
||||
@Query("from Staff where name like %:name%")
|
||||
List<Staff> getByNameIsLike(@Param("name")String name);
|
||||
|
||||
Staff getById(Integer id);
|
||||
void deleteById(Integer id);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Tags;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TagsRepository extends JpaRepository<Tags,Integer> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.yaoyuan.jiscuss.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.yaoyuan.jiscuss.entity.Users;
|
||||
|
||||
|
||||
@Repository
|
||||
public interface UsersRepository extends JpaRepository<Users,Integer> {
|
||||
/**
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Query("from Users where username like %:username%")
|
||||
List<Users> getByUsernameIsLike(@Param("username")String username);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Users getById(Integer id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deleteById(Integer id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Query("from Users where username = :username")
|
||||
Users getByUsername(String username);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
@Query("from Users where username = :username and password = :password")
|
||||
Users checkByUsernameAndPassword(String username, String password);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yaoyuan.jiscuss.response;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一的公共响应体
|
||||
* @author NULL
|
||||
* @date 2019-12-16
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ResponseResult implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 返回状态码
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
private Object data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Discussions;
|
||||
|
||||
public interface IDiscussionsService {
|
||||
|
||||
List<Discussions> getAllList();
|
||||
|
||||
Discussions insert(Discussions discussions);
|
||||
|
||||
Discussions findOne(Integer id);
|
||||
|
||||
Page<Discussions> queryAllDiscussionsList(int pageNum,int pageSize);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.DiscussionsTags;
|
||||
|
||||
public interface IDiscussionsTagsService {
|
||||
|
||||
List<DiscussionsTags> getAllList();
|
||||
|
||||
DiscussionsTags insert(DiscussionsTags discussionsTags);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Posts;
|
||||
|
||||
public interface IPostsService {
|
||||
List<Posts> getAllList();
|
||||
|
||||
Posts insert(Posts posts);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Settings;
|
||||
|
||||
public interface ISettingsService {
|
||||
|
||||
List<Settings> getAllList();
|
||||
|
||||
Settings insert(Settings settings);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Staff;
|
||||
|
||||
public interface IStaffService {
|
||||
List<Staff> getAllList();
|
||||
Page<Staff> queryAllStaffList(int pageNum,int pageSize);
|
||||
List<Staff> getByNameIsLike(String name);
|
||||
|
||||
// @Cacheable("myCache")
|
||||
Staff findOne(Integer id);
|
||||
|
||||
|
||||
Staff insert(Staff staff);
|
||||
|
||||
|
||||
void remove(Integer id);
|
||||
|
||||
|
||||
void deleteAll();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Tags;
|
||||
|
||||
public interface ITagsService {
|
||||
|
||||
List<Tags> getAllList();
|
||||
|
||||
Tags insert(Tags tags);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yaoyuan.jiscuss.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Users;
|
||||
|
||||
public interface IUsersService {
|
||||
|
||||
List<Users> getAllList();
|
||||
|
||||
Page<Users> queryAllUsersList(int pageNum,int pageSize);
|
||||
|
||||
List<Users> getByUsernameIsLike(String name);
|
||||
|
||||
// @Cacheable("myCache")
|
||||
Users findOne(Integer id);
|
||||
|
||||
Users insert(Users user);
|
||||
|
||||
void remove(Integer id);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
Users getByUsername(String username);
|
||||
|
||||
Users checkByUsernameAndPassword(String username, String password);
|
||||
|
||||
Users update(Users user, Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 com.yaoyuan.jiscuss.entity.Discussions;
|
||||
import com.yaoyuan.jiscuss.repository.DiscussionsRepository;
|
||||
import com.yaoyuan.jiscuss.service.IDiscussionsService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class DiscussionsServiceImpl implements IDiscussionsService {
|
||||
@Autowired
|
||||
private DiscussionsRepository discussionsRepository;
|
||||
|
||||
@Override
|
||||
public List<Discussions> getAllList() {
|
||||
return discussionsRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Discussions insert(Discussions discussions) {
|
||||
|
||||
return discussionsRepository.save(discussions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Discussions findOne(Integer id) {
|
||||
Discussions discussions = new Discussions();
|
||||
discussions.setId(id);
|
||||
return discussionsRepository.getOne(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Discussions> queryAllDiscussionsList(int pageNum, int pageSize) {
|
||||
Sort sort=new Sort(Sort.Direction.DESC,"id");
|
||||
@SuppressWarnings("deprecation")
|
||||
Pageable pageable=new PageRequest(pageNum,pageSize,sort);
|
||||
return discussionsRepository.findAll(pageable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.DiscussionsTags;
|
||||
import com.yaoyuan.jiscuss.repository.DiscussionsTagsRepository;
|
||||
import com.yaoyuan.jiscuss.service.IDiscussionsTagsService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class DiscussionsTagsServiceImpl implements IDiscussionsTagsService {
|
||||
@Autowired
|
||||
private DiscussionsTagsRepository discussionsTagsRepository;
|
||||
|
||||
@Override
|
||||
public List<DiscussionsTags> getAllList() {
|
||||
return discussionsTagsRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscussionsTags insert(DiscussionsTags discussionsTags) {
|
||||
return discussionsTagsRepository.save(discussionsTags);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Posts;
|
||||
import com.yaoyuan.jiscuss.repository.PostsRepository;
|
||||
import com.yaoyuan.jiscuss.service.IPostsService;
|
||||
|
||||
public class PostsServiceImpl implements IPostsService {
|
||||
@Autowired
|
||||
private PostsRepository postsRepository;
|
||||
|
||||
@Override
|
||||
public List<Posts> getAllList() {
|
||||
return postsRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Posts insert(Posts posts) {
|
||||
return postsRepository.save(posts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Settings;
|
||||
import com.yaoyuan.jiscuss.repository.SettingsRepository;
|
||||
import com.yaoyuan.jiscuss.service.ISettingsService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SettingsServiceImpl implements ISettingsService {
|
||||
@Autowired
|
||||
private SettingsRepository settingsRepository;
|
||||
|
||||
@Override
|
||||
public List<Settings> getAllList() {
|
||||
return settingsRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings insert(Settings settings) {
|
||||
return settingsRepository.save(settings);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 com.yaoyuan.jiscuss.entity.Staff;
|
||||
import com.yaoyuan.jiscuss.repository.StaffRepository;
|
||||
import com.yaoyuan.jiscuss.service.IStaffService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class StaffServiceImpl implements IStaffService {
|
||||
@Autowired
|
||||
private StaffRepository staffRepository;
|
||||
|
||||
@Override
|
||||
public List<Staff> getAllList() {
|
||||
return staffRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Staff> queryAllStaffList(int pageNum,int pageSize) {
|
||||
Sort sort=new Sort(Sort.Direction.DESC,"id");
|
||||
@SuppressWarnings("deprecation")
|
||||
Pageable pageable=new PageRequest(pageNum,pageSize,sort);
|
||||
return staffRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Staff> getByNameIsLike(String name) {
|
||||
return staffRepository.getByNameIsLike(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Staff findOne(Integer id) {
|
||||
return staffRepository.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Staff insert(Staff staff) {
|
||||
return staffRepository.save(staff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Integer id) {
|
||||
staffRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
staffRepository.deleteAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Tags;
|
||||
import com.yaoyuan.jiscuss.repository.TagsRepository;
|
||||
import com.yaoyuan.jiscuss.service.ITagsService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class TagsServiceImpl implements ITagsService {
|
||||
@Autowired
|
||||
private TagsRepository tagsRepository;
|
||||
|
||||
@Override
|
||||
public List<Tags> getAllList() {
|
||||
return tagsRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tags insert(Tags tags) {
|
||||
return tagsRepository.save(tags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.yaoyuan.jiscuss.service.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import com.yaoyuan.jiscuss.entity.Users;
|
||||
import com.yaoyuan.jiscuss.repository.UsersRepository;
|
||||
import com.yaoyuan.jiscuss.service.IUsersService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class UsersServiceImpl implements IUsersService {
|
||||
@Autowired
|
||||
private UsersRepository usersRepository;
|
||||
|
||||
@Cacheable(value = "user")
|
||||
@Override
|
||||
public List<Users> getAllList() {
|
||||
return usersRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<Users> 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Users> getByUsernameIsLike(String name) {
|
||||
return usersRepository.getByUsernameIsLike(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Users findOne(Integer id) {
|
||||
return usersRepository.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Users insert(Users user) {
|
||||
return usersRepository.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Integer id) {
|
||||
usersRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
usersRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Users getByUsername(String username) {
|
||||
return usersRepository.getByUsername(username);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Users checkByUsernameAndPassword(String username,String password) {
|
||||
return usersRepository.checkByUsernameAndPassword(username,password);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Users update(Users user, Integer id) {
|
||||
return usersRepository.saveAndFlush(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user