+ * 前端控制器 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@RestController +@RequestMapping("/blog/department") +public class DepartmentController { + +} + diff --git a/src/main/java/com/Chlin/blog/controller/DishController.java b/src/main/java/com/Chlin/blog/controller/DishController.java new file mode 100644 index 0000000..b42c789 --- /dev/null +++ b/src/main/java/com/Chlin/blog/controller/DishController.java @@ -0,0 +1,125 @@ +package com.Chlin.blog.controller; + + +import com.Chlin.blog.entity.Dish; +import com.Chlin.blog.entity.Orders; +import com.Chlin.blog.entity.User; +import com.Chlin.blog.mapper.DishMapper; +import com.Chlin.blog.service.DishService; +import com.Chlin.blog.service.OrderService; +import com.Chlin.blog.service.impl.DishServiceImpl; +import com.Chlin.blog.service.impl.OrderServiceImpl; +import com.google.gson.Gson; +import lombok.val; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.List; + +/** + *+ * 前端控制器 + *
+ *菜品控制器 + * @author Chlin + * @since 2023-08-29 + */ +@RestController +@RequestMapping("/blog/dish") +public class DishController { + private Gson gson = new Gson(); + + @Autowired + public DishService dishService; + /** + * 新增一个菜 + * @param jsonData + * @return + */ + @PostMapping("/newDish") + public ResponseEntity+ * 前端控制器 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@RestController +@RequestMapping("/blog/order") +public class OrderController { + @Autowired + OrderService orderService=new OrderServiceImpl(); + @Autowired + DishService dishService=new DishServiceImpl(); + @Autowired + UserService userService=new UserServiceImpl(); + + Gson gson=new Gson(); + + @PostMapping("/payment1") + public ResponseEntity+ * 前端控制器 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@RestController +@RequestMapping("/blog/user") +public class UserController { + private Gson gson = new Gson(); + @Autowired + private UserMapper userMapper; + private UserServiceImpl userService=new UserServiceImpl(); + +// private void setCookies(String id,String password,Cookie cookie){ +// +// +// } + /** + * 用户登录 + * 接受用户名密码,返回判断是否正确 + * 返回格式{value3:true} + * @return + */ + @PostMapping("/login") + public ResponseEntity+ * + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +//@ApiModel(value="Department对象", description="") +public class Department implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String name; + + + public Integer getId() { + return id; + } + + public Department setId(Integer id) { + this.id = id; + return this; + } + + public String getName() { + return name; + } + + public Department setName(String name) { + this.name = name; + return this; + } + + @Override + public String toString() { + return "Department{" + + "id=" + id + + ", name=" + name + + "}"; + } +} diff --git a/src/main/java/com/Chlin/blog/entity/Dish.java b/src/main/java/com/Chlin/blog/entity/Dish.java new file mode 100644 index 0000000..70f1ad3 --- /dev/null +++ b/src/main/java/com/Chlin/blog/entity/Dish.java @@ -0,0 +1,144 @@ +package com.Chlin.blog.entity; + +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; + +/** + *+ * 一个菜品dish类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +//@ApiModel(value="Dish对象", description="") +@Data +public class Dish implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String name; + + private BigDecimal price; + + private Integer categoryId=0; + + private Integer monthlySales; + + private Integer inventory; + +// @ApiModelProperty(value = "状态:0-下架,1-上架") + private Integer status; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public Dish setId(Integer id) { + this.id = id; + return this; + } + + public String getName() { + return name; + } + + public Dish setName(String name) { + this.name = name; + return this; + } + + public BigDecimal getPrice() { + return price; + } + + public Dish setPrice(BigDecimal price) { + this.price = price; + return this; + } + + public Integer getCategoryId() { + return categoryId; + } + + public Dish setCategoryId(Integer categoryId) { + this.categoryId = categoryId; + return this; + } + + public Integer getMonthlySales() { + return monthlySales; + } + + public Dish setMonthlySales(Integer monthlySales) { + this.monthlySales = monthlySales; + return this; + } + + public Integer getInventory() { + return inventory; + } + + public Dish setInventory(Integer inventory) { + this.inventory = inventory; + return this; + } + + public Integer getStatus() { + return status; + } + + public Dish setStatus(Integer status) { + this.status = status; + return this; + } + + public Date getCreateTime() { + return createTime; + } + + public Dish setCreateTime(Date createTime) { + this.createTime = createTime; + return this; + } + + public Date getUpdateTime() { + return updateTime; + } + + public Dish setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + return this; + } + + @Override + public String toString() { + return "Dish{" + + "id=" + id + + ", name=" + name + + ", price=" + price + + ", categoryId=" + categoryId + + ", monthlySales=" + monthlySales + + ", inventory=" + inventory + + ", status=" + status + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + "}"; + } +} diff --git a/src/main/java/com/Chlin/blog/entity/Orders.java b/src/main/java/com/Chlin/blog/entity/Orders.java new file mode 100644 index 0000000..218f078 --- /dev/null +++ b/src/main/java/com/Chlin/blog/entity/Orders.java @@ -0,0 +1,157 @@ +package com.Chlin.blog.entity; + +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; + +/** + *+ * + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +//@ApiModel(value="Order对象", description="") +public class Orders implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private Integer userId; + + private Integer dishId; + + //购买数量 + private Integer count; + + //单个金额 + private BigDecimal amount; + + //支付金额paid=count+amount + private BigDecimal paidAmount; + +// @ApiModelProperty(value = "状态:0-未付款,1-已付款") + private Integer status; + +// @ApiModelProperty(value = "支付类型:1-余额;2-现金") + private Integer payType; + + private Date completeTime; + + private Date createTime; + + + public Integer getId() { + return id; + } + + public Orders setId(Integer id) { + this.id = id; + return this; + } + + public Integer getUserId() { + return userId; + } + + public Orders setUserId(Integer userId) { + this.userId = userId; + return this; + } + + public Integer getDishId() { + return dishId; + } + + public Orders setDishId(Integer dishId) { + this.dishId = dishId; + return this; + } + + public Integer getCount() { + return count; + } + + public Orders setCount(Integer count) { + this.count = count; + return this; + } + + public BigDecimal getAmount() { + return amount; + } + + public Orders setAmount(BigDecimal amount) { + this.amount = amount; + return this; + } + + public BigDecimal getPaidAmount() { + return paidAmount; + } + + public Orders setPaidAmount(BigDecimal paidAmount) { + this.paidAmount = paidAmount; + return this; + } + + public Integer getStatus() { + return status; + } + + public Orders setStatus(Integer status) { + this.status = status; + return this; + } + + public Integer getPayType() { + return payType; + } + + public Orders setPayType(Integer payType) { + this.payType = payType; + return this; + } + + public Date getCompleteTime() { + return completeTime; + } + + public Orders setCompleteTime(Date completeTime) { + this.completeTime = completeTime; + return this; + } + + public Date getCreateTime() { + return createTime; + } + + public Orders setCreateTime(Date createTime) { + this.createTime = createTime; + return this; + } + + @Override + public String toString() { + return "Orders{" + + "id=" + id + + ", userId=" + userId + + ", dishId=" + dishId + + ", count=" + count + + ", amount=" + amount + + ", paidAmount=" + paidAmount + + ", status=" + status + + ", payType=" + payType + + ", completeTime=" + completeTime + + ", createTime=" + createTime + + "}"; + } +} diff --git a/src/main/java/com/Chlin/blog/entity/User.java b/src/main/java/com/Chlin/blog/entity/User.java new file mode 100644 index 0000000..b7ae552 --- /dev/null +++ b/src/main/java/com/Chlin/blog/entity/User.java @@ -0,0 +1,204 @@ +package com.Chlin.blog.entity; + +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; + +/** + *+ * + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +//@ApiModel(value="User对象", description="") +public class User implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String username; + + private String password; + + private String realName; + +// @ApiModelProperty(value = "用户类型:0-学生,1-员工") + private Integer type; + + private String studentId; + + private String email; + + private Integer phone; + + private Integer grade; + + private BigDecimal balance; + + private Date registerTime; + + private Date lastLoginTime; + private boolean rememberpassword; + private String signatures; + + public boolean isRememberpassword() { + return rememberpassword; + } + + + public String getSignatures() { + return signatures; + } + + public void setSignatures(String signatures) { + this.signatures = signatures; + } + + // +// public static long getSerialVersionUID() { +// return serialVersionUID; +// } + + public boolean isRememberPassword() { + return rememberpassword; + } + + public void setRememberPassword(boolean rememberPassword) { + this.rememberpassword = rememberPassword; + } + + public Integer getId() { + return id; + } + + public User setId(Integer id) { + this.id = id; + return this; + } + + public String getUsername() { + return username; + } + + public User setUsername(String username) { + this.username = username; + return this; + } + + public String getPassword() { + return password; + } + + public User setPassword(String password) { + this.password = password; + return this; + } + + public String getRealName() { + return realName; + } + + public User setRealName(String realName) { + this.realName = realName; + return this; + } + + public Integer getType() { + return type; + } + + public User setType(Integer type) { + this.type = type; + return this; + } + + public String getStudentId() { + return studentId; + } + + public User setStudentId(String studentId) { + this.studentId = studentId; + return this; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Integer getPhone() { + return phone; + } + + public void setPhone(Integer phone) { + this.phone = phone; + } + + public Integer getGrade() { + return grade; + } + + public User setGrade(Integer grade) { + this.grade = grade; + return this; + } + + public BigDecimal getBalance() { + return balance; + } + + public User setBalance(BigDecimal balance) { + this.balance = balance; + return this; + } + + public Date getRegisterTime() { + return registerTime; + } + + public User setRegisterTime(Date registerTime) { + this.registerTime = registerTime; + return this; + } + + public Date getLastLoginTime() { + return lastLoginTime; + } + + public User setLastLoginTime(Date lastLoginTime) { + this.lastLoginTime = lastLoginTime; + return this; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + + ", username=" + username + + ", password=" + password + + ", realName=" + realName + + ", type=" + type + + ", studentId=" + studentId + + ", email=" + email + + ", phone=" + phone + + ", grade=" + grade + + ", balance=" + balance + + ", signatures=" + signatures + + ", registerTime=" + registerTime + + ", lastLoginTime=" + lastLoginTime + + ", rememberPassword=" + rememberpassword + + "}"; + } +} diff --git a/src/main/java/com/Chlin/blog/mapper/DepartmentMapper.java b/src/main/java/com/Chlin/blog/mapper/DepartmentMapper.java new file mode 100644 index 0000000..4bf4792 --- /dev/null +++ b/src/main/java/com/Chlin/blog/mapper/DepartmentMapper.java @@ -0,0 +1,16 @@ +package com.Chlin.blog.mapper; + +import com.Chlin.blog.entity.Department; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *+ * Mapper 接口 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +public interface DepartmentMapper extends BaseMapper+ * Mapper 接口 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@Repository +//@Mapper +public interface DishMapper extends BaseMapper+ * Mapper 接口 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@Repository +public interface OrdersMapper extends BaseMapper+ * Mapper 接口 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@Mapper +@Repository +public interface UserMapper extends BaseMapper+ * 服务类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +public interface DepartmentService extends IService+ * 服务类的接口 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +public interface DishService extends IService+ * 服务类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +public interface OrderService extends IService+ * 服务类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +public interface UserService extends IService+ * 服务实现类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@Service +public class DepartmentServiceImpl extends ServiceImpl+ * 服务实现类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@Service +public class DishServiceImpl extends ServiceImpl+ * 服务实现类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ + +/** + * 订单服务, + */ +@Service +public class OrderServiceImpl extends ServiceImpl+ * 服务实现类 + *
+ * + * @author Chlin + * @since 2023-08-29 + */ +@Service +public class UserServiceImpl extends ServiceImpl
+ |
+
+ |
+
+ |
+
+ |