spring+springMVC+mybatis实现的物业管理系统

本系统借用了前辈的页面框架来实现了一个物业管理系统,使用到的主要技术有:SSM框架,MySql 8.0数据库,tomcat 8.0,使用maven进行依赖管理,前端页面使用的是jsp。整个系统分为用户端和管理员端。
用户端功能有:
1、管理个人信息,包括个人资料、家庭成员、车辆信息、宠物信息。
用户个人资料的功能有增加、删除、查找、修改用户信息以及用户登陆,Controller层代码如下:

@Controller
@RequestMapping("/userProfile")
public class UserProfileController {
    @Autowired
    private IUserProfileService userProfileService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<UserProfile> userProfileList=userProfileService.findAll(page,size);
        PageInfo userProfilePageInfo = new PageInfo(userProfileList);
        mv.addObject("userProfilePageInfo",userProfilePageInfo);
        mv.setViewName("userProfile-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "UserId", required = true) Integer UserId) throws Exception {
        ModelAndView mv = new ModelAndView();
        UserProfile userProfile =userProfileService.findById(UserId);
        mv.addObject("userProfile",userProfile);
        mv.setViewName("userProfile-show");
        return mv;
    }

    @RequestMapping("/findById2")
    public ModelAndView findById2(@RequestParam(name = "UserId", required = true) Integer UserId) throws Exception {
        ModelAndView mv = new ModelAndView();
        UserProfile userProfile =userProfileService.findById(UserId);
        mv.addObject("userProfile",userProfile);
        mv.setViewName("user-list");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "UserId", required = true) Integer UserId) throws Exception{
        userProfileService.updateUserStatus(UserId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(UserProfile userProfile) throws Exception {
        userProfileService.save(userProfile);
        return "redirect:/userlogin.jsp";
    }
    @RequestMapping("/update")
    public String update(UserProfile userProfile) throws Exception {
        userProfileService.updateUserProfile(userProfile);
        return "redirect:findAll";
    }
    @RequestMapping("/update2")
    public String update2(UserProfile userProfile) throws Exception {
        userProfileService.updateUserProfile(userProfile);
        return "redirect:/pages/user-list.jsp";
    }
    @RequestMapping("/verify")
    public String Verify(UserProfile userProfile, HttpSession session) throws Exception {
        System.out.println("用户登录"+userProfile);
        UserProfile userProfileVerify = userProfileService.verifyUserProfile(userProfile);
        System.out.println("用户登录"+userProfile);
        if(userProfileVerify==null)
            return "redirect:/userlogin.jsp";
        else{
            session.setAttribute("userInfoLogin",userProfileVerify);
            return "main-user";
        }
    }
}

数据持久层实现数据库数据的查询、更新等,使用的是mybatis注解的形式,代码如下:

    @Select("select * from user_profile")
    public List<UserProfile> findAll(int page, int size) throws Exception;

    @Insert("insert into user_profile(User_name,House_id,User_native_place,User_unit,User_id_number,User_tel,User_check_in_time,User_sex,User_password,User_status) values(#{UserName},#{HouseId},#{UserNativePlace},#{UserUnit},#{UserIdNumber},#{UserTel},#{UserCheckInTime},#{UserSex},#{UserPassword},1)")
    void save(UserProfile userProfile);

    @Delete("delete from user_profile where User_id=#{UserId}")
    void deleteuserProfileById(Integer UserId);

    @Select("select * from user_profile where User_id=#{UserId}")
    UserProfile findById(Integer UserId);

    @Update("update user_profile set User_name=#{UserName},House_id=#{HouseId},User_native_place=#{UserNativePlace},User_unit=#{UserUnit},User_id_number=#{UserIdNumber},User_tel=#{UserTel},User_check_in_time=#{UserCheckInTime},User_check_out_time=#{UserCheckOutTime},User_sex=#{UserSex},User_age=#{UserAge},User_note=#{UserNote},User_password=#{UserPassword},User_status=#{UserStatus} where User_id=#{UserId}")
    void update(UserProfile userProfile);
    //验证登陆
    @Select("select * from user_profile where User_id_number=#{UserIdNumber} and User_password=#{UserPassword} and User_status=1")
    UserProfile verifyUserProfile(UserProfile userProfile);

    @Update("update user_profile set User_status= 0 where User_id=#{UserId}")
    void updateUserStatus(Integer UserId);

2、管理缴费信息,包括物业费、水电费、停车费。
物业费管理的Controller层:

 @Autowired
    private IPropertyFeeService propertyFeeService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<PropertyFee> propertyFeeList =propertyFeeService.findAll(page,size);
        PageInfo propertyFeePageInfo = new PageInfo(propertyFeeList);
        mv.addObject("propertyFeePageInfo", propertyFeePageInfo);
        mv.setViewName("propertyFee-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "PropertyFeeId", required = true) Integer PropertyFeeId) throws Exception {
        ModelAndView mv = new ModelAndView();
        PropertyFee propertyFee = propertyFeeService.findById(PropertyFeeId);
        mv.addObject("propertyFee",propertyFee);
        mv.setViewName("propertyFee-show");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "PropertyFeeId", required = true) Integer PropertyFeeId) throws Exception{
        propertyFeeService.deletepropertyFeeById(PropertyFeeId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(PropertyFee propertyFee) throws Exception {
        System.out.println("新增:"+propertyFee);
        propertyFeeService.save(propertyFee);
        return "redirect:findAll";
    }
    @RequestMapping("/update")
    public String update(PropertyFee propertyFee) throws Exception {
        System.out.println("修改:"+propertyFee);
        propertyFeeService.updatePropertyFee(propertyFee);
        return "redirect:findAll";
    }
    @RequestMapping("/findByUserId")
    public ModelAndView findByUserId(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size,@RequestParam(name = "UserId", required = true) Integer UserId) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<PropertyFee> propertyFeeList=propertyFeeService.findByUserId(page, size, UserId);
        PageInfo propertyFeePageInfos = new PageInfo(propertyFeeList);
        mv.addObject("propertyFeePageInfos",propertyFeePageInfos);
        mv.setViewName("propertyFees-list");
        return mv;
    }

物业费管理的Dao层:

    @Select("select * from property_fee")
    public List<PropertyFee> findAll(int page, int size) throws Exception;

    @Insert("insert into property_fee(User_id,User_name,Property_address,Property_year,Property_month,Property_fee_total,Property_fee_pay,Property_fee_owe,Property_fee_pay_time,Property_fee_pay_method,Property_fee_handler,Property_fee_note) values(#{UserId},#{UserName},#{PropertyAddress},#{PropertyYear},#{PropertyMonth},#{PropertyFeeTotal},#{PropertyFeePay},#{PropertyFeeOwe},#{PropertyFeePayTime},#{PropertyFeePayMethod},#{PropertyFeeHandler},#{PropertyFeeNote})")
    void save(PropertyFee propertyFee);

    @Delete("delete from property_fee where Property_fee_id=#{PropertyFeeId}")
    void deletepropertyFeeById(Integer PropertyFeeId);

    @Select("select * from property_fee where Property_fee_id=#{PropertyFeeId}")
    PropertyFee findById(Integer PropertyFeeId);

    @Update("update property_fee set User_id=#{UserId},User_name=#{UserName},Property_address=#{PropertyAddress},Property_year=#{PropertyYear},Property_month=#{PropertyMonth},Property_fee_total=#{PropertyFeeTotal},Property_fee_pay=#{PropertyFeePay},Property_fee_owe=#{PropertyFeeOwe},Property_fee_pay_time=#{PropertyFeePayTime},Property_fee_pay_method=#{PropertyFeePayMethod},Property_fee_handler=#{PropertyFeeHandler},Property_fee_note=#{PropertyFeeNote} where Property_fee_id=#{PropertyFeeId}")
    void update(PropertyFee propertyFee);

    @Select("select * from property_fee where User_id=#{UserId}")
    List<PropertyFee> findByUserId(int page, int size,@Param("UserId")Integer UserId) throws Exception;

3、员工评价,查看以往评价以及对员工进行评价。
员工评价的Controller层如下:

    @Autowired
    private IEmployeeEvaluateService employeeEvaluateService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<EmployeeEvaluate> employeeEvaluateList = employeeEvaluateService.findAll(page,size);
        PageInfo employeeEvaluatePageInfo = new PageInfo(employeeEvaluateList);
        mv.addObject("employeeEvaluatePageInfo", employeeEvaluatePageInfo);
        mv.setViewName("employeeEvaluate-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "EvaluateId", required = true) Integer EvaluateId) throws Exception {
        ModelAndView mv = new ModelAndView();
        EmployeeEvaluate employeeEvaluate = employeeEvaluateService.findById(EvaluateId);
        mv.addObject("employeeEvaluate",employeeEvaluate);
        mv.setViewName("employeeEvaluate-show");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "EvaluateId", required = true) Integer EvaluateId) throws Exception{
        employeeEvaluateService.deleteemployeeEvaluateById(EvaluateId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(EmployeeEvaluate employeeEvaluate) throws Exception {
        employeeEvaluateService.save(employeeEvaluate);
        return "redirect:findAll";
    }
    @RequestMapping("/update")
    public String update(EmployeeEvaluate employeeEvaluate) throws Exception {
        employeeEvaluateService.updateEmployeeEvaluate(employeeEvaluate);
        return "redirect:findAll";
    }

员工评价的Dao层代码如下:

    @Select("select * from employee_evaluate")
    public List<EmployeeEvaluate> findAll(int page, int size) throws Exception;

    @Insert("insert into employee_evaluate(Evaluate_content,Evaluate_stars,User_id,Employee_id) values(#{EvaluateContent},#{EvaluateStars},#{UserId},#{EmployeeId})")
    void save(EmployeeEvaluate employeeEvaluate);

    @Delete("delete from employee_evaluate where Evaluate_id=#{EvaluateId}")
    void deleteemployeeEvaluateById(Integer EvaluateId);

    @Select("select * from employee_evaluate where Evaluate_id=#{EvaluateId}")
    EmployeeEvaluate findById(Integer EvaluateId);

    @Update("update employee_evaluate set Evaluate_content=#{EvaluateContent},Evaluate_stars=#{EvaluateStars},User_id=#{UserId},Employee_id=#{EmployeeId} where Evaluate_id=#{EvaluateId}")
    void update(EmployeeEvaluate employeeEvaluate);

spring+springMVC+mybatis实现的物业管理系统_第1张图片
spring+springMVC+mybatis实现的物业管理系统_第2张图片

spring+springMVC+mybatis实现的物业管理系统_第3张图片
管理员端的功能主要有:
spring+springMVC+mybatis实现的物业管理系统_第4张图片

1、人事管理
spring+springMVC+mybatis实现的物业管理系统_第5张图片
人事管理的功能以岗位考核为例提供代码示例:
岗位考核的Controller层代码如下:

    @Autowired
    private IEmployeeExamService employeeExamService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<EmployeeExam> employeeExamList = employeeExamService.findAll(page,size);
        PageInfo employeeExamPageInfo = new PageInfo(employeeExamList);
        mv.addObject("employeeExamPageInfo", employeeExamPageInfo);
        mv.setViewName("employeeExam-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "ExamId", required = true) Integer ExamId) throws Exception {
        ModelAndView mv = new ModelAndView();
        EmployeeExam employeeExam = employeeExamService.findById(ExamId);
        mv.addObject("employeeExam",employeeExam);
        mv.setViewName("employeeExam-show");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "ExamId", required = true) Integer ExamId) throws Exception{
        employeeExamService.deleteemployeeExamById(ExamId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(EmployeeExam employeeExam) throws Exception {
        employeeExamService.save(employeeExam);
        return "redirect:findAll";
    }
    @RequestMapping("/update")
    public String update(EmployeeExam employeeExam) throws Exception {
        employeeExamService.updateEmployeeExam(employeeExam);
        return "redirect:findAll";
    }

岗位考核的Service层代码如下:

    @Autowired
    IEmployeeExamDao employeeExamDao;
    @Override
    public List<EmployeeExam> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page, size);
        return employeeExamDao.findAll(page,size);
    }

    @Override
    public void save(EmployeeExam employeeExam) {
        employeeExamDao.save(employeeExam);

    }

    @Override
    public void deleteemployeeExamById(Integer ExamId) {
        employeeExamDao.deleteemployeeExamById(ExamId);
    }

    @Override
    public EmployeeExam findById(Integer ExamId) {
        return employeeExamDao.findById(ExamId);
    }

    @Override
    public void updateEmployeeExam(EmployeeExam employeeExam) {
        employeeExamDao.update(employeeExam);
    }

岗位考核的Dao层代码如下:

    @Select("select * from employee_exam")
    public List<EmployeeExam> findAll(int page, int size) throws Exception;

    @Insert("insert into employee_exam(Employee_id,Exam_name,Exam_time,Exam_score,Exam_note) values(#{EmployeeId},#{ExamName},#{ExamTime},#{ExamScore},#{ExamNote})")
    void save(EmployeeExam employeeExam);

    @Delete("delete from employee_exam where Exam_id=#{ExamId}")
    void deleteemployeeExamById(Integer ExamId);

    @Select("select * from employee_exam where Exam_id=#{ExamId}")
    EmployeeExam findById(Integer ExamId);

    @Update("update employee_exam set Employee_id=#{EmployeeId},Exam_name=#{ExamName},Exam_time=#{ExamTime},Exam_score=#{ExamScore},Exam_note=#{ExamNote} where Exam_id=#{ExamId}")
    void update(EmployeeExam employeeExam);

2、房产信息管理
spring+springMVC+mybatis实现的物业管理系统_第6张图片
以项目信息为例提供代码示例:
Controller层代码如下:

    @Autowired
    private IProjectProfileService projectProfileService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<ProjectProfile> projectProfileList =projectProfileService.findAll(page,size);
        PageInfo projectProfilePageInfo = new PageInfo(projectProfileList);
        mv.addObject("projectProfilePageInfo", projectProfilePageInfo);
        mv.setViewName("projectProfile-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "ProjectId", required = true) Integer ProjectId) throws Exception {
        ModelAndView mv = new ModelAndView();
        ProjectProfile projectProfile = projectProfileService.findById(ProjectId);
        mv.addObject("projectProfile",projectProfile);
        mv.setViewName("projectProfile-show");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "ProjectId", required = true) Integer ProjectId) throws Exception{
        projectProfileService.deleteprojectProfileById(ProjectId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(ProjectProfile projectProfile) throws Exception {
        projectProfileService.save(projectProfile);
        return "redirect:findAll";
    }
    @RequestMapping("/update")
    public String update(ProjectProfile projectProfile) throws Exception {
        projectProfileService.updateProjectProfile(projectProfile);
        return "redirect:findAll";
    }

Service层代码如下:

    @Autowired
    IProjectProfileDao projectProfileDao;
    @Override
    public List<ProjectProfile> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page, size);
        return  projectProfileDao.findAll(page,size);
    }

    @Override
    public void save(ProjectProfile projectProfile) {
        projectProfileDao.save(projectProfile);
    }

    @Override
    public void deleteprojectProfileById(Integer ProjectId) {
        projectProfileDao.deleteprojectProfileById(ProjectId);
    }

    @Override
    public ProjectProfile findById(Integer ProjectId) {
        return projectProfileDao.findById(ProjectId);
    }

    @Override
    public void updateProjectProfile(ProjectProfile projectProfile) {
        projectProfileDao.update(projectProfile);
    }

