基于javaweb的送水公司管理系统(java+springboot+html+mybatis+mysql)

基于javaweb的送水公司管理系统(java+springboot+html+mybatis+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

20220819210153

20220819210154

20220819210155

20220819210156

20220819210157

20220819210159

基于javaweb+mysql的送水公司管理系统(java+SpringBoot+html+Mybatis+Mysql)

项目介绍

这个项目是一个基于SpringBoot+MyBatis的送水公司管理系统

管理员权限包括: 客户管理 送水工管理 送水历史管理 计算工资 统计送水数量

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;  4.数据库:MySql 5.7版本; 5.是否Maven项目:是;

技术栈

1.后端:SpringBoot+Mybatis+Mysql 2.前端:html+css+javascriipt

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8091/ 注意:端口不要修改,否则会有异常 管理员账户:admin/admin

用户管理控制层:

@Controller

@RequestMapping(“/cust”)

@Slf4j

public class CustomerController {

/**

  • 控制器依赖业务逻辑,按照类型自动装配CustomerService对象

*/

@Autowired

private CustomerService customerService ;

/**

  • 用户点击"客户管理"超链接按钮,显示所有的客户信息

  • 步骤:

  • 1 调用CustomerService对象的listCustomer方法查询所有的客户信息

  • 2 将客户信息渲染到客户列表页面

  • 3 跳转到客户列表页面

  • @param model 在前端和后端之间传递数据的对象

  • @return 客户列表页面

*/

@RequestMapping(“/listCust”)

public String listCustomer(Model model) {

List custList = customerService.listCustomer();

model.addAttribute(“custList”,custList);

return “customerList”;

/**

点击“客户列表”页面的“添加”按钮,跳转到“添加客户”页面

*/

@RequestMapping(“/preSaveCust”)

public String preSaveCustomer() {

return “customerSave”;

/**

  • 在“添加客户”页面的表单填写要添加的客户信息,点击“提交”按钮,处理添加客户的请求

  • 步骤:

  • 1 调用CustomerService对象的saveCustomer添加客户信息

  • 2 重定向到客户列表,显示新添加的客户信息

  • @param customer 表单采集的客户对象

  • @return 客户列表,显示添加的新客户信息

*/

@RequestMapping(value = “/saveCust”,method = RequestMethod.POST)

public String saveCustomer(Customer customer) {

log.info(“customer ===”+ customer);

int rows = customerService.saveCustomer(customer);

log.info("save customer rows = "+rows);

// 添加成功之后重新查询客户列表,显示新添加的客户信息

return “redirect:/cust/listCust”;

/**

  • 在浏览器上输入要搜索的“客户名称”,点击“搜索按钮”,根据条件搜索满足条件的客户,将客户列表显示到前端页面

  • 步骤:

  • 1 调用CustomerService对象的searchCustomer方法根据客户名称搜索满足条件的客户

  • 2 将客户列表渲染到前端(客户列表)页面

  • 3 跳转到客户列表页面

  • @param custName 客户名称

  • @param model

  • @return 客户列表页面

*/

@RequestMapping(“/searchCust”)

public String searchCustomer(String custName, Model model) {

log.info("searchCustomer custName = "+custName);

List custList = customerService.searchCustomer(custName);

model.addAttribute(“custList”,custList);

// 把搜索条件回传到前端页面

model.addAttribute(“searchName”,custName);

return “customerList”;

/**

  • 处理删除请求

  • 步骤:

  • 1 调用CustomerService对象的deleteCustomerById方法根据客户ID删除客户信息

  • 2 打印受影响行数

  • 3 返回客户列表路径,重新执行查询客户列表方法listCustomer,显示删除之后的数据

  • @param cid 前端传入的客户id

  • @return 返回客户列表路径,重新执行查询客户列表方法listCustomer,显示删除之后的数据

*/

@RequestMapping(“/delCust/{cid}”)

public String deleteCustomer(@PathVariable(“cid”) Integer cid) {

log.info("delete Customer cid = "+cid);

int rows = customerService.deleteCustomerById(cid);

log.info("delte customer rows = "+rows);

return “redirect:/cust/listCust”;

/**

  • 用户在页面上点击“修改”按钮,完成数据回显

  • 步骤:

  • 1 根据ID查询对应的客户信息

  • 2 将客户信息渲染到“修改客户”页面

  • 3 返回“修改客户”页面

  • @param cid 客户id

  • @param model

  • @return 修改客户

*/

@RequestMapping(“/preUpdateCust/{cid}”)

public String preUpdateCustomer(@PathVariable(“cid”) Integer cid,Model model) {

log.info("pre update customer cid = "+cid);

Customer customer = customerService.getCustomerById(cid);

model.addAttribute(“customer”,customer);

return “customerUpdate”;

/**

  • 在“修改客户”页面点击“提交”按钮,处理“修改客户”的请求

  • 修改成功重新执行查询客户列表,显示修改之后的客户信息

  • @param customer “修改客户”页面采集的客户信息

  • @return 客户列表

*/

@RequestMapping(value=“/updateCust”,method = RequestMethod.POST)

public String updateCustomer(Customer customer) {

log.info("update Customer "+customer);

int rows = customerService.updateCustomer(customer);

log.info("update customer rows = "+rows);

return “redirect:/cust/listCust”;

访问管理控制层:

@Controller

@Slf4j

public class AccountController {

/**

  • Controller控制器依赖于业务逻辑层,将AccountService自动装配到控制器(AccountController对象)

*/

@Autowired

private AccountService accountService;

/**

  • 该方法用来处理前端浏览器的登录请求,登录成功跳转到"送水工管理系统"主页面,登录失败返回index.html页面

  • 步骤:

  • 1 调用业务逻辑对象(AccountService)的login方法判断登录是否成功

  • 2 登录成功跳转到"送水工管理系统"主页面

  • 3 登录失败返回index.html页面,并给出提示"用户名或者密码错误"

  • @param userName 浏览器表单采集的用户名

  • @param userPwd 浏览器表单采集的密码

  • @param model 用来在视图层和控制层之间传递数据的对象

  • @return 登录成功跳转到"送水工管理系统"主页面,登录失败返回index.html页面

*/

@RequestMapping(value=“/login”,method = RequestMethod.POST)

public String login(String userName, String userPwd, Model model, HttpSession session) {

boolean result = accountService.login(userName, userPwd);

// 条件成立:登录成功,否则登录失败

if(result) {

//登陆成功,将表单输入的用户名传递到前端页面

session.setAttribute(“currentUser”,userName);

// 登录成功跳转到主页面

return “waterMainMenu”;

} else {

model.addAttribute(“loginFail”,“用户名或者密码错误”);

return “index”;

/***

  • 退出系统

  • @return

*/

@RequestMapping(“/logout”)

public String logout() {

return “index”;

/***

  • 跳转到修改密码页面

  • @return

*/

@RequestMapping(“/changePwd”)

public String changePwd() {

return “changePwd”;

/**

  • 修改密码

  • @param

  • @return

*/

@RequestMapping(value=“/updatePassword”,method = RequestMethod.POST)

public String updatePassword(String oldPassword,String confirmPassword, Model model, HttpSession session) {

String username = (String) session.getAttribute(“currentUser”);

boolean checkOldPwd = accountService.checkOldPassword(username,oldPassword);

if (!checkOldPwd){

model.addAttribute(“changePwdMsg”,“原密码错误”);

return “changePwd”;

// 将新密码信息持久化到数据库

int count = accountService.updateAccount(username,confirmPassword);

if (count>0){

model.addAttribute(“changePwdMsg”,“密码修改成功”);

return “changePwd”;

}else {

model.addAttribute(“changePwdMsg”,“密码修改失败”);

return “changePwd”;

计算工资的控制器:

/**

  • TODO:计算工资的控制器,处理计算工资的请求

*/

@RequestMapping(“/salary”)

@Controller

@Slf4j

public class SalaryController {

/**

  • 自动装配计算工资业务逻辑

*/

@Autowired

private SalaryService salaryService;

/**

  • 点击“计算工资”按钮,查询所有送水工的工资,然后将工资渲染到前端页面,并返回

  • @param model

  • @return 计算工资列表页面

*/

@RequestMapping(“/calcSalary”)

public String calcWorkerSalary(Model model) {

List salaryList = salaryService.listCalcSalary();

log.info("calc worker salary list size = "+salaryList.size());

model.addAttribute(“salaryList”,salaryList);

return “salaryList”;

/**

  • 在“计算工资”页面表单输入开始时间和结束时间统计工资

  • @param startDate 开始时间

  • @param endDate 结束时间

  • @param model

  • @return

*/

@RequestMapping(“/searchCalcSalay”)

public String searchWorkerCalcSalary(String startDate,String endDate,Model model) {

log.info("start date = "+startDate);

log.info("end date = "+endDate);

List salaryList = salaryService.listCalcSalaryByCondition(startDate, endDate);

log.info("search calc list size = "+salaryList.size());

model.addAttribute(“salaryList”,salaryList);

// 修复BUG,将搜索条件传入到前端页面

model.addAttribute(“startDate”,startDate);

model.addAttribute(“endDate”,endDate);

return “salaryList”;


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值