commit
63eabab518
@ -0,0 +1,42 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : he
|
||||
Source Server Version : 50636
|
||||
Source Host : localhost:3306
|
||||
Source Database : hlb
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50636
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2024-06-28 13:12:37
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for admins
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `admins`;
|
||||
CREATE TABLE `admins` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`adminName` varchar(20) NOT NULL COMMENT '管理员的名字',
|
||||
`adminPwd` varchar(20) NOT NULL COMMENT '密码',
|
||||
`realName` varchar(20) NOT NULL COMMENT '真实的名字',
|
||||
`telephone` varchar(20) NOT NULL COMMENT '电话',
|
||||
`Email` varchar(20) NOT NULL,
|
||||
`birthday` date NOT NULL,
|
||||
`sex` varchar(3) NOT NULL,
|
||||
`pic` varchar(100) DEFAULT 'a.png',
|
||||
`remark` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of admins
|
||||
-- ----------------------------
|
||||
INSERT INTO `admins` VALUES ('1', 'tzp', '11', '123', '15797959509', '15281210084', '2000-12-11', '男', 'a1.png', 'asd');
|
||||
INSERT INTO `admins` VALUES ('2', 'xm', '11', '111', '12345678999', '15893336489', '2023-12-13', '女', 'a.png', 'dasdasd');
|
||||
INSERT INTO `admins` VALUES ('3', 'bc', '11', '122', '12345678766', '1234567876@qq.com', '2023-12-12', '女', 'a2.png', 'adsasd');
|
||||
INSERT INTO `admins` VALUES ('4', 'cc', '11', '122', '12345678766', '1234567876@qq.com', '2023-12-12', '女', 'a3.png', 'dasdasd');
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : he
|
||||
Source Server Version : 50636
|
||||
Source Host : localhost:3306
|
||||
Source Database : hlb
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50636
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2024-06-28 13:13:09
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for answer
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `answer`;
|
||||
CREATE TABLE `answer` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`userId` int(11) DEFAULT NULL,
|
||||
`replayId` int(11) DEFAULT NULL,
|
||||
`commentId` int(11) NOT NULL,
|
||||
`answerTime` date NOT NULL,
|
||||
`content` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `fk8` (`userId`) USING BTREE,
|
||||
KEY `fk11` (`commentId`) USING BTREE,
|
||||
KEY `fk10` (`replayId`) USING BTREE,
|
||||
CONSTRAINT `fk10` FOREIGN KEY (`replayId`) REFERENCES `answer` (`id`),
|
||||
CONSTRAINT `fk11` FOREIGN KEY (`commentId`) REFERENCES `comment` (`id`),
|
||||
CONSTRAINT `fk8` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of answer
|
||||
-- ----------------------------
|
||||
INSERT INTO `answer` VALUES ('1', '2', null, '8', '2018-08-23', '真乖');
|
||||
INSERT INTO `answer` VALUES ('2', '5', '1', '8', '2018-08-23', '好漂亮');
|
||||
INSERT INTO `answer` VALUES ('3', '3', '2', '8', '2019-09-06', '我也喜欢。');
|
||||
INSERT INTO `answer` VALUES ('5', '1', null, '8', '2019-09-07', '太爱了。');
|
||||
INSERT INTO `answer` VALUES ('6', '1', null, '8', '2019-09-07', '我也喜欢。');
|
||||
INSERT INTO `answer` VALUES ('7', '1', null, '11', '2019-09-07', '我也喜欢。');
|
||||
INSERT INTO `answer` VALUES ('8', '17', null, '8', '2019-09-08', '我也喜欢。');
|
||||
INSERT INTO `answer` VALUES ('9', '17', null, '8', '2019-09-08', '好漂亮');
|
||||
INSERT INTO `answer` VALUES ('10', '17', null, '12', '2019-09-09', '我也喜欢。');
|
||||
INSERT INTO `answer` VALUES ('11', '17', null, '11', '2019-09-09', '我也喜欢。');
|
||||
INSERT INTO `answer` VALUES ('12', '1', null, '3', '2024-06-26', '453311');
|
||||
INSERT INTO `answer` VALUES ('13', '1', null, '3', '2024-06-26', '基地啊司机的驾驶的集结地阿三基地啊家是基督教按时间嗲是基地啊家是低价啊是第几点击洒几滴静安寺嗲是基地啊是近代世界的i大家说大家时间嗲是基地啊家上帝哦哦就基地啊是基地啊家上帝啊世界第几啊是哦对基地啊世界第哦啊降低哦骄傲地哦交大急啊多久啊是大家基地啊家低价圣诞节哦i阿娇级大神单价单价较低哦奥军第九的教师基地啊家嗲基地啊实际上都i静安寺军第哦啊世界第哦啊降低哦哦阿姐、基地啊司机的驾驶的集结地阿三基地啊家是基督教按时间嗲是基地啊家是基地啊司机的驾驶的集结地阿三基地啊家是基督教按时间嗲是基地啊家是');
|
@ -0,0 +1,152 @@
|
||||
package club.controller;
|
||||
|
||||
import club.pojo.Admins;
|
||||
import club.service.AdminService;
|
||||
import club.service.UserService;
|
||||
import club.util.Message;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpSession;
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class AdminController {
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("/create")
|
||||
@ResponseBody
|
||||
public Message add(Admins admins, MultipartFile file){
|
||||
String pic = FileLoad.uploadAdminPic(file);
|
||||
admins.setPic(pic);
|
||||
int add = adminService.add(admins);
|
||||
if(add>0){
|
||||
return Message.success();
|
||||
}else{
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("findById")
|
||||
@ResponseBody
|
||||
public Message findById(Integer id){
|
||||
Admins byId = adminService.findById(id);
|
||||
return Message.success().add("admin",byId);
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(Admins admins, MultipartFile file){
|
||||
if (file != null && file.getSize() > 0){
|
||||
String pic = FileLoad.uploadAdminPic(file);
|
||||
admins.setPic(pic);
|
||||
}
|
||||
int update = adminService.update(admins);
|
||||
if(update>0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message del(Integer id){
|
||||
int del = adminService.del(id);
|
||||
if(del>0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/admins")
|
||||
@ResponseBody
|
||||
public Message admins(@RequestParam(required = false) String adminName,@RequestParam("pn") Integer pageNum){
|
||||
Integer pageSize = 4;
|
||||
if(pageNum == null){
|
||||
pageNum = 1;
|
||||
}
|
||||
PageInfo<Admins> list = adminService.adminPage(adminName, pageNum, pageSize);
|
||||
return Message.success().add("pageInfo",list);
|
||||
}
|
||||
|
||||
@RequestMapping("/admin")
|
||||
public String admin(){
|
||||
return "admin/admin";
|
||||
}
|
||||
|
||||
@RequestMapping("/adopt")
|
||||
public String adopt(){
|
||||
return "admin/adopt";
|
||||
}
|
||||
|
||||
@RequestMapping("/agree")
|
||||
public String agree(){
|
||||
return "admin/agree";
|
||||
}
|
||||
|
||||
@RequestMapping("/apply")
|
||||
public String apply(){
|
||||
return "admin/apply";
|
||||
}
|
||||
|
||||
@RequestMapping("/blog")
|
||||
public String blog(){
|
||||
return "admin/blog";
|
||||
}
|
||||
|
||||
@RequestMapping("/comment")
|
||||
public String comment(){
|
||||
return "admin/comment";
|
||||
}
|
||||
|
||||
@RequestMapping("/disAgree")
|
||||
public String disAgree(){
|
||||
return "admin/disAgree";
|
||||
}
|
||||
|
||||
@RequestMapping("/pet")
|
||||
public String pet(){
|
||||
return "admin/pet";
|
||||
}
|
||||
|
||||
@RequestMapping("/user")
|
||||
public String user(){
|
||||
return "admin/user";
|
||||
}
|
||||
|
||||
/*管理员登录*/
|
||||
@RequestMapping("/login")
|
||||
public String login(){
|
||||
return "admin/login";
|
||||
}
|
||||
|
||||
@RequestMapping("/dologin")
|
||||
public String doLogin(HttpSession session, String adminName,String adminPwd){
|
||||
Admins login = adminService.login(adminName, adminPwd);
|
||||
if (login == null){
|
||||
session.setAttribute("msg","用户名或密码错误!");
|
||||
return "redirect:/admin/login";
|
||||
}
|
||||
session.setAttribute("admin",login);
|
||||
return "redirect:/admin/admin";
|
||||
}
|
||||
|
||||
@RequestMapping("/logout")
|
||||
public String logout(HttpSession session){
|
||||
session.invalidate();
|
||||
return "redirect:/admin/login";
|
||||
}
|
||||
|
||||
@RequestMapping("/developing")
|
||||
public String developing(){
|
||||
return "admin/developing";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package club.controller;
|
||||
|
||||
import club.pojo.Answer;
|
||||
import club.pojo.User;
|
||||
import club.service.AnswerService;
|
||||
import club.util.Message;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/answer")
|
||||
public class AnswerController {
|
||||
|
||||
@Resource
|
||||
private AnswerService answerService;
|
||||
|
||||
@RequestMapping("/create")
|
||||
@ResponseBody
|
||||
public Message create(HttpSession session, Integer commentId, String content){
|
||||
User user = (User) session.getAttribute("user");
|
||||
Integer integer = answerService.create(user.getId(), commentId, content);
|
||||
if (integer > 0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/findById")
|
||||
@ResponseBody
|
||||
public Message findById(Integer id){
|
||||
Answer answer = answerService.findById(id);
|
||||
return Message.success().add("answer", answer);
|
||||
}
|
||||
|
||||
@RequestMapping("/creates")
|
||||
@ResponseBody
|
||||
public Message creates(HttpSession session, Integer replayId, String content, Integer commentId){
|
||||
User user = (User) session.getAttribute("user");
|
||||
Integer integer = answerService.creates(user.getId(), replayId, content, commentId);
|
||||
if (integer > 0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package club.controller;
|
||||
|
||||
import club.pojo.User;
|
||||
import club.service.UserService;
|
||||
import club.util.Message;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping("/create")
|
||||
@ResponseBody
|
||||
public Message add(User user){
|
||||
int add = userService.add(user);
|
||||
if(add>0){
|
||||
return Message.success();
|
||||
}else{
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/login")
|
||||
@ResponseBody
|
||||
public Message loginuser(HttpSession session, String userName, String password){
|
||||
User user = userService.loginuser(userName, password);
|
||||
if (user != null){
|
||||
session.setAttribute("user",user);
|
||||
return Message.success().add("user",user);
|
||||
}else{
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
@RequestMapping("/logout")
|
||||
@ResponseBody
|
||||
public Message logout(HttpSession session){
|
||||
session.invalidate();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/users")
|
||||
@ResponseBody
|
||||
public Message users(@RequestParam(required = false) String userName, @RequestParam("pn")Integer pageNum){
|
||||
Integer pageSize = 4;
|
||||
PageInfo<User> users = userService.allUser(userName,pageNum,pageSize);
|
||||
return Message.success().add("pageInfo",users);
|
||||
}
|
||||
|
||||
@RequestMapping("findById")
|
||||
@ResponseBody
|
||||
public Message findById(Integer id){
|
||||
User byId = userService.findById(id);
|
||||
return Message.success().add("user",byId);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message del(Integer id){
|
||||
int del = userService.del(id);
|
||||
if(del>0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/about")
|
||||
public String about(){
|
||||
return "user/about";
|
||||
}
|
||||
|
||||
@RequestMapping("/error")
|
||||
public String error(){
|
||||
return "user/error";
|
||||
}
|
||||
|
||||
@RequestMapping("/index")
|
||||
public String index(){
|
||||
return "user/index";
|
||||
}
|
||||
|
||||
@RequestMapping("/personal-info")
|
||||
public String personalInfo(){
|
||||
return "user/personal-info";
|
||||
}
|
||||
|
||||
@RequestMapping("/service")
|
||||
public String service(){
|
||||
return "user/service";
|
||||
}
|
||||
|
||||
@RequestMapping("/show")
|
||||
public String show(){
|
||||
return "user/show";
|
||||
}
|
||||
|
||||
@RequestMapping("/team")
|
||||
public String team(){
|
||||
return "user/team";
|
||||
}
|
||||
|
||||
@RequestMapping("/teamBlog")
|
||||
public String teamBlog(){
|
||||
return "user/teamBlog";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(User user){
|
||||
Integer update = userService.update(user);
|
||||
if(update > 0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/updatePic")
|
||||
@ResponseBody
|
||||
public Message updatePic(HttpSession session, MultipartFile file){
|
||||
String fileName = FileLoad.uploadUserPic(file);
|
||||
User user = (User) session.getAttribute("user");
|
||||
user.setPic(fileName);
|
||||
Integer update = userService.update(user);
|
||||
if (update > 0){
|
||||
return Message.success();
|
||||
}else {
|
||||
return Message.fail();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package club.dao;
|
||||
|
||||
import club.pojo.Admins;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
|
||||
|
||||
public interface AdminMapper extends BaseMapper<Admins> {
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package club.dao;
|
||||
|
||||
import club.pojo.Answer;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
|
||||
public interface AnswerMapper extends BaseMapper<Answer> {
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package club.dao;
|
||||
|
||||
import club.pojo.User;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package club.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotations.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class Answer {
|
||||
private Integer id;
|
||||
private Integer userId;
|
||||
private Integer replayId;
|
||||
private Integer commentId;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date answerTime;
|
||||
private String content;
|
||||
|
||||
@TableField(exist = false)
|
||||
private User user;
|
||||
@TableField(exist = false)
|
||||
private Answer answer;
|
||||
@TableField(exist = false)
|
||||
private Comment comment;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package club.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotations.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class User {
|
||||
// 定义用户类
|
||||
private Integer id;
|
||||
private String userName;
|
||||
private String password;
|
||||
private String sex;
|
||||
private Integer age;
|
||||
private String telephone;
|
||||
private String Email;
|
||||
private String address;
|
||||
private String pic;
|
||||
private Integer state;
|
||||
@TableField(exist = false)
|
||||
List<Comment> commentList;
|
||||
@TableField(exist = false)
|
||||
List<AdoptAnimal> animalList;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package club.service;
|
||||
|
||||
import club.pojo.Admins;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
|
||||
import club.pojo.Admins;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
|
||||
public interface AdminService {
|
||||
PageInfo<Admins> adminPage(String adminName,Integer pageNum,Integer pageSize);
|
||||
Admins findById(Integer id);
|
||||
Admins login(String adminName, String adminPwd);
|
||||
PageInfo<Admins> allAdmin(String adminsName, int pageNum, int pageSize);
|
||||
int add(Admins admins);
|
||||
int update(Admins admins);
|
||||
int del(Integer id);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package club.service;
|
||||
|
||||
import club.pojo.Answer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnswerService {
|
||||
List<Answer> answersAboutOneComment(Integer commentId);
|
||||
Integer create(Integer userId, Integer commentId, String content);
|
||||
Answer findById(Integer id);
|
||||
Integer creates(Integer userId, Integer replayrId, String content, Integer commentId);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package club.service;
|
||||
|
||||
import club.pojo.User;
|
||||
|
||||
import club.pojo.User;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
List<User> findByName(String userName, Integer state);
|
||||
List<User> showName(String userName);
|
||||
//登录数据
|
||||
User loginuser(String userName,String password);
|
||||
//添加数据
|
||||
int add(User user);
|
||||
//修改数据
|
||||
Integer update(User user);
|
||||
User findById(Integer id);
|
||||
PageInfo<User> allUser(String userName, Integer pageNum, Integer pageSize);
|
||||
int del(Integer id);
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package club.service.impl;
|
||||
|
||||
import club.dao.AdminMapper;
|
||||
import club.pojo.Admins;
|
||||
import club.service.AdminService;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
@Resource
|
||||
private AdminMapper adminMapper;
|
||||
@Override
|
||||
public PageInfo<Admins> adminPage(String adminName, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
EntityWrapper wrapper = new EntityWrapper();
|
||||
if(adminName != null && !"".equals(adminName)){
|
||||
wrapper.like("adminName",adminName);
|
||||
}
|
||||
List list = adminMapper.selectList(wrapper);
|
||||
PageInfo<Admins> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Admins login(String adminName, String adminPwd) {
|
||||
Admins a = new Admins();
|
||||
a.setAdminName(adminName);
|
||||
Admins admin = adminMapper.selectOne(a);
|
||||
if (admin != null && admin.getAdminPwd().equals(adminPwd)){
|
||||
return admin;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Admins> allAdmin(String adminName, int pageNum, int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int add(Admins admins) {
|
||||
return adminMapper.insert(admins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Admins admins) {
|
||||
return adminMapper.updateById(admins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Admins findById(Integer id) {
|
||||
return adminMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int del(Integer id) {
|
||||
return adminMapper.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package club.service.impl;
|
||||
|
||||
import club.dao.AnswerMapper;
|
||||
import club.dao.CommentMapper;
|
||||
import club.dao.UserMapper;
|
||||
import club.pojo.Answer;
|
||||
import club.pojo.Comment;
|
||||
import club.pojo.User;
|
||||
import club.service.AnswerService;
|
||||
import club.service.UserService;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class AnswerServiceImpl implements AnswerService {
|
||||
|
||||
@Resource
|
||||
private AnswerMapper answerMapper;
|
||||
|
||||
@Resource
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public List<Answer> answersAboutOneComment(Integer commentId) {
|
||||
EntityWrapper wrapper = new EntityWrapper();
|
||||
if (commentId != null) {
|
||||
wrapper.eq("commentId", commentId);
|
||||
}
|
||||
List<Answer> list = answerMapper.selectList(wrapper);
|
||||
if (!list.isEmpty()) {
|
||||
for (Answer answer : list) {
|
||||
User user = userMapper.selectById(answer.getUserId());
|
||||
answer.setUser(user);
|
||||
if (answer.getReplayId() != null) {
|
||||
Answer answer1 = answerMapper.selectById(answer.getReplayId());
|
||||
User u = userMapper.selectById(answer1.getUserId());
|
||||
answer1.setUser(u);
|
||||
answer.setAnswer(answer1);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer create(Integer userId, Integer commentId, String content) {
|
||||
Answer answer = new Answer();
|
||||
answer.setUserId(userId);
|
||||
answer.setCommentId(commentId);
|
||||
answer.setContent(content);
|
||||
answer.setAnswerTime(new Date());
|
||||
return answerMapper.insert(answer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer findById(Integer id) {
|
||||
Answer answer = answerMapper.selectById(id);
|
||||
Comment comment = commentMapper.selectById(answer.getCommentId());
|
||||
answer.setComment(comment);
|
||||
return answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer creates(Integer userId, Integer replayId, String content, Integer commentId) {
|
||||
Answer answer = new Answer();
|
||||
answer.setUserId(userId);
|
||||
answer.setReplayId(replayId);
|
||||
answer.setCommentId(commentId);
|
||||
answer.setContent(content);
|
||||
answer.setAnswerTime(new Date());
|
||||
return answerMapper.insert(answer);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package club.service.impl;
|
||||
|
||||
import club.dao.UserMapper;
|
||||
import club.pojo.User;
|
||||
import club.dao.UserMapper;
|
||||
import club.pojo.Admins;
|
||||
import club.pojo.User;
|
||||
import club.service.UserService;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.List;
|
||||
@Service
|
||||
@Transactional
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Override
|
||||
public User findById(Integer id) {
|
||||
return userMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByName(String userName, Integer state) {
|
||||
EntityWrapper<User> wrapper = new EntityWrapper<>();
|
||||
if (userName != null && !userName.equals("")){
|
||||
wrapper.like("userName", userName);
|
||||
}
|
||||
if (state != null){
|
||||
wrapper.eq("state", state);
|
||||
}
|
||||
return userMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> showName(String userName) {
|
||||
EntityWrapper wrapper = new EntityWrapper();
|
||||
if(userName != null && !userName.equals("")){
|
||||
wrapper.like("userName",userName);
|
||||
}
|
||||
return userMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User loginuser(String userName, String password) {
|
||||
User user = new User();
|
||||
user.setUserName(userName);
|
||||
User user1 = userMapper.selectOne(user);
|
||||
if (user1 != null && user1.getPassword().equals(password)) {
|
||||
return user1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer update(User user) {
|
||||
return userMapper.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<User> allUser(String userName ,Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
EntityWrapper<User> wrapper = new EntityWrapper<>();
|
||||
if(userName != null && !"".equals(userName)){
|
||||
wrapper.like("userName",userName);
|
||||
}
|
||||
|
||||
List<User> list = userMapper.selectList(wrapper);
|
||||
PageInfo<User> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int add(User user) {
|
||||
return userMapper.insert(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int del(Integer id) {
|
||||
return userMapper.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : he
|
||||
Source Server Version : 50636
|
||||
Source Host : localhost:3306
|
||||
Source Database : hlb
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50636
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2024-06-28 13:13:51
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for user
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user`;
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`userName` varchar(20) NOT NULL,
|
||||
`password` varchar(30) NOT NULL,
|
||||
`sex` varchar(2) DEFAULT NULL COMMENT '性别',
|
||||
`age` int(11) DEFAULT NULL COMMENT '年龄',
|
||||
`telephone` varchar(20) DEFAULT NULL COMMENT '电话',
|
||||
`Email` varchar(30) DEFAULT NULL COMMENT 'Email',
|
||||
`address` varchar(50) DEFAULT NULL COMMENT '地址',
|
||||
`pic` varchar(100) DEFAULT 't0.jpg',
|
||||
`state` int(11) DEFAULT '0' COMMENT '有无领养宠物的经历 0 是没有 1 是由',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user
|
||||
-- ----------------------------
|
||||
INSERT INTO `user` VALUES ('1', 'tzp', '11', '男', '10', '13809182091', '', '攀枝花', 't1.jpg', '3');
|
||||
INSERT INTO `user` VALUES ('2', '打瞌睡', '11', '男', '50', '13908457344', '', '泸州', 't2.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('3', '能理解', '11', '男', '45', '13903827601', '132121129281@qq.com', '泸州', 't3.jpg', '1');
|
||||
INSERT INTO `user` VALUES ('4', '云集了', '11', '男', '43', '13903822001', '', '泸州', 't4.jpg', '1');
|
||||
INSERT INTO `user` VALUES ('5', '洋溢', '11', '女', '23', '13903810621', '121212549281@qq.com', '泸州', 't5.jpg', '1');
|
||||
INSERT INTO `user` VALUES ('6', '陈一', '11', '男', '40', '13903819146', '12121212181@qq.com', '泸州', 't6.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('8', '陈二', '11', '女', '35', '13123819301', '12121212112@qq.com', '泸州', 't8.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('17', '陈三', '11', '女', '32', '15797959509', '21111111111@qq.com', '泸州', 't17.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('33', '沉思', '11', '男', '22', '1456879876', '1111111118@163.com', '泸州', 'xq1.jpg', '1');
|
||||
INSERT INTO `user` VALUES ('34', '晨雾', '11', '男', '22', '1456879876', '1111111118@163.com', '泸州', 'xq2.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('35', 'eqw', '123456', '男', '123', 'ewqeqwe', 'qeweqw', 'qeweqw', 't0.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('36', '123', '123', '男', '12', '16565', '257451', '好几个', 't0.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('37', '1', '1', '男', '2', '23124', '21', '123', 't0.jpg', '0');
|
||||
INSERT INTO `user` VALUES ('38', 'lll', '1234', '男', '22', '15281210084', '2802045328@qq.cpm', '孝泉', 't0.jpg', '0');
|
@ -0,0 +1,68 @@
|
||||
package club.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
//
|
||||
//工具包
|
||||
public class Message {
|
||||
|
||||
/**
|
||||
* 状态码 100-成功 200-失败
|
||||
* */
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
* */
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 用户要返回给浏览器的数据
|
||||
* */
|
||||
private Map<String, Object> extend = new HashMap<String, Object>();
|
||||
|
||||
public static Message success(){
|
||||
Message result = new Message();
|
||||
result.setCode(100);
|
||||
result.setMessage("处理成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Message fail(){
|
||||
Message result = new Message();
|
||||
result.setCode(200);
|
||||
result.setMessage("处理失败!");
|
||||
return result;
|
||||
}
|
||||
|
||||
public Message add(String key,Object value){
|
||||
this.getExtend().put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Map<String, Object> getExtend() {
|
||||
return extend;
|
||||
}
|
||||
|
||||
public void setExtend(Map<String, Object> extend) {
|
||||
this.extend = extend;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue