package com.joycheng.ryan.controller.admin;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.joycheng.ryan.common.LoginSession;
import com.joycheng.ryan.common.ServerLayResult;
import com.joycheng.ryan.entity.Article;
import com.joycheng.ryan.service.LabelService;
import com.joycheng.ryan.entity.Label;
import com.joycheng.ryan.service.ArticleService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class ArticleController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ArticleService articleService;
@Autowired
private LabelService labelService;
@RequestMapping("/articleUi")
public String articleListUi() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/article/list";
}
@RequestMapping("/articleUiAdd")
public String articleAddUi() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/article/listform";
}
/**
* 后台文章列表
*
* @param page 当前页
* @param limit 每页多少条
* @param keyword1 关键字查询
* @param keyword2
* @param keyword3
* @return
*/
@ResponseBody
@RequestMapping("/admin/article/list")
public ServerLayResult<Article> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
String keyword1, String keyword2, String keyword3) {
if (keyword1 != null && keyword2 != "" || keyword2 != null && keyword2 != "" || keyword3 != null && keyword3 != "") {
List<Article> articles = articleService.selectByKeyWord(page, limit, keyword1, keyword2, keyword3);
ServerLayResult result = new ServerLayResult(0, "", articles.size(), articles);
return result;
}
//封装数据
ServerLayResult result = new ServerLayResult(0, "", articleService.count(), articleService.selectAll(page, limit));
return result;
}
/**
* 根据ID删除
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/admin/article/del")
public Map<String, Object> delArticle(@RequestParam("id") int id) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = articleService.deleteByPrimaryKey(id);
dataMap.put("success", isSuccess);
return dataMap;
}
/**
* 前台响应json数据
* 解析保存
*
* @param article
* @return
*/
@ResponseBody
@RequestMapping("/admin/article/add")
public Map<String, Object> addArticle(@RequestBody JSONObject article) {
JSONObject json = JSON.parseObject(article.toJSONString());
String author = json.getString("author");
Integer label = json.getInteger("label");
String title = json.getString("title");
String content = json.getString("content");
String status = json.getString("status");
int temp = 0;
if (status != null) {
if (status.equals("on")) {
temp = 1;
}
}
Label label1 = new Label();
label1.setId(label);
Article articles = new Article();
articles.setAuthor(author);
articles.setContent(content);
articles.setTitle(title);
articles.setStatus(temp);
articles.setCreateTime(new Date());
articles.setLabel(label1);
logger.info(article + "");
boolean isSuccess = articleService.insert(articles);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("success", isSuccess);
return dataMap;
}
/**
* 根据前台响应的json对象封装后通过业务方法保存到数据库
*
* @param article
* @return
*/
@ResponseBody
@RequestMapping("/admin/article/update")
public Map<String, Object> updateArticle(@RequestBody JSONObject article) {
JSONObject json = JSON.parseObject(article.toJSONString());
String author = json.getString("author");
Integer label = json.getInteger("label");
Integer id = json.getInteger("id");
String title = json.getString("title");
String content = json.getString("content");
String status = json.getString("status");
int temp = 0;
if (status != null) {
if (status.equals("on")) {
temp = 1;
}
}
Label label1 = new Label();
label1.setId(label);
Article articles = new Article();
articles.setId(id);
articles.setAuthor(author);
articles.setContent(content);
articles.setTitle(title);
articles.setStatus(temp);
articles.setCreateTime(new Date());
articles.setLabel(label1);
logger.info(article + "");
boolean isSuccess = articleService.updateByPrimaryKey(articles);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("success", isSuccess);
return dataMap;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于springboot2+mybatis+thymeleaf+layui整合开发的在线心理咨询管理系统源码+数据库sq.zip
共846个文件
gif:300个
js:120个
xml:104个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 2 浏览量
2023-06-30
11:30:45
上传
评论
收藏 5.97MB ZIP 举报
温馨提示
基于springboot2+mybatis+thymeleaf+layui整合开发的在线心理咨询管理系统源碼.zip 【资源说明】 该项目是个人毕设项目源码,评审分达到95分,都经过严格调试,确保可以运行!放心下载使用。 该项目资源主要针对计算机、自动化等相关专业的学生或从业者下载使用,也可作为期末课程设计、课程大作业、毕业设计等。 具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现类似其他功能。 【行环境 】 jdk8+mysql5.7+IntelliJ IDEA+maven 项目技术 spring boot2+mybatis+thymeleaf+layui 数据库文件 doc/xinlidb.sql http://localhost:8080/ 管理后台登录地址 http://localhost:8080/login admin 123456 数据库名:xinlidb
资源推荐
资源详情
资源评论
收起资源包目录
基于springboot2+mybatis+thymeleaf+layui整合开发的在线心理咨询管理系统源码+数据库sq.zip (846个子文件)
ArticleController.class 6KB
LeacotController.class 5KB
NoticeController.class 5KB
LoginController.class 5KB
ClientLeacotsController.class 4KB
UserController.class 4KB
TopicController.class 4KB
UpdatePasswordController.class 4KB
ArticleServiceImpl.class 4KB
ClientPgTestController.class 4KB
TopicServiceImpl.class 4KB
NoticeServiceImpl.class 4KB
LeacotServiceImpl.class 3KB
PgTestServiceImpl.class 3KB
UserServiceImpl.class 3KB
PgTestController.class 3KB
User.class 3KB
Article.class 3KB
ClientNoticeController.class 2KB
ClientArticleController.class 2KB
ServerLayResult.class 2KB
Leacot.class 2KB
ReplyServiceImpl.class 2KB
Topic.class 2KB
LoginConfiguration.class 2KB
Reply.class 2KB
PgTest.class 2KB
KaptchaConfig.class 1KB
Notice.class 1KB
GlobalException.class 1KB
LabelServiceImpl.class 1KB
LoginSession.class 1KB
ConsoleController.class 1KB
YixinliApplicationTests.class 1KB
CheckLoginInterceptor.class 1KB
Label.class 1KB
LabelController.class 1KB
UserMapper.class 938B
UserService.class 904B
ArticleService.class 842B
LeacotService.class 832B
TopicService.class 825B
NoticeService.class 805B
RyanApplication.class 797B
PgTestService.class 745B
ArticleMapper.class 719B
NoticeMapper.class 677B
ClientUserController.class 669B
ClientIndexController.class 656B
PgTestMapper.class 644B
LeacotMapper.class 641B
TopicMapper.class 635B
ReplyService.class 470B
LabelService.class 470B
ReplyMapper.class 467B
LabelMapper.class 467B
.classpath 11KB
layui.css 68KB
layui.css 68KB
layui.css 68KB
layui.css 68KB
admin.css 25KB
admin.css 25KB
layim.css 15KB
layim.css 15KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
main.css 13KB
main.css 13KB
template.css 12KB
template.css 12KB
layui.mobile.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
layim.css 9KB
layim.css 9KB
laydate.css 7KB
laydate.css 7KB
laydate.css 7KB
laydate.css 7KB
login.css 3KB
login.css 3KB
code.css 1KB
code.css 1KB
code.css 1KB
code.css 1KB
font.css 512B
font.css 512B
iconfont.eot 40KB
iconfont.eot 40KB
iconfont.eot 40KB
iconfont.eot 40KB
59.gif 10KB
59.gif 10KB
59.gif 10KB
59.gif 10KB
22.gif 10KB
共 846 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
z同学的编程之路
- 粉丝: 1892
- 资源: 2130
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 智器阅读-7.4.1-NOAD智器阅读修复版,修复没有存储卡,请确认SD卡已插入的问题,可以在安卓6.0以上手机
- HC06蓝牙模块控制小灯开关例程
- tmp_adb8e8467ff56ac6da80f420d95de0a0442e56ec0e6fa485.bin
- 基于普中51开发板的超声波测距+蜂鸣器报警 (附开发板原理图)
- 基于51单片机带WIFI和陀螺仪的超声波测距
- C#用socket实现局域网办公助理设计.rar
- Allwinner-F1C600-User-Manual-V1.0 pdf
- 宾馆客房管理系统.rar
- NET房地产评估系统VB+SQL.rar
- vb.net酒店管理系统设计与实现
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功