开发语言:Java
框架:ssm
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
安卓框架:uniapp
安卓开发软件:HBuilder X
开发模式:混合开发
数据库:
DROP TABLE IF EXISTS `address`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `address` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘主键’,
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间’,
`userid` bigint(20) NOT NULL COMMENT ‘用户id’,
`address` varchar(200) NOT NULL COMMENT ‘地址’,
`name` varchar(200) NOT NULL COMMENT ‘收货人’,
`phone` varchar(200) NOT NULL COMMENT ‘电话’,
`isdefault` varchar(200) NOT NULL COMMENT ‘是否默认地址[是/否]’,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT=’地址’;
/*!40101 SET character_set_client = @saved_cs_client */;
—
— Dumping data for table `address`
—
LOCK TABLES `address` WRITE;
/*!40000 ALTER TABLE `address` DISABLE KEYS */;
INSERT INTO `address` VALUES (1,’2022-04-13 07:00:47′,11,’宇宙银河系金星1号’,’金某’,’13823888881′,’是’),(2,’2022-04-13 07:00:47′,12,’宇宙银河系木星1号’,’木某’,’13823888882′,’是’),(3,’2022-04-13 07:00:47′,13,’宇宙银河系水星1号’,’水某’,’13823888883′,’是’),(4,’2022-04-13 07:00:47′,14,’宇宙银河系火星1号’,’火某’,’13823888884′,’是’),(5,’2022-04-13 07:00:47′,15,’宇宙银河系土星1号’,’土某’,’13823888885′,’是’),(6,’2022-04-13 07:00:47′,16,’宇宙银河系月球1号’,’月某’,’13823888886′,’是’);
/*!40000 ALTER TABLE `address` ENABLE KEYS */;
UNLOCK TABLES;
—
— Table structure for table `caipinfenlei`
—
DROP TABLE IF EXISTS `caipinfenlei`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `caipinfenlei` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘主键’,
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间’,
`caipinfenlei` varchar(200) NOT NULL COMMENT ‘菜品分类’,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1649833643836 DEFAULT CHARSET=utf8 COMMENT=’菜品分类’;
/*!40101 SET character_set_client = @saved_cs_client */;
—
— Dumping data for table `caipinfenlei`
—
LOCK TABLES `caipinfenlei` WRITE;
/*!40000 ALTER TABLE `caipinfenlei` DISABLE KEYS */;
INSERT INTO `caipinfenlei` VALUES (41,’2022-04-13 07:00:47′,’菜品分类1′),(42,’2022-04-13 07:00:47′,’菜品分类2′),(43,’2022-04-13 07:00:47′,’菜品分类3′),(44,’2022-04-13 07:00:47′,’菜品分类4′),(45,’2022-04-13 07:00:47′,’菜品分类5′),(46,’2022-04-13 07:00:47′,’菜品分类6′),(1649833643835,’2022-04-13 07:07:23′,’西餐’);
/*!40000 ALTER TABLE `caipinfenlei` ENABLE KEYS */;
UNLOCK TABLES;
—
— Table structure for table `caipinxinxi`
—
DROP TABLE IF EXISTS `caipinxinxi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `caipinxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘主键’,
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间’,
`caipinbianhao` varchar(200) DEFAULT NULL COMMENT ‘菜品编号’,
`dianpuxinxi` varchar(200) DEFAULT NULL COMMENT ‘店铺信息’,
`caipinmingcheng` varchar(200) NOT NULL COMMENT ‘菜品名称’,
`caipinfenlei` varchar(200) NOT NULL COMMENT ‘菜品分类’,
`kouwei` varchar(200) DEFAULT NULL COMMENT ‘口味’,
`fenliang` varchar(200) DEFAULT NULL COMMENT ‘份量’,
`tupian` varchar(200) DEFAULT NULL COMMENT ‘图片’,
`shangjiariqi` date DEFAULT NULL COMMENT ‘上架日期’,
`caipinjieshao` longtext COMMENT ‘菜品介绍’,
`shangjiazhanghao` varchar(200) DEFAULT NULL COMMENT ‘商家账号’,
`shangjiaxingming` varchar(200) DEFAULT NULL COMMENT ‘商家姓名’,
`price` float DEFAULT NULL COMMENT ‘价格’,
`onelimittimes` int(11) DEFAULT ‘-1’ COMMENT ‘单限’,
`alllimittimes` int(11) DEFAULT ‘-1’ COMMENT ‘库存’,
PRIMARY KEY (`id`),
UNIQUE KEY `caipinbianhao` (`caipinbianhao`)
) ENGINE=InnoDB AUTO_INCREMENT=1649833735169 DEFAULT CHARSET=utf8 COMMENT=’菜品信息’;
/*!40101 SET character_set_client = @saved_cs_client */;
业务逻辑代码:
@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<YonghuEntity>().eq(“yonghuzhanghao”, username));
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<YonghuEntity>().eq(“yonghuzhanghao”, yonghu.getYonghuzhanghao()));
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<YonghuEntity>().eq(“yonghuzhanghao”, username));
if(user==null) {
return R.error(“账号不存在”);
}
user.setMima(“123456”);
yonghuService.updateById(user);
return R.ok(“密码已重置为:123456”);
}
/**
* 后端列表
*/
@RequestMapping(“/page”)
public R page(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
HttpServletRequest request){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
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<String, Object> params,YonghuEntity yonghu,
HttpServletRequest request){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put(“data”, page);
}