开发语言:Java
框架:ssm
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
数据库脚本:
DROP TABLE IF EXISTS `chat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `chat` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`userid` bigint(20) NOT NULL COMMENT '用户id',
`adminid` bigint(20) DEFAULT NULL COMMENT '管理员id',
`ask` longtext COMMENT '提问',
`reply` longtext COMMENT '回复',
`isreply` int(11) DEFAULT NULL COMMENT '是否回复',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8 COMMENT='在线留言';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `chat`
--
LOCK TABLES `chat` WRITE;
/*!40000 ALTER TABLE `chat` DISABLE KEYS */;
INSERT INTO `chat` VALUES (51,'2022-02-27 13:29:35',1,1,'提问1','回复1',1),(52,'2022-02-27 13:29:35',2,2,'提问2','回复2',2),(53,'2022-02-27 13:29:35',3,3,'提问3','回复3',3),(54,'2022-02-27 13:29:35',4,4,'提问4','回复4',4),(55,'2022-02-27 13:29:35',5,5,'提问5','回复5',5),(56,'2022-02-27 13:29:35',6,6,'提问6','回复6',6);
/*!40000 ALTER TABLE `chat` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `config`
--
DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(100) NOT NULL COMMENT '配置参数名称',
`value` varchar(100) DEFAULT NULL COMMENT '配置参数值',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='配置文件';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `config`
--
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
INSERT INTO `config` VALUES (1,'picture1','upload/picture1.jpg'),(2,'picture2','upload/picture2.jpg'),(3,'picture3','upload/picture3.jpg');
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `dingpiaoxinxi`
--
DROP TABLE IF EXISTS `dingpiaoxinxi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dingpiaoxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`dingdanbianhao` varchar(200) DEFAULT NULL COMMENT '订单编号',
`hangbanbianhao` varchar(200) DEFAULT NULL COMMENT '航班编号',
`hangkonggongsi` varchar(200) DEFAULT NULL COMMENT '航空公司',
`chufadi` varchar(200) DEFAULT NULL COMMENT '出发地',
`mudedi` varchar(200) DEFAULT NULL COMMENT '目的地',
`feixingfangshi` varchar(200) DEFAULT NULL COMMENT '飞行方式',
`chufashijian` datetime DEFAULT NULL COMMENT '出发时间',
`piaojia` float DEFAULT NULL COMMENT '票价',
`shuliang` int(11) NOT NULL COMMENT '数量',
`zongjine` float DEFAULT NULL COMMENT '总金额',
`yonghuzhanghao` varchar(200) DEFAULT NULL COMMENT '用户账号',
`yonghuxingming` varchar(200) DEFAULT NULL COMMENT '用户姓名',
`lianxidianhua` varchar(200) DEFAULT NULL COMMENT '联系电话',
`shenfenzhenghao` varchar(200) DEFAULT NULL COMMENT '身份证号',
`goupiaoriqi` date DEFAULT NULL COMMENT '购票日期',
`ispay` varchar(200) DEFAULT '未支付' COMMENT '是否支付',
PRIMARY KEY (`id`),
UNIQUE KEY `dingdanbianhao` (`dingdanbianhao`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COMMENT='订票信息';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `dingpiaoxinxi`
--
LOCK TABLES `dingpiaoxinxi` WRITE;
/*!40000 ALTER TABLE `dingpiaoxinxi` DISABLE KEYS */;
INSERT INTO `dingpiaoxinxi` VALUES (31,'2022-02-27 13:29:35','1111111111','航班编号1','航空公司1','出发地1','目的地1','飞行方式1','2022-02-27 21:29:35',1,1,1,'用户账号1','用户姓名1','联系电话1','身份证号1','2022-02-27','未支付'),(32,'2022-02-27 13:29:35','2222222222','航班编号2','航空公司2','出发地2','目的地2','飞行方式2','2022-02-27 21:29:35',2,2,2,'用户账号2','用户姓名2','联系电话2','身份证号2','2022-02-27','未支付'),(33,'2022-02-27 13:29:35','3333333333','航班编号3','航空公司3','出发地3','目的地3','飞行方式3','2022-02-27 21:29:35',3,3,3,'用户账号3','用户姓名3','联系电话3','身份证号3','2022-02-27','未支付'),(34,'2022-02-27 13:29:35','4444444444','航班编号4','航空公司4','出发地4','目的地4','飞行方式4','2022-02-27 21:29:35',4,4,4,'用户账号4','用户姓名4','联系电话4','身份证号4','2022-02-27','未支付'),(35,'2022-02-27 13:29:35','5555555555','航班编号5','航空公司5','出发地5','目的地5','飞行方式5','2022-02-27 21:29:35',5,5,5,'用户账号5','用户姓名5','联系电话5','身份证号5','2022-02-27','未支付'),(36,'2022-02-27 13:29:35','6666666666','航班编号6','航空公司6','出发地6','目的地6','飞行方式6','2022-02-27 21:29:35',6,6,6,'用户账号6','用户姓名6','联系电话6','身份证号6','2022-02-27','未支付');
/*!40000 ALTER TABLE `dingpiaoxinxi` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `discussjipiaoxinxi`
--
DROP TABLE IF EXISTS `discussjipiaoxinxi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `discussjipiaoxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`refid` bigint(20) NOT NULL COMMENT '关联表id',
`userid` bigint(20) NOT NULL COMMENT '用户id',
`nickname` varchar(200) DEFAULT NULL COMMENT '用户名',
`content` longtext NOT NULL COMMENT '评论内容',
`reply` longtext COMMENT '回复内容',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=87 DEFAULT CHARSET=utf8 COMMENT='机票信息评论表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `discussjipiaoxinxi`
--
LOCK TABLES `discussjipiaoxinxi` WRITE;
/*!40000 ALTER TABLE `discussjipiaoxinxi` DISABLE KEYS */;
INSERT INTO `discussjipiaoxinxi` VALUES (81,'2022-02-27 13:29:36',1,1,'用户名1','评论内容1','回复内容1'),(82,'2022-02-27 13:29:36',2,2,'用户名2','评论内容2','回复内容2'),(83,'2022-02-27 13:29:36',3,3,'用户名3','评论内容3','回复内容3'),(84,'2022-02-27 13:29:36',4,4,'用户名4','评论内容4','回复内容4'),(85,'2022-02-27 13:29:36',5,5,'用户名5','评论内容5','回复内容5'),(86,'2022-02-27 13:29:36',6,6,'用户名6','评论内容6','回复内容6');
/*!40000 ALTER TABLE `discussjipiaoxinxi` ENABLE KEYS */;
UNLOCK TABLES;
业务逻辑代码:
/**
* 用户
* 后端接口
* @author
* @email
* @date 2022-02-27 21:28:50
*/
@RestController
@RequestMapping("/yonghu")
public class YonghuController {
@Autowired
private YonghuService yonghuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
YonghuEntity user = yonghuService.selectOne(new EntityWrapper
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"yonghu", "用户" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody YonghuEntity yonghu){
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
yonghu.setId(uId);
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
YonghuEntity user = yonghuService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
YonghuEntity user = yonghuService.selectOne(new EntityWrapper
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
yonghuService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map
HttpServletRequest request){
EntityWrapper
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map
HttpServletRequest request){
EntityWrapper
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( YonghuEntity yonghu){
EntityWrapper
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
return R.ok().put("data", yonghuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(YonghuEntity yonghu){
EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
YonghuView yonghuView = yonghuService.selectView(ew);
return R.ok("查询用户成功").put("data", yonghuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
YonghuEntity yonghu = yonghuService.selectById(id);
return R.ok().put("data", yonghu);
}