基于javaweb+mysql的springboot家政服务系统(java+springboot+html+echarts+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot家政服务系统(java+springboot+html+echarts+maven+mysql)
项目介绍
本项目为后管系统,主要功能包括: 1. 用户的注册、登录、退出系统 2. 用户的搜索功能 3. 家政人员上传资料、身份认证和资格认证 4. 消费者发布预约、查看预约、确认预约、评价订单、删除订单、修改个人资料 5. 家政人员修改个人资料、申请预约、接受订单、取消订单、完成订单 6. 管理员对用户管理、认证管理和系统的量化查看
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 8.0版本;
6.是否Maven项目:是;
技术栈
前端 1. UI界面:Bootstrap 2. 弹窗:Sweetalert 3. Js事件:jQuery/ajax 4. 可视化报表:ECharts 5. 下拉框:Bootstrap-Select 后端 1. 服务层:SpringBoot 2. 持久层:Mybatis 3. 分页:Pagehelper 4. 连接池:c3p0
- 实体类:Lombok
使用说明
-
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
-
使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
- 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8081/ 登录 消费者登录账号/密码:18796283605/123456 家政人员登录账号/密码:18860425033/123456 管理员账号/密码:18796283601/123456
*/
@GetMapping("/toCertifyCompany")
public String toCertifyCompany() {
return "hk-person/certify-company";
}
@PostMapping("/getHKPerson")
@ResponseBody
public ResponseResult<HouseKeeper> getHKPerson (
HttpSession session
) {
ResponseResult<HouseKeeper> result = new ResponseResult<>();
HouseKeeper hk = hkPersonService.selectHKByPhone(session);
result.setData(hk);
return result;
}
@PostMapping("/updateHousekeeperInfo")
@ResponseBody
public ResponseResult<Void> updateHousekeeperInfo (
HttpSession session,
HttpServletRequest request,
MultipartFile avatarFile,
@RequestParam("nickname") String nickName,
@RequestParam("phone") String phone,
@RequestParam("email") String email
) throws IOException {
HouseKeeper houseKeeper = new HouseKeeper();
houseKeeper.setHkNickname(nickName);
houseKeeper.setHkPhone(phone);
houseKeeper.setHkEmail(email);
if (avatarFile.getSize() != 0) {
String filePath = UploadFile.uploadFile(request, avatarFile);
houseKeeper.setHkHeadphoto(filePath);
} else {
String originImg = hkPersonService.selectHKByPhone(session).getHkHeadphoto();
houseKeeper.setHkHeadphoto(originImg);
}
hkPersonService.updateHousekeeperInfo(session, houseKeeper);
return new ResponseResult<>();
}
@PostMapping("/updateHKPerson")
@ResponseBody
*/
@GetMapping("/toMessagePerson")
public String toMessagePerson() {
return "person/message-person";
}
@PostMapping("/selectCustomer")
@ResponseBody
public ResponseResult<Customer> selectCustomer (HttpSession session) {
ResponseResult<Customer> result = new ResponseResult<>();
Customer customer = personService.selectCustomer(session);
result.setData(customer);
return result;
}
@PostMapping("/updateCustomer")
@ResponseBody
public ResponseResult<Void> updateCustomer (
HttpSession session,
HttpServletRequest request,
MultipartFile avatarFile,
@RequestParam("nickname") String nickName,
@RequestParam("phone") String phone,
@RequestParam("email") String email
) throws IOException {
Customer customer = new Customer();
customer.setCmNickname(nickName);
customer.setCmPhone(phone);
customer.setCmEmail(email);
System.out.println(customer);
// 上传头像
if (avatarFile.getSize() != 0) {
String filePath = UploadFile.uploadFile(request, avatarFile);
customer.setCmHeadPhoto(filePath);
} else {
String originImg = personService.selectCustomer(session).getCmHeadPhoto();
customer.setCmHeadPhoto(originImg);
}
personService.updateCustomer(session, customer);
return new ResponseResult<>();
}
@PostMapping("/updatePassword")
@ResponseBody
public ResponseResult<Void> updatePassword (
HttpSession session,
@RequestParam("oldPassword") String oldPassword,
@RequestParam("newPassword") String newPassword
) {
personService.updatePassword(session, oldPassword, newPassword);
return new ResponseResult<Void>();
Integer paramInt = Integer.parseInt(param);
ResponseResult<List<Comment>> result = new ResponseResult<>();
List<Comment> list = commentService.getCommentListByID(paramInt);
result.setData(list);
return result;
}
}
/**
* Created by IntelliJ IDEA 2020.1.
* Project: house
* Description:用户Controller
*/
@Controller
@RequestMapping("/person")
public class PersonController extends BaseController{
@Autowired
private PersonService personService;
/**
* 跳转用户页面
* @return 用户页面
*/
@GetMapping("/toPerson")
public String toPerson(HttpSession session) {
int role = (int) session.getAttribute("role");
if (0 == role){
return "xfz/person";
}
return "person";
}
@RequestParam("app_address_area") String appAddressArea,
@RequestParam("app_address_detail") String appAddressDetail,
@RequestParam("app_phone") String appPhone,
@RequestParam("app_time") String appTime
) {
ResponseResult<Void> response = new ResponseResult<Void>();
String username = new String();
String key = "username";
if (session.getAttribute(key) == null) {
response.setState(406);
response.setMessage("用户未登录");
} else {
username = session.getAttribute(key).toString();
}
String appAddress = appAddressCity + "-" + appAddressArea + "-" + appAddressDetail;
Appointment appointment = new Appointment();
appointment.setAppAddress(appAddress);
appointment.setAppType(appType);
appointment.setAppPhone(appPhone);
appointment.setAppBeginTime(FormatDate.StrToDate(appTime));
System.out.println("预约地点:" + appAddress + "预约类型:" + appType + "预约电话:" + appPhone);
appService.insertAppointment(appointment, username);
return new ResponseResult<Void>();
}
@PostMapping("/getVaildApp")
@ResponseBody
public ResponseResult<PageInfo<Appointment>> getVaildApp (
HttpSession session,
@RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer currentPage
) {
ResponseResult<PageInfo<Appointment>> result = new ResponseResult<>();
if (session == null) {
throw new UserNoLoginException("用户未登录");
} else {
PageInfo<Appointment> list = appService.getStatusApp(session, 1,currentPage);
result.setData(list);
}
return result;
}
@PostMapping("/getAllApp")
@ResponseBody
public ResponseResult<PageInfo<Appointment>> getAllApp (
}
@RequestMapping("/getTopRepair")
@ResponseBody
public ResponseResult<List<HouseKeeper>> getTopRepair () {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getTopHousekeeper(9);
result.setData(list);
return result;
}
@RequestMapping("/getTopMove")
@ResponseBody
public ResponseResult<List<HouseKeeper>> getTopMove () {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getTopHousekeeper(13);
result.setData(list);
return result;
}
@RequestMapping("/getRecommend")
@ResponseBody
public ResponseResult<List<HouseKeeper>> getRecommend (
HttpSession session
) {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getRecommend(session);
result.setData(list);
return result;
}
@PostMapping("/getTypeID")
@ResponseBody
public ResponseResult<Integer> getTypeID (
@RequestParam("param") String param
) {
ResponseResult<Integer> result = new ResponseResult<>();
int id = indexService.getTypeID(param);
result.setData(id);
return result;
}
}
public ResponseResult<PageInfo<Order>> getAllOrder (
HttpSession session,
@RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer currentPage
) {
ResponseResult<PageInfo<Order>> result = new ResponseResult<>();
if (session == null) {
throw new UserNoLoginException("用户未登录");
} else {
PageInfo<Order> list = orderService.getAllOrder(session, currentPage);
result.setData(list);
}
return result;
}
@PostMapping("/getOrderByID")
@ResponseBody
public ResponseResult<Order> getOrderByID (
@RequestParam("orderID") int id
) {
ResponseResult<Order> result = new ResponseResult<>();
Order order = orderService.getOrderByID(id);
result.setData(order);
return result;
}
@PostMapping("/deleteOrderByID")
@ResponseBody
public ResponseResult<Void> deleteOrderByID (
@RequestParam("orderID") int id
) {
orderService.deleteOrderByID(id);
return new ResponseResult<>();
}
@PostMapping("/getOrderListByHKID")
@ResponseBody
public ResponseResult<List<Order>> getOrderListByHKID (
HttpSession session
) {
ResponseResult<List<Order>> result = new ResponseResult<>();
List<Order> list = orderService.getOrderListByHKID(session);
result.setData(list);
adminService.updateCustomerStatusByID(Integer.parseInt(id), 2);
return new ResponseResult<>();
}
@PostMapping("/certifyCustomerByID")
@ResponseBody
public ResponseResult<Void> certifyCustomerByID (
@RequestParam("id") String id
) {
adminService.updateCustomerStatusByID(Integer.parseInt(id), 1);
return new ResponseResult<>();
}
@PostMapping("/cancelHousekeeperByID")
@ResponseBody
public ResponseResult<Void> cancelHousekeeperByID (
@RequestParam("id") String id
) {
adminService.updateHousekeeperStatusByID(Integer.parseInt(id), 2);
return new ResponseResult<>();
}
@PostMapping("/certifyHousekeeperByID")
@ResponseBody
public ResponseResult<Void> certifyHousekeeperByID (
@RequestParam("id") String id
) {
adminService.updateHousekeeperStatusByID(Integer.parseInt(id), 1);
return new ResponseResult<>();
}
@PostMapping("/cancelCompanyByID")
@ResponseBody
public ResponseResult<Void> cancelCompanyByID (
@RequestParam("id") String id
) {
adminService.updateCompanyStatusByID(Integer.parseInt(id), 2);
return new ResponseResult<>();
}
HttpSession session
) {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getRecommend(session);
result.setData(list);
return result;
}
@PostMapping("/getTypeID")
@ResponseBody
public ResponseResult<Integer> getTypeID (
@RequestParam("param") String param
) {
ResponseResult<Integer> result = new ResponseResult<>();
int id = indexService.getTypeID(param);
result.setData(id);
return result;
}
}
/**
* Created by IntelliJ IDEA 2020.1.
* Project: house
* Description:
*/
@Service
public class HKPersonServiceImpl implements HKPersonService {
@Autowired
private HKPersonMapper hkPersonMapper;
@Autowired
list = JsonUtil.json2List(applyList, Integer.class);
// 在集合中添加家政人员的编号
if (session == null) {
throw new UserNoLoginException("用户未登录");
} else {
String username = session.getAttribute("username").toString();
// 通过手机号判断家政人员是否已经认证,若未认证,则填写认证信息
if (hkPersonMapper.selectHKStatusByPhone(username) == 0) {
throw new NoApplyPermission("请填写认证信息");
} else if (hkPersonMapper.selectHKStatusByPhone(username) == 2) {
throw new NoApplyPermission("请等待认证结果");
} else {
int hkID = userMapper.selectHKIDByPhone(username);
System.out.println(hkID);
list.add(new Integer(hkID));
}
}
// 然后将集合转换为 json 格式
applyList = JsonUtil.toJSONString(list);
// 最后将 json 插入到数据库中
return appMapper.updateApplyList(applyList, id);
}
@Override
public Appointment selectAppointByID(int id) throws UserNoLoginException {
// 根据预约的 id 获得一条预约的信息
Appointment app = appMapper.selectAppointByID(id);
List<String> applyNicknameList = new ArrayList<>();
// 获得一条预约的申请列表
List<Integer> applyList = JsonUtil.json2List(app.getApplyJson(), Integer.class);
app.setApplyList(applyList);
// 根据预约的申请列表中的家政人员的编号,来设置申请列表的家政人员的昵称
for (int i = 0; i < applyList.size(); i ++) {
String applyNickname = userMapper.selectHKNicknameByHkID(applyList.get(i));
applyNicknameList.add(applyNickname);
}
// 将申请列表的家政人员的昵称放到实体类中
app.setApplyNameList(applyNicknameList);
return app;
}
@Override
public Integer updateAppointStatus(int status, int id) {
message.setMessageStatus(unreadStatus);
return messageMapper.insertMessage(message);
}
}
}
/**
* Created by IntelliJ IDEA 2020.1.
* Project: house
* Description:用户服务层
*/
public interface PersonService {
/**
* 得到消费者的基本资料
* @param session 通过session 获得手机号
* @return 消费者
*/
Customer selectCustomer(HttpSession session) throws UserNoLoginException;
/**
* 更新消费者的基本资料
* @param session
* @param customer 前台得到的基本信息
* @return 受影响的行数
*/
Integer updateCustomer (HttpSession session, Customer customer);
/**
* 更新消费者的密码
* @param session
* @param oldPassword 消费者的老密码
* @param newPassword 消费者的新密码
* @return
*/
Integer updatePassword (HttpSession session, String oldPassword, String newPassword) throws UserNoLoginException, PasswordIsErrorException;
/**
* 获得登录用户的认证信息
* @param session
* @return 认证信息
/**
* 更改公司的认证状态
* @param id 公司编号
* @param status 公司的认证状态
*/
void updateCompanyStatusByID (int id, int status);
/**
* 通过手机号获得用户列表
* @param phone 手机号
* @return 用户列表
*/
List<User> getUserByPhone (String phone) throws ContentException;
/**
* 更新管理员的密码
* @param session
* @param oldPassword 消费者的老密码
* @param newPassword 消费者的新密码
* @return
*/
Integer updatePassword (HttpSession session, String oldPassword, String newPassword) throws UserNoLoginException, PasswordIsErrorException;
}
/**
/**
* Created by IntelliJ IDEA 2020.1.
* Project: house
* Description:
*/
@Service
public class OrderServiceImpl implements OrderService {
private static int PAGESIZE = 10;
@Autowired
private OrderMapper orderMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private TypeMapper typeMapper;
@Autowired
private AppointmentMapper appointmentMapper;
@Override
public PageInfo<Order> getAllOrder(HttpSession session, int currentPage) {
String username = session.getAttribute("username").toString();
if (StringUtils.isEmpty(username)) {
throw new UserNoLoginException("用户未登录...");
} else {
int cmID = userMapper.selectCmIDByPhone(username);
if (currentPage <= 0) {
currentPage = 1;
}
PageHelper.startPage(currentPage, PAGESIZE);
List<Order> list = orderMapper.getAllOrder(cmID);
PageInfo<Order> pageInfo = new PageInfo<>(list);
for (Order order : list) {
String hkName = userMapper.selectHKNameByHkID(order.getHkID());
order.setHkName(hkName);
int days = CalcDate.calcDays(order.getOrderBeginTime(), order.getOrderEndTime());
order.setOrderDur(days);
}
return pageInfo;
}
public class AppointmentServiceImpl implements AppointmentService {
private static int PAGESIZE = 10;
@Autowired
private AppointmentMapper appMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private OrderMapper orderMapper;
@Autowired
private TypeMapper typeMapper;
@Autowired
private HKPersonMapper hkPersonMapper;
@Override
public Integer insertAppointment(Appointment appointment, String username) throws AppointFailedException, UserNoLoginException {
Integer cmID = appMapper.getCustomerIDByUsername(username);
if (cmID == null) {
throw new UserNoLoginException("用户未登录!");
}
appointment.setCmID(cmID);
Integer result = appMapper.insertAppointment(appointment);
if (result > 0) {
return result;
} else {
throw new AppointFailedException("预约失败!");
}
}
@Override
public List<Appointment> getStatusApp(HttpSession session, int status) throws UserNoLoginException {
int hkID = 0;
if (session == null) {
throw new UserNoLoginException("用户未登录");
} else {
String username = session.getAttribute("username").toString();
hkID = userMapper.selectHKIDByPhone(username);
}
List<Appointment> list = appMapper.getStatusApp(status);
for (Appointment app : list) {
List<Integer> applyList = JsonUtil.json2List(app.getApplyJson(), Integer.class);
app.setApplyList(applyList);
app.setHkID(hkID);
}
return "order";
}
/**
* 跳转至商家订单页面
* @return 商家订单页面
*/
@GetMapping("/toHkOrder")
public String toHkOrder() {
return "hk_order";
}
@PostMapping("/getAllOrder")
@ResponseBody
public ResponseResult<PageInfo<Order>> getAllOrder (
HttpSession session,
@RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer currentPage
) {
ResponseResult<PageInfo<Order>> result = new ResponseResult<>();
if (session == null) {
throw new UserNoLoginException("用户未登录");
} else {
PageInfo<Order> list = orderService.getAllOrder(session, currentPage);
result.setData(list);
}
return result;
}
@PostMapping("/getOrderByID")
@ResponseBody
public ResponseResult<Order> getOrderByID (
@RequestParam("orderID") int id
) {
ResponseResult<Order> result = new ResponseResult<>();
Order order = orderService.getOrderByID(id);
result.setData(order);
return result;
}
@PostMapping("/deleteOrderByID")
@ResponseBody
public ResponseResult<Void> deleteOrderByID (
customer.setCmNickname(nickname);
customer.setCmName(name);
customer.setCmSex(gender);
customer.setCmPhone(phone);
customer.setCmEmail(email);
customer.setCmPassword(password);
customer.setCmAddress(address);
adminService.insertCustomer(customer);
return response;
}
@PostMapping("/insertAdmin")
@ResponseBody
public ResponseResult<Void> insertAdmin (
@RequestParam("name") String name,
@RequestParam("gender") String gender,
@RequestParam("phone") String phone,
@RequestParam("password") String password
) {
ResponseResult<Void> response = new ResponseResult<>();
Admin admin = new Admin();
admin.setAdName(name);
admin.setAdPassword(password);
admin.setAdPhone(phone);
admin.setAdSex(gender);
adminService.insertAdmin(admin);
return response;
}
@PostMapping("/updateLoginStatus")
@ResponseBody
public ResponseResult<Void> updateLoginStatus (
@RequestParam("") String username
) {
ResponseResult<Void> response = new ResponseResult<>();
adminService.updateLoginStatus(username);
return response;
}
@PostMapping("/getOrderData")
@ResponseBody
public ResponseResult<List<EchartsData>> getOrderData(){
ResponseResult<List<EchartsData>> response = new ResponseResult<>();
List<EchartsData> echartsData = adminService.getOrderData();
response.setData(echartsData);
return response;
}
/**
* Created by IntelliJ IDEA 2020.1.
* Project: house
* Description:
*/
@Service
public class MessageServiceImpl implements MessageService {
@Autowired
private MessageMapper messageMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private HKPersonMapper hkPersonMapper;
/**
* unreadStatus 表示未读状态
*/
private final int unreadStatus = 0;
/**
* readStatus 表示已读
*/
private final int readStatus = 1;
public ResponseResult<List<HouseKeeper>> getTopRepair () {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getTopHousekeeper(9);
result.setData(list);
return result;
}
@RequestMapping("/getTopMove")
@ResponseBody
public ResponseResult<List<HouseKeeper>> getTopMove () {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getTopHousekeeper(13);
result.setData(list);
return result;
}
@RequestMapping("/getRecommend")
@ResponseBody
public ResponseResult<List<HouseKeeper>> getRecommend (
HttpSession session
) {
ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
List<HouseKeeper> list = indexService.getRecommend(session);
result.setData(list);
return result;
}
@PostMapping("/getTypeID")
@ResponseBody
public ResponseResult<Integer> getTypeID (
@RequestParam("param") String param
) {
ResponseResult<Integer> result = new ResponseResult<>();
int id = indexService.getTypeID(param);
result.setData(id);
return result;
}
}
private CompanyService companyService;
@Autowired
private CommentService commentService;
/**
* 跳转至商家资料页面
* @return 商家资料页面
*/
@GetMapping("/toHkPerson")
public String toHkPerson() {
return "hk_person";
}
/**
* 跳转至个人信息页面
* @return 个人信息页面
*/
@GetMapping("/toInfoHk")
public String toInfoHk() {
return "hk-person/info-hk";
}
/**
* 跳转至家政资料页面
* @return 家政资料页面
*/
@GetMapping("/toEditHk")
public String toEditHk() {
return "hk-person/edit-hk";
}
/**
* 跳转至消息页面
* @return 消息页面
*/
@GetMapping("/toMessageHk")
public String toMessageHk() {
return "hk-person/message-hk";
}
/**
* 跳转至商家认证页面
* @return 商家认证页面
*/
@GetMapping("/toCertifyHk")
public String toCertifyHk() {
return "hk-person/certify-hk";