Dao层代码如下:

    @Select("select * from project_profile")
    public List<ProjectProfile> findAll(int page, int size) throws Exception;

    @Insert("insert into project_profile(Project_name,Project_class,Project_fee,Employee_id,Project_note) values(#{ProjectName},#{ProjectClass},#{ProjectFee},#{EmployeeId},#{ProjectNote})")
    void save(ProjectProfile projectProfile);

    @Delete("delete from project_profile where Project_id=#{ProjectId}")
    void deleteprojectProfileById(Integer ProjectId);

    @Select("select * from project_profile where Project_id=#{ProjectId}")
    ProjectProfile findById(Integer ProjectId);

    @Update("update project_profile set Project_name=#{ProjectName},Project_class=#{ProjectClass},Project_fee=#{ProjectFee},Employee_id=#{EmployeeId},Project_note=#{ProjectNote} where Project_id=#{ProjectId}")
    void update(ProjectProfile projectProfile);

3、客户信息管理
spring+springMVC+mybatis实现的物业管理系统_第7张图片
以车辆信息为例提供代码示例:
Controller层:

    @Autowired
    private IUserCarService userCarService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "8") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<UserCar> userCarList=userCarService.findAll(page,size);
        PageInfo userCarPageInfo = new PageInfo(userCarList);
        mv.addObject("userCarPageInfo", userCarPageInfo);
        mv.setViewName("userCar-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "CarId", required = true) Integer CarId) throws Exception {
        ModelAndView mv = new ModelAndView();
        UserCar userCar =userCarService.findById(CarId);
        mv.addObject("userCar",userCar);
        mv.setViewName("userCar-show");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "CarId", required = true) Integer CarId) throws Exception{
        userCarService.deleteuserCarById(CarId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(UserCar userCar) throws Exception {
        userCarService.save(userCar);
        return "redirect:findAll";
    }
    @RequestMapping("/update")
    public String update(UserCar userCar) throws Exception {
        userCarService.updateUserCar(userCar);
        return "redirect:findAll";
    }
    @RequestMapping("/findByUserId")
    public ModelAndView findByUserId(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size,@RequestParam(name = "UserId", required = true) Integer UserId) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<UserCar> userCarList=userCarService.findByUserId(page, size, UserId);
        PageInfo userCarPageInfos = new PageInfo(userCarList);
        mv.addObject("userCarPageInfos",userCarPageInfos);
        mv.setViewName("userCars-list");
        return mv;
    }

Service层:

    @Autowired
    IUserCarDao userCarDao;
    @Override
    public List<UserCar> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page, size);
        return  userCarDao.findAll(page,size);
    }

    @Override
    public void save(UserCar userCar) {
        userCarDao.save(userCar);
    }

    @Override
    public void deleteuserCarById(Integer CarId) {
        userCarDao.deleteuserCarById(CarId);
    }

    @Override
    public UserCar findById(Integer CarId) {
        return userCarDao.findById(CarId);
    }

    @Override
    public void updateUserCar(UserCar userCar) {
        userCarDao.update(userCar);

    }

    @Override
    public List<UserCar> findByUserId(int page, int size,Integer UserId) throws Exception {
        PageHelper.startPage(page, size);
        return userCarDao.findByUserId(page,size,UserId);
    }

