parent
9485f58453
commit
836f6b3bf7
@ -0,0 +1,86 @@ |
||||
-- MySQL dump 10.13 Distrib 8.0.20, for Linux (x86_64) |
||||
-- |
||||
-- Host: localhost Database: dmmdb |
||||
-- ------------------------------------------------------ |
||||
-- Server version 8.0.20 |
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; |
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; |
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; |
||||
/*!50503 SET NAMES utf8mb4 */; |
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; |
||||
/*!40103 SET TIME_ZONE='+00:00' */; |
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; |
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; |
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; |
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; |
||||
|
||||
-- |
||||
-- Table structure for table `m_menu` |
||||
-- |
||||
|
||||
DROP TABLE IF EXISTS `m_menu`; |
||||
/*!40101 SET @saved_cs_client = @@character_set_client */; |
||||
/*!50503 SET character_set_client = utf8mb4 */; |
||||
CREATE TABLE `m_menu` ( |
||||
`ID` char(3) NOT NULL, |
||||
`FENLEI` varchar(20) NOT NULL, |
||||
`PINMU` varchar(20) NOT NULL, |
||||
`CAILIAO` varchar(20) NOT NULL, |
||||
`JIAGE` int NOT NULL, |
||||
PRIMARY KEY (`ID`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
/*!40101 SET character_set_client = @saved_cs_client */; |
||||
|
||||
-- |
||||
-- Dumping data for table `m_menu` |
||||
-- |
||||
|
||||
LOCK TABLES `m_menu` WRITE; |
||||
/*!40000 ALTER TABLE `m_menu` DISABLE KEYS */; |
||||
INSERT INTO `m_menu` VALUES ('001','正菜','肉类','牛肉',50),('002','正菜','肉类','猪肉',30),('003','正菜','肉类','鸡肉',20),('004','正菜','蔬菜','白菜',10),('005','正菜','蔬菜','黄瓜',10),('006','正菜','海鲜','大虾',40),('007','正菜','海鲜','黄鱼',40),('008','主食','米饭','白饭',3),('009','主食','米饭','炒饭',10),('010','主食','面条','凉拌',12),('011','主食','面条','打卤',15),('012','主食','水饺','素馅',15),('013','主食','水饺','肉馅',20),('014','酒水','白酒','茅台',1000),('015','酒水','白酒','郎酒',500),('016','酒水','啤酒','雪花',5),('017','酒水','啤酒','哈啤',6),('018','酒水','饮料','可乐',3),('019','酒水','饮料','雪碧',3); |
||||
/*!40000 ALTER TABLE `m_menu` ENABLE KEYS */; |
||||
UNLOCK TABLES; |
||||
|
||||
-- |
||||
-- Table structure for table `tbl_diancan` |
||||
-- |
||||
|
||||
DROP TABLE IF EXISTS `tbl_diancan`; |
||||
/*!40101 SET @saved_cs_client = @@character_set_client */; |
||||
/*!50503 SET character_set_client = utf8mb4 */; |
||||
CREATE TABLE `tbl_diancan` ( |
||||
`ZHUOHAO` char(11) NOT NULL, |
||||
`XINGMING` varchar(15) NOT NULL, |
||||
`YUDING` tinyint(1) NOT NULL, |
||||
`BIRTHDAY` datetime NOT NULL, |
||||
`RENSHU` int DEFAULT NULL, |
||||
`TEL` varchar(20) DEFAULT NULL, |
||||
`CAIPIN` varchar(100) DEFAULT NULL, |
||||
`ZHUSHI` varchar(100) DEFAULT NULL, |
||||
`JIUSHUI` varchar(100) DEFAULT NULL, |
||||
`JINE` int DEFAULT NULL, |
||||
`BEIZHU` varchar(200) DEFAULT NULL, |
||||
PRIMARY KEY (`ZHUOHAO`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
/*!40101 SET character_set_client = @saved_cs_client */; |
||||
|
||||
-- |
||||
-- Dumping data for table `tbl_diancan` |
||||
-- |
||||
|
||||
LOCK TABLES `tbl_diancan` WRITE; |
||||
/*!40000 ALTER TABLE `tbl_diancan` DISABLE KEYS */; |
||||
/*!40000 ALTER TABLE `tbl_diancan` ENABLE KEYS */; |
||||
UNLOCK TABLES; |
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; |
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; |
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; |
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; |
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; |
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; |
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; |
||||
|
||||
-- Dump completed on 2020-07-14 22:58:56 |
@ -0,0 +1,8 @@ |
||||
package com.example.demo; |
||||
|
||||
public class Constants { |
||||
public static final String SPAN_NAME = "span_name"; |
||||
public static final String LIST = "list"; |
||||
public static final String QUERY = "query"; |
||||
public static final String FENLEI = "fenlei"; |
||||
} |
@ -1,17 +1,128 @@ |
||||
package com.example.demo.controller; |
||||
|
||||
import com.example.demo.model.JsonResponse; |
||||
import com.example.demo.model.Result; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import com.example.demo.Constants; |
||||
import com.example.demo.model.Diancan; |
||||
import com.example.demo.model.DiancanForm; |
||||
import com.example.demo.model.Menu; |
||||
import com.example.demo.repository.DiancanRespository; |
||||
import com.example.demo.repository.MenuRepository; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.ui.Model; |
||||
import org.springframework.util.StringUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
import javax.persistence.criteria.Predicate; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Controller |
||||
@RequestMapping("/api") |
||||
public class WebController { |
||||
|
||||
@GetMapping("/hello") |
||||
public JsonResponse<String> result(){ |
||||
return new JsonResponse<>(Result.OK, "hello"); |
||||
@Autowired |
||||
private MenuRepository menuRepository; |
||||
|
||||
@Autowired |
||||
private DiancanRespository diancanRespository; |
||||
|
||||
@RequestMapping("/index") |
||||
public String index(Model model,Diancan diancan){ |
||||
List<Diancan> diancans= diancanRespository.findAll((root,query,cb)->{ |
||||
List<Predicate> predicates = new ArrayList<>(); |
||||
if(!StringUtils.isEmpty(diancan.getZhuohao())){ |
||||
predicates.add(cb.like(root.get("zhuohao"),"%"+diancan.getZhuohao()+"%")); |
||||
} |
||||
if(!StringUtils.isEmpty(diancan.getXingming())){ |
||||
predicates.add(cb.like(root.get("xingming"),"%"+diancan.getXingming()+"%")); |
||||
} |
||||
if(!StringUtils.isEmpty(diancan.getTel())){ |
||||
predicates.add(cb.equal(root.get("tel"),diancan.getTel())); |
||||
} |
||||
if(diancan.getYuding()!=null){ |
||||
predicates.add(cb.equal(root.get("yuding"),diancan.getYuding())); |
||||
} |
||||
return query.where(predicates.toArray(new Predicate[0])).getRestriction(); |
||||
}); |
||||
model.addAttribute(Constants.LIST,diancans); |
||||
if(diancan.getYuding()==null){ |
||||
diancan.setYuding(true); |
||||
} |
||||
model.addAttribute(Constants.QUERY,diancan); |
||||
return "index"; |
||||
} |
||||
|
||||
@RequestMapping("/order/del/{id}") |
||||
public void del(Model model, @PathVariable String id, HttpServletResponse response) throws IOException { |
||||
diancanRespository.deleteById(id); |
||||
response.sendRedirect("/api/index"); |
||||
} |
||||
|
||||
@GetMapping("/order") |
||||
public String getOrder(Model model){ |
||||
model.addAttribute(Constants.SPAN_NAME,"点餐画面"); |
||||
model.addAttribute(Constants.FENLEI,menuRepository.getFenlei()); |
||||
return "order"; |
||||
} |
||||
|
||||
@PostMapping("/order") |
||||
public void postOrder(Model model, HttpServletResponse response, DiancanForm diancanForm) throws IOException { |
||||
response.sendRedirect("/api/index"); |
||||
} |
||||
|
||||
@GetMapping("/order/{id}") |
||||
public String getEditOrder(Model model,@PathVariable String id){ |
||||
model.addAttribute(Constants.SPAN_NAME,"修改画面"); |
||||
return "order"; |
||||
} |
||||
|
||||
@PostMapping("/order/{id}") |
||||
public void postEditOrder(Model model,@PathVariable String id,HttpServletResponse response) throws IOException { |
||||
response.sendRedirect("/api/index"); |
||||
} |
||||
|
||||
@GetMapping("/order/detail/{id}") |
||||
public String getDetailOrder(Model model,@PathVariable String id){ |
||||
model.addAttribute(Constants.SPAN_NAME,"详细画面"); |
||||
return "order"; |
||||
} |
||||
|
||||
@GetMapping("/order/pay/{id}") |
||||
public String getPayOrder(Model model,@PathVariable String id){ |
||||
model.addAttribute(Constants.SPAN_NAME,"支付画面"); |
||||
return "order"; |
||||
} |
||||
|
||||
@GetMapping(path = "/getPinMu",produces = {"application/json;charset=UTF-8"}) |
||||
@ResponseBody |
||||
public List<String> getPinMu(Menu menu){ |
||||
if( !StringUtils.isEmpty(menu.getFenlei())){ |
||||
return menuRepository.getPinmuByFenlei(menu.getFenlei()); |
||||
}else{ |
||||
return new ArrayList<>(); |
||||
} |
||||
} |
||||
|
||||
@GetMapping(path = "/getMenu",produces = {"application/json;charset=UTF-8"}) |
||||
@ResponseBody |
||||
public List<Menu> getMenu(Menu menu){ |
||||
if( !StringUtils.isEmpty(menu.getFenlei())&&!StringUtils.isEmpty(menu.getPinmu())){ |
||||
return menuRepository.findByFenleiAndPinmu(menu.getFenlei(),menu.getPinmu()); |
||||
}else{ |
||||
return new ArrayList<>(); |
||||
} |
||||
} |
||||
|
||||
@GetMapping(path = "/hasYuding",produces = {"application/json;charset=UTF-8"}) |
||||
@ResponseBody |
||||
public Boolean hasYuding(Diancan diancan){ |
||||
if(!StringUtils.isEmpty(diancan.getZhuohao())){ |
||||
return diancanRespository.countByZhuohao(diancan.getZhuohao())==1; |
||||
}else{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,23 @@ |
||||
package com.example.demo.model; |
||||
|
||||
public class CaiDan { |
||||
private String cailiao; |
||||
|
||||
private String sum; |
||||
|
||||
public String getCailiao() { |
||||
return cailiao; |
||||
} |
||||
|
||||
public void setCailiao(String cailiao) { |
||||
this.cailiao = cailiao; |
||||
} |
||||
|
||||
public String getSum() { |
||||
return sum; |
||||
} |
||||
|
||||
public void setSum(String sum) { |
||||
this.sum = sum; |
||||
} |
||||
} |
@ -0,0 +1,124 @@ |
||||
package com.example.demo.model; |
||||
|
||||
import javax.persistence.Column; |
||||
import javax.persistence.Entity; |
||||
import javax.persistence.Id; |
||||
import java.util.Date; |
||||
|
||||
@Entity(name = "tbl_diancan") |
||||
public class Diancan { |
||||
|
||||
@Id |
||||
private String zhuohao; |
||||
|
||||
@Column(nullable = false) |
||||
private String xingming; |
||||
|
||||
@Column(nullable = false) |
||||
private Boolean yuding; |
||||
|
||||
@Column(nullable = false) |
||||
private Date birthday; |
||||
|
||||
private Integer renshu; |
||||
|
||||
private String tel; |
||||
|
||||
private String caipin; |
||||
|
||||
private String zhushi; |
||||
|
||||
private String jiushui; |
||||
|
||||
private Integer jine; |
||||
|
||||
private String beizhu; |
||||
|
||||
public String getZhuohao() { |
||||
return zhuohao; |
||||
} |
||||
|
||||
public void setZhuohao(String zhuohao) { |
||||
this.zhuohao = zhuohao; |
||||
} |
||||
|
||||
public String getXingming() { |
||||
return xingming; |
||||
} |
||||
|
||||
public void setXingming(String xingming) { |
||||
this.xingming = xingming; |
||||
} |
||||
|
||||
public Boolean getYuding() { |
||||
return yuding; |
||||
} |
||||
|
||||
public void setYuding(Boolean yuding) { |
||||
this.yuding = yuding; |
||||
} |
||||
|
||||
public Date getBirthday() { |
||||
return birthday; |
||||
} |
||||
|
||||
public void setBirthday(Date birthday) { |
||||
this.birthday = birthday; |
||||
} |
||||
|
||||
public Integer getRenshu() { |
||||
return renshu; |
||||
} |
||||
|
||||
public void setRenshu(Integer renshu) { |
||||
this.renshu = renshu; |
||||
} |
||||
|
||||
public String getTel() { |
||||
return tel; |
||||
} |
||||
|
||||
public void setTel(String tel) { |
||||
this.tel = tel; |
||||
} |
||||
|
||||
public String getCaipin() { |
||||
return caipin; |
||||
} |
||||
|
||||
public void setCaipin(String caipin) { |
||||
this.caipin = caipin; |
||||
} |
||||
|
||||
public String getZhushi() { |
||||
return zhushi; |
||||
} |
||||
|
||||
public void setZhushi(String zhushi) { |
||||
this.zhushi = zhushi; |
||||
} |
||||
|
||||
public String getJiushui() { |
||||
return jiushui; |
||||
} |
||||
|
||||
public void setJiushui(String jiushui) { |
||||
this.jiushui = jiushui; |
||||
} |
||||
|
||||
public Integer getJine() { |
||||
return jine; |
||||
} |
||||
|
||||
public void setJine(Integer jine) { |
||||
this.jine = jine; |
||||
} |
||||
|
||||
public String getBeizhu() { |
||||
return beizhu; |
||||
} |
||||
|
||||
public void setBeizhu(String beizhu) { |
||||
this.beizhu = beizhu; |
||||
} |
||||
} |
@ -0,0 +1,96 @@ |
||||
package com.example.demo.model; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class DiancanForm { |
||||
private String zhuohao; |
||||
|
||||
private String xingming; |
||||
|
||||
private String birthday; |
||||
|
||||
private String shijian; |
||||
|
||||
private String tel; |
||||
|
||||
private Integer jine; |
||||
|
||||
private String beizhu; |
||||
|
||||
private Integer renshu; |
||||
|
||||
List<CaiDan> diancans=new ArrayList<>(); |
||||
|
||||
public String getZhuohao() { |
||||
return zhuohao; |
||||
} |
||||
|
||||
public void setZhuohao(String zhuohao) { |
||||
this.zhuohao = zhuohao; |
||||
} |
||||
|
||||
public String getXingming() { |
||||
return xingming; |
||||
} |
||||
|
||||
public void setXingming(String xingming) { |
||||
this.xingming = xingming; |
||||
} |
||||
|
||||
public String getBirthday() { |
||||
return birthday; |
||||
} |
||||
|
||||
public void setBirthday(String birthday) { |
||||
this.birthday = birthday; |
||||
} |
||||
|
||||
public String getShijian() { |
||||
return shijian; |
||||
} |
||||
|
||||
public void setShijian(String shijian) { |
||||
this.shijian = shijian; |
||||
} |
||||
|
||||
public String getTel() { |
||||
return tel; |
||||
} |
||||
|
||||
public void setTel(String tel) { |
||||
this.tel = tel; |
||||
} |
||||
|
||||
public Integer getJine() { |
||||
return jine; |
||||
} |
||||
|
||||
public void setJine(Integer jine) { |
||||
this.jine = jine; |
||||
} |
||||
|
||||
public String getBeizhu() { |
||||
return beizhu; |
||||
} |
||||
|
||||
public void setBeizhu(String beizhu) { |
||||
this.beizhu = beizhu; |
||||
} |
||||
|
||||
public List<CaiDan> getDiancans() { |
||||
return diancans; |
||||
} |
||||
|
||||
public void setDiancans(List<CaiDan> diancans) { |
||||
this.diancans = diancans; |
||||
} |
||||
|
||||
public Integer getRenshu() { |
||||
return renshu; |
||||
} |
||||
|
||||
public void setRenshu(Integer renshu) { |
||||
this.renshu = renshu; |
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
package com.example.demo.model; |
||||
|
||||
import javax.persistence.Column; |
||||
import javax.persistence.Entity; |
||||
import javax.persistence.Id; |
||||
|
||||
@Entity(name = "m_menu") |
||||
public class Menu { |
||||
|
||||
@Id |
||||
private String id; |
||||
|
||||
@Column(nullable = false) |
||||
private String fenlei; |
||||
@Column(nullable = false) |
||||
private String pinmu; |
||||
@Column(nullable = false) |
||||
private String cailiao; |
||||
@Column(nullable = false) |
||||
private Integer jiage; |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public void setFenlei(String fenlei) { |
||||
this.fenlei = fenlei; |
||||
} |
||||
|
||||
public void setPinmu(String pinmu) { |
||||
this.pinmu = pinmu; |
||||
} |
||||
|
||||
public void setCailiao(String cailiao) { |
||||
this.cailiao = cailiao; |
||||
} |
||||
|
||||
public void setJiage(Integer jiage) { |
||||
this.jiage = jiage; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public String getFenlei() { |
||||
return fenlei; |
||||
} |
||||
|
||||
public String getPinmu() { |
||||
return pinmu; |
||||
} |
||||
|
||||
public String getCailiao() { |
||||
return cailiao; |
||||
} |
||||
|
||||
public Integer getJiage() { |
||||
return jiage; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package com.example.demo.repository; |
||||
|
||||
import com.example.demo.model.Diancan; |
||||
import org.springframework.data.jpa.repository.JpaRepository; |
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
||||
|
||||
public interface DiancanRespository extends JpaRepository<Diancan,String>, JpaSpecificationExecutor<Diancan> { |
||||
Integer countByZhuohao(String zhuohao); |
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.example.demo.repository; |
||||
|
||||
import com.example.demo.model.Menu; |
||||
import org.springframework.data.jpa.repository.JpaRepository; |
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
||||
import org.springframework.data.jpa.repository.Query; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface MenuRepository extends JpaRepository<Menu,String>, JpaSpecificationExecutor<Menu> { |
||||
List<Menu> findByFenleiAndPinmu(String fenlei, String pinmu); |
||||
|
||||
@Query("select distinct fenlei from com.example.demo.model.Menu") |
||||
List<String> getFenlei(); |
||||
|
||||
@Query("select distinct pinmu from com.example.demo.model.Menu m where m.fenlei=?1") |
||||
List<String> getPinmuByFenlei(String fenlei); |
||||
} |
@ -0,0 +1,16 @@ |
||||
spring: |
||||
thymeleaf: |
||||
prefix: classpath:/templates/ |
||||
cache: false |
||||
datasource: |
||||
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
url: jdbc:mysql://localhost:3306/dmmdb |
||||
username: sukura |
||||
password: 123456 |
||||
jpa: |
||||
properties: |
||||
hibernate: |
||||
dialect: org.hibernate.dialect.MySQL8Dialect |
||||
format_sql: true |
||||
show-sql: true |
||||
|
@ -0,0 +1,18 @@ |
||||
.container { |
||||
margin: 0 auto; |
||||
min-height: 100vh; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
} |
||||
.frame { |
||||
border: 1px solid black; |
||||
padding: 30px; |
||||
} |
||||
.border-black { |
||||
border: 1px solid black; |
||||
} |
||||
.icon{ |
||||
width: 20px; |
||||
height: 20px; |
||||
} |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 408 B |
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 816 B |
After Width: | Height: | Size: 626 B |
After Width: | Height: | Size: 778 B |
@ -0,0 +1,109 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>简易点菜系统</title> |
||||
<link href="/css/index.css" rel="stylesheet"> |
||||
<link rel="stylesheet" href="/css/bootstrap.min.css" |
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> |
||||
<script> |
||||
|
||||
</script> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
<div class="frame"> |
||||
<span>检索条件</span> |
||||
<form method="post" action="#" th:action="@{/api/index}" th:object="${query}"> |
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-2 pr-2 justify-content-end"> |
||||
<span class="input-group-text">桌号</span> |
||||
</div> |
||||
<input type="text" th:field="*{zhuohao}" class="form-control col-4"> |
||||
</div> |
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-2"> |
||||
<span class="input-group-text">客人姓名</span> |
||||
</div> |
||||
<input type="text" th:field="*{xingming}" class="form-control col-4"> |
||||
<div class="input-group-prepend col-2"> |
||||
<span class="input-group-text">联系方式</span> |
||||
</div> |
||||
<input type="text" th:field="*{tel}" class="form-control col-4"> |
||||
</div> |
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-2 pr-2 justify-content-end"> |
||||
<span class="input-group-text">预定</span> |
||||
</div> |
||||
<div class="custom-control custom-radio custom-control-inline mt-auto mb-auto"> |
||||
<input type="radio" id="customRadioInline1" |
||||
class="custom-control-input" value="true" th:field="*{yuding}"> |
||||
<label class="custom-control-label" for="customRadioInline1">有</label> |
||||
</div> |
||||
<div class="custom-control custom-radio custom-control-inline mt-auto mb-auto"> |
||||
<input type="radio" id="customRadioInline2" name="yuding" class="custom-control-input" value="false" |
||||
th:field="*{yuding}"> |
||||
<label class="custom-control-label" for="customRadioInline2">无</label> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="mt-3 d-flex justify-content-between"> |
||||
<a href="/api/order" class="btn btn-secondary col-3">点餐</a> |
||||
<button type="submit" class="btn btn-secondary col-3">检索</button> |
||||
</div> |
||||
</form> |
||||
|
||||
|
||||
<hr class="border-black"/> |
||||
|
||||
<span th:text="${query.yuding?'检索结果(已定)':'检索结果(未定)'}"></span> |
||||
|
||||
<table class="table mt-3 table-bordered border-black text-center"> |
||||
<thead class="thead-light" th:switch="${query.yuding}"> |
||||
<tr th:case="true"> |
||||
<th scope="col">桌号</th> |
||||
<th scope="col">客人姓名</th> |
||||
<th scope="col">预定</th> |
||||
<th scope="col">联系方式</th> |
||||
<th scope="col">用餐时间</th> |
||||
<th scope="col">人数</th> |
||||
<th scope="col"></th> |
||||
<th scope="col"></th> |
||||
</tr> |
||||
<tr th:case="false"> |
||||
<th scope="col">桌号</th> |
||||
<th scope="col">人数</th> |
||||
<th scope="col"></th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody th:switch="${query.yuding}"> |
||||
<tr th:case="true" th:each="item:${list}"> |
||||
<th scope="row" class="p-3"><a th:href="@{'/api/order/detail/'+${item.zhuohao}}">${item.zhuohao}</a></th> |
||||
<td class="p-3">${item.xingming}</td> |
||||
<td class="p-3"> |
||||
<img th:src="@{${item.yuding?'/icon/radioactive.svg':'/icon/radioactive.svg'}}" class="icon"/> |
||||
</td> |
||||
<td class="p-3">${item.tel}</td> |
||||
<td class="p-3">${item.birthday}</td> |
||||
<td class="p-3">${item.renshu}</td> |
||||
<td> |
||||
<a th:href="@{'/api/order/'+${item.zhuohao}}" class="btn btn-secondary">修改</a> |
||||
</td> |
||||
<td> |
||||
<a th:href="@{'/api/order/del/'+${item.zhuohao}}" class="btn btn-secondary">删除</a> |
||||
</td> |
||||
</tr> |
||||
<tr th:case="false" th:each="item:${list}"> |
||||
<th scope="row" class="p-3"><a th:href="@{'/api/order/detail/'+${item.zhuohao}}">${item.zhuohao}</a></th> |
||||
<td class="p-3">${item.renshu}</td> |
||||
<td> |
||||
<a href="/api/order" class="btn btn-secondary">点餐</a> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,238 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>简易点菜系统</title> |
||||
<link href="/css/index.css" rel="stylesheet"> |
||||
<link rel="stylesheet" href="/css/bootstrap.min.css" |
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> |
||||
<style> |
||||
.order-frame { |
||||
width: 700px |
||||
} |
||||
|
||||
.action { |
||||
cursor: pointer; |
||||
} |
||||
</style> |
||||
<script th:inline="javascript"> |
||||
onload = function () { |
||||
let item = document.getElementsByClassName('fff') |
||||
for (let i in item) { |
||||
item[i].innerHTML += getSelect() |
||||
} |
||||
} |
||||
|
||||
function getSelect() { |
||||
let fenlei = [[${fenlei}]] |
||||
let fenleistr = '' |
||||
for (let item in fenlei) { |
||||
fenleistr += `<option value="${fenlei[item]}">${fenlei[item]}</option>` |
||||
} |
||||
let count=document.querySelectorAll('select[name$=cailiao]').length |
||||
return `<select class="custom-select" name="diancans[${count}].fenlei" onchange="changeFenLei(this,this.parentElement.querySelector('select[name$=pinmu]'),this.parentElement.querySelector('select[name$=cailiao]'))"> |
||||
<option selected>请选择分类</option> |
||||
${fenleistr} |
||||
</select> |
||||
|
||||
<select class="custom-select" name="diancans[${count}].pinmu" onchange="changePinmu(this.parentElement.querySelector('select[name$=fenlei]'),this,this.parentElement.querySelector('select[name$=cailiao]'))"> |
||||
<option selected>请选择品目</option> |
||||
</select> |
||||
|
||||
<select class="custom-select" name="diancans[${count}].cailiao" required oninvalid="setCustomValidity('请选择材料')" onchange="changeCailiao(document.querySelectorAll('select[name$=cailiao]'))"> |
||||
<option selected value="">请选择材料</option> |
||||
</select> |
||||
|
||||
<input type="text" class="form-control" name="diancans[${count}].sum" placeholder="做法或数量" onchange="changeCailiao(document.querySelectorAll('select[name$=cailiao]'))">` |
||||
} |
||||
|
||||
function plus(s) { |
||||
let div = document.createElement('div') |
||||
div.classList.add('input-group', 'mt-3', 'order-frame') |
||||
div.innerHTML = `<div class="col-3 text-right mt-auto mb-auto"> |
||||
<img src="/icon/plus.svg" class="icon action" onclick="plus(this)"/> |
||||
<img src="/icon/minus.svg" class="icon action" onclick="minus(this)"/> |
||||
</div> |
||||
${getSelect()} |
||||
` |
||||
list.appendChild(div) |
||||
if (list.childElementCount > 1) { |
||||
add.classList.add('d-none') |
||||
} |
||||
} |
||||
|
||||
function minus(s) { |
||||
list.removeChild(s.parentElement.parentElement) |
||||
if (list.childElementCount === 1) { |
||||
add.classList.remove('d-none') |
||||
} |
||||
|
||||
changeCailiao(document.querySelectorAll('select[name$=cailiao]')) |
||||
} |
||||
|
||||
function changeFenLei(fenlei, pinmu, cailiao) { |
||||
pinmu.innerHTML = '<option selected>请选择品目</option>' |
||||
cailiao.innerHTML = '<option selected>请选择材料</option>' |
||||
fetch(new Request('/api/getPinMu?fenlei=' + fenlei.value)).then(res => res.json()).then(res => { |
||||
for (let index in res) { |
||||
pinmu.innerHTML += `<option>${res[index]}</option>` |
||||
} |
||||
}) |
||||
let sum=fenlei.parentElement.querySelector('input[name$=sum]') |
||||
if (fenlei.value === '正菜') { |
||||
sum.setAttribute('type', 'text') |
||||
} else { |
||||
sum.setAttribute('type', 'number') |
||||
sum.value=1 |
||||
} |
||||
|
||||
changeCailiao(document.querySelectorAll('select[name$=cailiao]')) |
||||
} |
||||
|
||||
function changePinmu(fenlei, pinmu, cailiao) { |
||||
cailiao.innerHTML = '<option selected>请选择材料</option>' |
||||
fetch(new Request(`/api/getMenu?fenlei=${fenlei.value}&pinmu=${pinmu.value}`)).then(res => res.json()).then(res => { |
||||
for (let index in res) { |
||||
cailiao.innerHTML += `<option value="${res[index].id}" jine="${res[index].jiage}">${res[index].cailiao}</option>` |
||||
} |
||||
}) |
||||
|
||||
changeCailiao(document.querySelectorAll('select[name$=cailiao]')) |
||||
} |
||||
|
||||
function changeCailiao(cailiao) { |
||||
let sum = 0 |
||||
for (let index in cailiao) { |
||||
if (cailiao[index].value !== '' && cailiao[index].selectedIndex) { |
||||
if(cailiao[index].selectedIndex!==0){ |
||||
cailiao[index].setCustomValidity('') |
||||
} |
||||
let option = cailiao[index].childNodes[cailiao[index].selectedIndex] |
||||
let value=cailiao[index].parentElement.querySelector('input[name$=sum]').value |
||||
sum += parseInt(option.getAttribute('jine'))*(/^\d+$/.test(value)?value:1) |
||||
} |
||||
} |
||||
jine.value = sum |
||||
} |
||||
|
||||
function birthdayValid(shijian) { |
||||
shijian.removeAttribute('required') |
||||
shijian.setCustomValidity('') |
||||
} |
||||
|
||||
function changeBirthday(shijian) { |
||||
shijian.setAttribute('required','required') |
||||
} |
||||
|
||||
function hasYuding(zhuohao) { |
||||
fetch(new Request(`/api/hasYuding?zhuohao=${zhuohao.value}`)).then(res=>res.json()).then(res=>{ |
||||
if(res){ |
||||
alert(`桌号${zhuohao.value}已预定!`) |
||||
zhuohao.value='' |
||||
} |
||||
}) |
||||
} |
||||
|
||||
|
||||
function checkMobie() { |
||||
let mobie=document.querySelector('input[name=tel]') |
||||
if(mobie.value.length>0&&!/^\d{11}$/.test(mobie.value)){ |
||||
mobie.setCustomValidity('手机号不合法') |
||||
}else { |
||||
mobie.setCustomValidity('') |
||||
} |
||||
} |
||||
|
||||
|
||||
</script> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
<div class="frame"> |
||||
<span th:text="${span_name}"></span> |
||||
<form method="post" action="/api/order"> |
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">桌号</span> |
||||
</div> |
||||
<input type="text" name="zhuohao" class="form-control col-4" required oninvalid="setCustomValidity('桌号不能为空')" oninput="setCustomValidity('');hasYuding(this)"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">客人姓名</span> |
||||
</div> |
||||
<input type="text" name="xingming" class="form-control col-4" oninvalid="setCustomValidity('姓名不能为空')" oninput="setCustomValidity('');" required maxlength="15"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">用餐时间</span> |
||||
</div> |
||||
<div class="custom-control custom-radio custom-control-inline mt-auto mb-auto"> |
||||
<input type="radio" id="customRadioInline1" name="birthday" checked |
||||
class="custom-control-input" value="1" onclick="birthdayValid(this.parentElement.parentElement.querySelector('input[name=shijian]'))"> |
||||
<label class="custom-control-label" for="customRadioInline1">及时单</label> |
||||
</div> |
||||
<div class="custom-control custom-radio custom-control-inline mt-auto mb-auto"> |
||||
<input type="radio" id="customRadioInline2" value="2" name="birthday" class="custom-control-input" onclick="changeBirthday(this.parentElement.parentElement.querySelector('input[name=shijian]'))"> |
||||
<label class="custom-control-label" for="customRadioInline2">指定</label> |
||||
</div> |
||||
|
||||
<input type="text" name="shijian" oninput="setCustomValidity('')" oninvalid="setCustomValidity('时间不能为空')" class="form-control col-4"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">用餐人数</span> |
||||
</div> |
||||
|
||||
<input type="number" value="1" name="renshu" class="form-control col-4"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">联系方式(手机)</span> |
||||
</div> |
||||
|
||||
<input type="text" name="tel" oninput="checkMobie()" class="form-control col-4"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3 order-frame fff"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">点餐区</span> |
||||
</div> |
||||
</div> |
||||
|
||||
<div id="list"> |
||||
<div class="input-group mt-3 order-frame d-none" id="add"> |
||||
<div class="col-3 text-right mt-auto mb-auto"> |
||||
<img src="/icon/plus.svg" class="icon action" onclick="plus(this)"/> |
||||
</div> |
||||
</div> |
||||
<div class="input-group mt-3 order-frame fff"> |
||||
<div class="col-3 text-right mt-auto mb-auto"> |
||||
<img src="/icon/plus.svg" class="icon action" onclick="plus(this)"/> |
||||
<img src="/icon/minus.svg" class="icon action" onclick="minus(this)"/> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3 justify-content-end"> |
||||
<div class="input-group-prepend"> |
||||
<span class="input-group-text">预结金额</span> |
||||
</div> |
||||
<input type="text" id="jine" name="jine" class="form-control col-2" readonly> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend"> |
||||
<span class="input-group-text">备注</span> |
||||
</div> |
||||
<textarea class="form-control" name="beizhu" aria-label="With textarea"></textarea> |
||||
</div> |
||||
<div class="mt-3 text-right"> |
||||
<button class="btn btn-secondary col-3">提交</button> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,9 @@ |
||||
Manifest-Version: 1.0 |
||||
Created-By: IntelliJ IDEA |
||||
Built-By: pan |
||||
Build-Jdk: 13.0.2 |
||||
Implementation-Title: demo |
||||
Implementation-Version: 0.0.1-SNAPSHOT |
||||
Implementation-Vendor-Id: com.example |
||||
Main-Class: ${start-class} |
||||
|
@ -1,10 +0,0 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>Title</title> |
||||
</head> |
||||
<body> |
||||
|
||||
</body> |
||||
</html> |
@ -1,7 +0,0 @@ |
||||
.container { |
||||
margin: 0 auto; |
||||
min-height: 100vh; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
} |
@ -1,175 +0,0 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>简易点菜系统</title> |
||||
<link href="index.css" rel="stylesheet"> |
||||
<link rel="stylesheet" href="bootstrap.min.css" |
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> |
||||
<style> |
||||
.frame { |
||||
border: 1px solid black; |
||||
padding: 30px; |
||||
} |
||||
.order-frame{ |
||||
width:700px |
||||
} |
||||
.icon{ |
||||
width: 20px; |
||||
height: 20px; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
<div class="frame"> |
||||
<span>点餐画面</span> |
||||
<form> |
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">桌号</span> |
||||
</div> |
||||
<input type="text" class="form-control col-4"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">客人姓名</span> |
||||
</div> |
||||
<input type="text" class="form-control col-4"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">预定</span> |
||||
</div> |
||||
<div class="custom-control custom-radio custom-control-inline mt-auto mb-auto"> |
||||
<input type="radio" id="customRadioInline1" name="customRadioInline1" checked |
||||
class="custom-control-input"> |
||||
<label class="custom-control-label" for="customRadioInline1">及时单</label> |
||||
</div> |
||||
<div class="custom-control custom-radio custom-control-inline mt-auto mb-auto"> |
||||
<input type="radio" id="customRadioInline2" name="customRadioInline1" class="custom-control-input"> |
||||
<label class="custom-control-label" for="customRadioInline2">指定</label> |
||||
</div> |
||||
|
||||
<input type="text" class="form-control col-4"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">联系方式(手机)</span> |
||||
</div> |
||||
|
||||
<input type="text" class="form-control col-4"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3 order-frame"> |
||||
<div class="input-group-prepend col-3 pr-2 justify-content-end"> |
||||
<span class="input-group-text">点餐区</span> |
||||
</div> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择分类</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择品目</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择材料</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<input type="text" class="form-control" placeholder="做法或数量"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3 order-frame"> |
||||
<div class="col-3 text-right mt-auto mb-auto"> |
||||
<img src="plus.svg" class="icon"/> |
||||
<img src="minus.svg" class="icon"/> |
||||
</div> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择分类</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择品目</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择材料</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<input type="text" class="form-control" placeholder="做法或数量"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3 order-frame"> |
||||
<div class="col-3 text-right mt-auto mb-auto"> |
||||
<img src="plus.svg" class="icon"/> |
||||
<img src="minus.svg" class="icon"/> |
||||
</div> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择分类</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择品目</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<select class="custom-select"> |
||||
<option selected>请选择材料</option> |
||||
<option value="1">One</option> |
||||
<option value="2">Two</option> |
||||
<option value="3">Three</option> |
||||
</select> |
||||
|
||||
<input type="text" class="form-control" placeholder="做法或数量"> |
||||
</div> |
||||
|
||||
<div class="input-group mt-3 justify-content-end"> |
||||
<div class="input-group-prepend"> |
||||
<span class="input-group-text">预结金额</span> |
||||
</div> |
||||
<input type="text" class="form-control col-2" disabled> |
||||
|
||||
|
||||
</div> |
||||
|
||||
<div class="input-group mt-3"> |
||||
<div class="input-group-prepend"> |
||||
<span class="input-group-text">备注</span> |
||||
</div> |
||||
<textarea class="form-control" aria-label="With textarea"></textarea> |
||||
</div> |
||||
<div class="mt-3 text-right"> |
||||
<button class="btn btn-secondary col-3">提交</button> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -1,13 +1,36 @@ |
||||
package com.example.demo; |
||||
|
||||
import com.example.demo.repository.DiancanRespository; |
||||
import com.example.demo.repository.MenuRepository; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
||||
import java.util.List; |
||||
|
||||
@SpringBootTest |
||||
class DemoApplicationTests { |
||||
|
||||
@Autowired |
||||
private MenuRepository menuRepository; |
||||
|
||||
@Autowired |
||||
private DiancanRespository diancanRespository; |
||||
|
||||
@Test |
||||
void contextLoads() { |
||||
} |
||||
|
||||
@Test |
||||
void testGetMenu(){ |
||||
List<String> l= menuRepository.getPinmuByFenlei("正菜"); |
||||
|
||||
l=menuRepository.getFenlei(); |
||||
} |
||||
|
||||
@Test |
||||
void testcheckZhuoHao(){ |
||||
int a=diancanRespository.countByZhuohao("2"); |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue