ssm基于Java ssm的校园驿站管理系统源码和论文016
开发工具:idea
数据库mysql5.7+
数据库链接工具:navcat,小海豚等
技术:ssm
摘 要
互联网发展至今,无论是其理论还是技术都已经成熟,而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播,搭配信息管理工具可以很好地为人们提供服务。针对校园快递信息管理混乱,出错率高,信息安全性差,劳动强度大,费时费力等问题,采用校园驿站管理系统可以有效管理,使信息管理能够更加科学和规范。
校园驿站管理系统在JDK环境中,使用Java语言进行编码,使用Mysql创建数据表保存本系统产生的数据。系统可以提供信息显示和相应服务,其管理员管理快递仓库信息,管理待发货信息,管理已收快递,管理物流以及留言信息,管理员工和用户资料。员工更改物流信息,管理快递仓库信息,管理待发货信息,管理已收快递,发布留言信息。用户签收快递,查看系统公告,发布留言,查看已收快递信息,查看快递物流信息。
总之,校园驿站管理系统集中管理信息,有着保密性强,效率高,存储空间大,成本低等诸多优点。它可以降低信息管理成本,实现信息管理计算机化。
关键词:校园驿站管理系统;Java语言;Mysql
package com.controller;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.annotation.IgnoreAuth;
import com.entity.YuangongxinxiEntity;
import com.service.TokenService;
import org.apache.commons.lang3.StringUtils;
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.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.YuangongxinxiEntity;
import com.service.YuangongxinxiService;
import com.utils.PageUtils;
import com.utils.R;
/**
*
* 后端接口
* @author
* @email
* @date 2021-02-22
*/
@RestController
@Controller
@RequestMapping("/yuangongxinxi")
public class YuangongxinxiController {
private static final Logger logger = LoggerFactory.getLogger(YuangongxinxiController.class);
@Autowired
private YuangongxinxiService yuangongxinxiService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String role, HttpServletRequest request) {
YuangongxinxiEntity user = yuangongxinxiService.selectOne(new EntityWrapper<YuangongxinxiEntity>().eq("account", username));
if(user != null){
if(!user.getRole().equals(role)){
return R.error("权限不正常");
}
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),user.getName(), "users", user.getRole());
return R.ok().put("token", token);
}else{
return R.error("账号或密码或权限不对");
}
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody YuangongxinxiEntity user){
if(yuangongxinxiService.selectOne(new EntityWrapper<YuangongxinxiEntity>().eq("account", user.getAccount())) !=null) {
return R.error("员工已存在");
}
user.setRole("员工");
yuangongxinxiService.insert(user);
return R.ok();
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
YuangongxinxiEntity user = yuangongxinxiService.selectOne(new EntityWrapper<YuangongxinxiEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
yuangongxinxiService.update(user,null);
return R.ok("密码已重置为:123456");
}
/**
* 获取员工的session员工信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
YuangongxinxiEntity user = yuangongxinxiService.selectById(id);
return R.ok().put("data", user);
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",page方法");
Object role = request.getSession().getAttribute("role");
PageUtils page = null;
if(role.equals("员工")){
params.put("yh",request.getSession().getAttribute("userId"));
page = yuangongxinxiService.queryPage(params);
}else{
page = yuangongxinxiService.queryPage(params);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("Controller:"+this.getClass().getName()+",info方法");
YuangongxinxiEntity yuangongxinxi = yuangongxinxiService.selectById(id);
if(yuangongxinxi!=null){
return R.ok().put("data", yuangongxinxi);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody YuangongxinxiEntity yuangongxinxi, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",save");
Wrapper<YuangongxinxiEntity> queryWrapper = new EntityWrapper<YuangongxinxiEntity>()
.eq("name", yuangongxinxi.getName())
.eq("account", yuangongxinxi.getAccount())
.eq("password", yuangongxinxi.getPassword())
.eq("role", yuangongxinxi.getRole())
;
yuangongxinxi.setRole("员工");
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YuangongxinxiEntity yuangongxinxiEntity = yuangongxinxiService.selectOne(queryWrapper);
if("".equals(yuangongxinxi.getImgPhoto()) || "null".equals(yuangongxinxi.getImgPhoto())){
yuangongxinxi.setImgPhoto(null);
}
if(yuangongxinxiEntity==null){
yuangongxinxiService.insert(yuangongxinxi);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YuangongxinxiEntity yuangongxinxi, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",update");
//根据字段查询是否有相同数据
Wrapper<YuangongxinxiEntity> queryWrapper = new EntityWrapper<YuangongxinxiEntity>()
.notIn("id",yuangongxinxi.getId())
.eq("name", yuangongxinxi.getName())
.eq("account", yuangongxinxi.getAccount())
.eq("password", yuangongxinxi.getPassword())
.eq("role", yuangongxinxi.getRole())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YuangongxinxiEntity yuangongxinxiEntity = yuangongxinxiService.selectOne(queryWrapper);
if("".equals(yuangongxinxi.getImgPhoto()) || "null".equals(yuangongxinxi.getImgPhoto())){
yuangongxinxi.setImgPhoto(null);
}
if(yuangongxinxiEntity==null){
yuangongxinxiService.updateById(yuangongxinxi);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
logger.debug("Controller:"+this.getClass().getName()+",delete");
yuangongxinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
文章来源:https://www.toymoban.com/news/detail-654072.html
文章来源地址https://www.toymoban.com/news/detail-654072.html
package com.controller;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.annotation.IgnoreAuth;
import com.entity.UserEntity;
import com.entity.YonghuxinxiEntity;
import com.service.TokenService;
import com.utils.MPUtil;
import org.apache.commons.lang3.StringUtils;
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.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.YonghuxinxiEntity;
import com.service.YonghuxinxiService;
import com.utils.PageUtils;
import com.utils.R;
/**
*
* 后端接口
* @author
* @email
* @date 2021-02-05
*/
@RestController
@Controller
@RequestMapping("/yonghuxinxi")
public class YonghuxinxiController {
private static final Logger logger = LoggerFactory.getLogger(YonghuxinxiController.class);
@Autowired
private YonghuxinxiService yonghuxinxiService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String role, HttpServletRequest request) {
YonghuxinxiEntity user = yonghuxinxiService.selectOne(new EntityWrapper<YonghuxinxiEntity>().eq("account", username));
if(user != null){
if(!user.getRole().equals(role)){
return R.error("权限不正常");
}
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),user.getName(), "users", user.getRole());
return R.ok().put("token", token);
}else{
return R.error("账号或密码或权限不对");
}
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody YonghuxinxiEntity user){
if(yonghuxinxiService.selectOne(new EntityWrapper<YonghuxinxiEntity>().eq("account", user.getAccount())) !=null) {
return R.error("用户已存在");
}
user.setRole("用户");
yonghuxinxiService.insert(user);
return R.ok();
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
YonghuxinxiEntity user = yonghuxinxiService.selectOne(new EntityWrapper<YonghuxinxiEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
yonghuxinxiService.update(user,null);
return R.ok("密码已重置为:123456");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
YonghuxinxiEntity user = yonghuxinxiService.selectById(id);
return R.ok().put("data", user);
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",page方法");
Object role = request.getSession().getAttribute("role");
PageUtils page = null;
if(role.equals("用户")){
params.put("yh",request.getSession().getAttribute("userId"));
page = yonghuxinxiService.queryPage(params);
}else{
page = yonghuxinxiService.queryPage(params);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("Controller:"+this.getClass().getName()+",info方法");
YonghuxinxiEntity yonghuxinxi = yonghuxinxiService.selectById(id);
if(yonghuxinxi!=null){
return R.ok().put("data", yonghuxinxi);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@IgnoreAuth
@RequestMapping("/save")
public R save(@RequestBody YonghuxinxiEntity yonghuxinxi, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",save");
Wrapper<YonghuxinxiEntity> queryWrapper = new EntityWrapper<YonghuxinxiEntity>()
.eq("name", yonghuxinxi.getName())
.eq("account", yonghuxinxi.getAccount())
.eq("password", yonghuxinxi.getPassword())
.eq("role", yonghuxinxi.getRole())
;
yonghuxinxi.setRole("用户");
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuxinxiEntity yonghuxinxiEntity = yonghuxinxiService.selectOne(queryWrapper);
if("".equals(yonghuxinxi.getImgPhoto()) || "null".equals(yonghuxinxi.getImgPhoto())){
yonghuxinxi.setImgPhoto(null);
}
if(yonghuxinxiEntity==null){
yonghuxinxiService.insert(yonghuxinxi);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YonghuxinxiEntity yonghuxinxi, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",update");
//根据字段查询是否有相同数据
Wrapper<YonghuxinxiEntity> queryWrapper = new EntityWrapper<YonghuxinxiEntity>()
.notIn("id",yonghuxinxi.getId())
.eq("name", yonghuxinxi.getName())
.eq("account", yonghuxinxi.getAccount())
.eq("password", yonghuxinxi.getPassword())
.eq("role", yonghuxinxi.getRole())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuxinxiEntity yonghuxinxiEntity = yonghuxinxiService.selectOne(queryWrapper);
if("".equals(yonghuxinxi.getImgPhoto()) || "null".equals(yonghuxinxi.getImgPhoto())){
yonghuxinxi.setImgPhoto(null);
}
if(yonghuxinxiEntity==null){
yonghuxinxiService.updateById(yonghuxinxi);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
logger.debug("Controller:"+this.getClass().getName()+",delete");
yonghuxinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
到了这里,关于ssm基于Java ssm的校园驿站管理系统源码和论文的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!