Dao层:

    @Select("select * from user_car")
    public List<UserCar> findAll(int page, int size) throws Exception;

    @Insert("insert into user_car(Car_name,Car_id_number,User_id,Car_parking_place,Car_note) values(#{CarName},#{CarIdNumber},#{UserId},#{CarParkingPlace},#{CarNote})")
    void save(UserCar userCar);

    @Delete("delete from user_car where Car_id=#{CarId}")
    void deleteuserCarById(Integer CarId);

    @Select("select * from user_car where Car_id=#{CarId}")
    UserCar findById(Integer CarId);

    @Update("update user_car set Car_name=#{CarName},Car_id_number=#{CarIdNumber},User_id=#{UserId},Car_parking_place=#{CarParkingPlace},Car_note=#{CarNote} where Car_id=#{CarId}")
    void update(UserCar userCar);

    @Select("select * from user_car where User_id=#{UserId}")
    List<UserCar> findByUserId(int page, int size,@Param("UserId")Integer UserId) throws Exception;

4、收费管理
spring+springMVC+mybatis实现的物业管理系统_第8张图片
以房屋租赁费为例提供代码示例:
Controller层代码如下:

    @Autowired
    private IHouseLeaseService houseLeaseService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "4") int size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<HouseLease> houseLeaseList =houseLeaseService.findAll(page,size);
        PageInfo houseLeasePageInfo = new PageInfo(houseLeaseList);
        mv.addObject("houseLeasePageInfo", houseLeasePageInfo);
        mv.setViewName("houseLease-list");
        return mv;
    }
    @RequestMapping("/findById")
    public ModelAndView findById(@RequestParam(name = "HouseLeaseId", required = true) Integer HouseLeaseId) throws Exception {
        ModelAndView mv = new ModelAndView();
        HouseLease houseLease = houseLeaseService.findById(HouseLeaseId);
        mv.addObject("houseLease",houseLease);
        mv.setViewName("houseLease-show");
        return mv;
    }

    @RequestMapping("/delete")
    public String deletePermission(@RequestParam(name = "HouseLeaseId", required = true) Integer HouseLeaseId) throws Exception{
        houseLeaseService.deletehouseLeaseById(HouseLeaseId);
        return "redirect:findAll";
    }

    @RequestMapping("/save")
    public String save(HouseLease houseLease) throws Exception {
        houseLeaseService.save(houseLease);
        return "redirect:findAll";
    }
    @RequestMapping("/update")
    public String update(HouseLease houseLease) throws Exception {
        houseLeaseService.updateHouseLease(houseLease);
        return "redirect:findAll";
    }

