JSP+SQL文档管理系统
文档管理系统分用户级别登录,一级用户,二级用户登录后操作权限和菜单权限会不一样
代码已经上传github,下载地址: https://github.com/21503882/filemanage
运用技术:
SSM + redis + jsp + bootstrap(前台) + layui/bootstrap(后台) + jquery
实现功能:
首页:商品信息+视频播放+广告轮播
import java.util.ArrayList;
import java.util.Date;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;
import com.hdxy.vehicle.base.Pagination;
import com.hdxy.vehicle.entity.News;
import com.hdxy.vehicle.entity.SysUser;
import com.hdxy.vehicle.service.NewsService;
import com.hdxy.vehicle.util.ActionResult;
/**
* TODO 类描述
*
* @version 0.0.1
* @author generator
* @date 2019-03-02
*/
@Controller
public class NewsAction {
@Autowired
private NewsService newsService;
/**
* 显示所有新闻信息并分页
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/findNews")
public Pagination<News> findNews(News entity) {
try {
entity.setSortColumns("updateTime desc");
return newsService.findPageByCondition(entity);
} catch (Exception e) {
e.printStackTrace();
}
return new Pagination<>(0, new ArrayList<>());
}
/**
* 删除新闻信息
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/delNews")
public ActionResult delNews(Integer id) {
ActionResult res = new ActionResult();
try {
newsService.deleteById(id);
res.setSuccess(true);
res.setMsg("删除成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,删除失败");
}
return res;
}
/**
* 跳转编辑页面
*
* @param id
* @return
*/
@RequestMapping("/isAdmin/forwardEditNews")
public ModelAndView forwardEditNews(Integer id) {
ModelAndView model = new ModelAndView();
model.setViewName("backstage/editNews");
try {
model.addObject("editNews", newsService.findById(id));
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
/**
* 修改新闻信息
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/upNews")
public ActionResult upNews(News entity, HttpSession session) {
ActionResult res = new ActionResult();
try {
entity.setUpdateTime(new Date());
SysUser sysUser = (SysUser) session.getAttribute("sysUser");
entity.setUpdateUser(sysUser.getId());
entity.setUsername(sysUser.getName());
newsService.updateById(entity);
res.setSuccess(true);
res.setMsg("修改成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,修改失败");
}
return res;
}
/**
* 添加新闻信息
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/addNews")
public ActionResult addNews(News entity, HttpSession session) {
ActionResult res = new ActionResult();
try {
entity.setUpdateTime(new Date());
SysUser sysUser = (SysUser) session.getAttribute("sysUser");
entity.setUpdateUser(sysUser.getId());
entity.setUsername(sysUser.getName());
entity.setPublishStatus(0);
newsService.save(entity);
res.setSuccess(true);
res.setMsg("添加成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,添加失败");
}
return res;
}
/**
* 修改新闻信息状态
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/updateNewsState")
public ActionResult updateNewsState(News entity) {
ActionResult res = new ActionResult();
try {
newsService.updateById(entity);
res.setSuccess(true);
res.setMsg("操作成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,操作失败");
}
return res;
}
/**
* 显示所有发布了的新闻信息并分页
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/user/findNewsByPage")
public Pagination<News> findNewsByPage(News entity) {
try {
entity.setPublishStatus(1);
entity.setSortColumns("updateTime desc");
return newsService.findPageByCondition(entity);
} catch (Exception e) {
e.printStackTrace();
}
return new Pagination<>(0, new ArrayList<>());
}
@ResponseBody
@RequestMapping("/user/queryNewsCount")
public Integer queryNewsCount(News entity) {
Integer pageNum = 0;
try {
entity.setPublishStatus(1);
Integer count = newsService.queryNewsCount(entity);
pageNum = (int) Math.ceil((float) count / entity.getLimit());
} catch (Exception e) {
e.printStackTrace();
}
return pageNum;
}
/**
* 跳转新闻详情页面
*
* @param id
* @return
*/
@RequestMapping("/user/forwardNewsDetails")
public ModelAndView forwardNewsDetails(Integer id) {
ModelAndView model = new ModelAndView();
model.setViewName("forward:/newsDetails.jsp");
try {
model.addObject("news", newsService.findById(id));
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
}
代码已经上传github,下载地址: https://github.com/21503882/filemanage