基于Java纯净水供应店信息管理平台设计与实现,开发平台为IntelliJ IDEA。要求实现功能1:纯净水信息管理功能,功能2:会员管理功能,功能3:纯净水销售。写出实现功能的代码
时间: 2024-04-22 18:23:19 浏览: 62
好的,下面是基于Java的纯净水供应店信息管理平台与实现代码示例,实现三个功能:
1.净水信息管理功能:
()纯净水Bean代码:
```java
public class PureWater {
private int id;
private String name;
String brand;
private String;
private double price;
// 省getters和setters方法
}
```
(2)纯净水DAO代码:
```java
public interface PureWaterDao {
// 添加纯净水
int addPureWater(PureWater pureWater);
// 删除纯净水
int deletePureWater(int id);
// 修改纯净水
int updatePureWater(PureWater pureWater);
// 查询所有纯净水
List<PureWater> getAllPureWater();
// 根据id查询纯净水
PureWater getPureWaterById(int id);
// 修改库存
int updateInventory(int id, int count);
}
```
(3)纯净水Service代码:
```java
@Service
public class PureWaterService {
@Autowired
private PureWaterDao pureWaterDao;
// 添加纯净水
public int addPureWater(PureWater pureWater) {
return pureWaterDao.addPureWater(pureWater);
}
// 删除纯净水
public int deletePureWater(int id) {
return pureWaterDao.deletePureWater(id);
}
// 修改纯净水
public int updatePureWater(PureWater pureWater) {
return pureWaterDao.updatePureWater(pureWater);
}
// 查询所有纯净水
public List<PureWater> getAllPureWater() {
return pureWaterDao.getAllPureWater();
}
// 根据id查询纯净水
public PureWater getPureWaterById(int id) {
return pureWaterDao.getPureWaterById(id);
}
// 修改库存
public int updateInventory(int id, int count) {
return pureWaterDao.updateInventory(id, count);
}
}
```
(4)纯净水Controller代码:
```java
@Controller
public class PureWaterController {
@Autowired
private PureWaterService pureWaterService;
// 转到纯净水信息管理页面
@RequestMapping("/pureWater")
public String toPureWater(HttpSession session) {
List<PureWater> pureWaters = pureWaterService.getAllPureWater();
session.setAttribute("pureWaters", pureWaters);
return "pureWater";
}
// 添加纯净水
@RequestMapping("/addPureWater")
@ResponseBody
public String addPureWater(PureWater pureWater) {
int result = pureWaterService.addPureWater(pureWater);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 删除纯净水
@RequestMapping("/deletePureWater")
@ResponseBody
public String deletePureWater(int id) {
int result = pureWaterService.deletePureWater(id);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 修改纯净水
@RequestMapping("/updatePureWater")
@ResponseBody
public String updatePureWater(PureWater pureWater) {
int result = pureWaterService.updatePureWater(pureWater);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 修改库存
@RequestMapping("/updateInventory")
@ResponseBody
public String updateInventory(int id, int count) {
int result = pureWaterService.updateInventory(id, count);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
}
```
2. 会员管理功能:
(1)会员Bean代码:
```java
public class Member {
private int id;
private String name;
private String phone;
private String address;
private int points;
// 省略getters和setters方法
}
```
(2)会员DAO代码:
```java
public interface MemberDao {
// 添加会员
int addMember(Member member);
// 删除会员
int deleteMember(int id);
// 修改会员
int updateMember(Member member);
// 查询所有会员
List<Member> getAllMember();
// 根据id查询会员
Member getMemberById(int id);
// 修改积分
int updatePoints(int id, int points);
}
```
(3)会员Service代码:
```java
@Service
public class MemberService {
@Autowired
private MemberDao memberDao;
// 添加会员
public int addMember(Member member) {
return memberDao.addMember(member);
}
// 删除会员
public int deleteMember(int id) {
return memberDao.deleteMember(id);
}
// 修改会员
public int updateMember(Member member) {
return memberDao.updateMember(member);
}
// 查询所有会员
public List<Member> getAllMember() {
return memberDao.getAllMember();
}
// 根据id查询会员
public Member getMemberById(int id) {
return memberDao.getMemberById(id);
}
// 修改积分
public int updatePoints(int id, int points) {
return memberDao.updatePoints(id, points);
}
}
```
(4)会员Controller代码:
```java
@Controller
public class MemberController {
@Autowired
private MemberService memberService;
// 转到会员信息管理页面
@RequestMapping("/member")
public String toMember(HttpSession session) {
List<Member> members = memberService.getAllMember();
session.setAttribute("members", members);
return "member";
}
// 添加会员
@RequestMapping("/addMember")
@ResponseBody
public String addMember(Member member) {
int result = memberService.addMember(member);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 删除会员
@RequestMapping("/deleteMember")
@ResponseBody
public String deleteMember(int id) {
int result = memberService.deleteMember(id);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 修改会员
@RequestMapping("/updateMember")
@ResponseBody
public String updateMember(Member member) {
int result = memberService.updateMember(member);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 修改积分
@RequestMapping("/updatePoints")
@ResponseBody
public String updatePoints(int id, int points) {
int result = memberService.updatePoints(id, points);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
}
```
3. 纯净水销售功能:
(1)订单Bean代码:
```java
public class Order {
private int id;
private int memberId;
private int pureWaterId;
private int count;
private double price;
private String orderTime;
private int status;
// 省略getters和setters方法
}
```
(2)订单DAO代码:
```java
public interface OrderDao {
// 添加订单
int addOrder(Order order);
// 删除订单
int deleteOrder(int id);
// 修改订单
int updateOrder(Order order);
// 查询所有订单
List<Order> getAllOrder();
// 根据id查询订单
Order getOrderById(int id);
// 修改订单状态
int updateStatus(int id, int status);
}
```
(3)订单Service代码:
```java
@Service
public class OrderService {
@Autowired
private OrderDao orderDao;
// 添加订单
public int addOrder(Order order) {
return orderDao.addOrder(order);
}
// 删除订单
public int deleteOrder(int id) {
return orderDao.deleteOrder(id);
}
// 修改订单
public int updateOrder(Order order) {
return orderDao.updateOrder(order);
}
// 查询所有订单
public List<Order> getAllOrder() {
return orderDao.getAllOrder();
}
// 根据id查询订单
public Order getOrderById(int id) {
return orderDao.getOrderById(id);
}
// 修改订单状态
public int updateStatus(int id, int status) {
return orderDao.updateStatus(id, status);
}
}
```
(4)订单Controller代码:
```java
@Controller
public class OrderController {
@Autowired
private OrderService orderService;
// 转到纯净水销售页面
@RequestMapping("/order")
public String toOrder(HttpSession session) {
List<Order> orders = orderService.getAllOrder();
session.setAttribute("orders", orders);
return "order";
}
// 添加订单
@RequestMapping("/addOrder")
@ResponseBody
public String addOrder(Order order) {
int result = orderService.addOrder(order);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 删除订单
@RequestMapping("/deleteOrder")
@ResponseBody
public String deleteOrder(int id) {
int result = orderService.deleteOrder(id);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 修改订单
@RequestMapping("/updateOrder")
@ResponseBody
public String updateOrder(Order order) {
int result = orderService.updateOrder(order);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
// 修改订单状态
@RequestMapping("/updateStatus")
@ResponseBody
public String updateStatus(int id, int status) {
int result = orderService.updateStatus(id, status);
if (result > 0) {
return "success";
} else {
return "fail";
}
}
}
```
以上是基于Java的纯净水供应店信息管理平台设计与实现的代码示例,如果您有具体的问题或需要更详细的解答,请随时提出。
阅读全文