Service层代码如下:

    @Autowired
    IHouseLeaseDao houseLeaseDao;
    @Override
    public List<HouseLease> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page, size);
        return  houseLeaseDao.findAll(page,size);
    }

    @Override
    public void save(HouseLease houseLease) {
        houseLeaseDao.save(houseLease);
    }

    @Override
    public void deletehouseLeaseById(Integer HouseLeaseId) {
        houseLeaseDao.deletehouseLeaseById(HouseLeaseId);
    }

    @Override
    public HouseLease findById(Integer HouseLeaseId) {
        return houseLeaseDao.findById(HouseLeaseId);
    }

    @Override
    public void updateHouseLease(HouseLease houseLease) {
        houseLeaseDao.update(houseLease);
    }

Dao层代码如下:

    @Select("select * from house_lease")
    public List<HouseLease> findAll(int page, int size) throws Exception;

    @Insert("insert into house_lease(User_id,User_name,House_lease_begin_time,House_lease_end_time,House_lease_unit_price,House_lease_fee_total,House_lease_fee_deposit,House_lease_note) values(#{UserId},#{UserName},#{HouseLeaseBeginTime},#{HouseLeaseEndTime},#{HouseLeaseUnitPrice},#{HouseLeaseFeeTotal},#{HouseLeaseFeeDeposit},#{HouseLeaseNote})")
    void save(HouseLease houseLease);

    @Delete("delete from house_lease where House_lease_id=#{HouseLeaseId}")
    void deletehouseLeaseById(Integer HouseLeaseId);

    @Select("select * from house_lease where House_lease_id=#{HouseLeaseId}")
    HouseLease findById(Integer HouseLeaseId);

    @Update("update house_lease set User_id=#{UserId},User_name=#{UserName},House_lease_begin_time=#{HouseLeaseBeginTime},House_lease_end_time=#{HouseLeaseEndTime},House_lease_unit_price=#{HouseLeaseUnitPrice},House_lease_fee_total=#{HouseLeaseFeeTotal},House_lease_fee_deposit=#{HouseLeaseFeeDeposit},House_lease_note=#{HouseLeaseNote} where House_lease_id=#{HouseLeaseId}")
    void update(HouseLease houseLease);

如果有需要完整项目的可以v我(备注来源):es_lad或者点此下载。

你可能感兴趣的:(jspweb项目上传文件,mybatis,spring,java)