Design and Implementation of Pet Adoption System Based on SSM

1 Introduction

Animals have been pets of humans for thousands of years, especially cats and dogs are loved and admired by humans because of their nature, and many idioms, stories, and sayings are related to them. However, in recent years, due to the acceleration of the pace of life, people's pressure has increased, and there is no time and space to take care of pets, so the number of families abandoning pets has increased, and more and more stray animals not only affect the lives of animals and even their survival. It also affects human life. According to Beijing's "Entertainment News", veterinary experts said that stray cats and dogs are more likely to spread diseases. "The probability of cats and dogs straying on the street carrying plague and other viruses, fleas and other parasites is much higher than that of domestic pets." In addition, a large number of stray cats and dogs also pose a serious hidden danger to the urban environment, traffic and public health safety, and it is also a disrespect for life. At the same time, some families regret not finding suitable pets.

At present, there are many problems in the rescue of animals, such as limited rescue areas, large investment, remote sites, and difficulties in updating and releasing information. These situations have led to the situation of "more income and less output" for animals in animal rescues, which has led to increasingly serious problems in the shelter's economy and space. Today, with the rapid development of network technology, e-commerce has a greater and greater impact on people, ranging from buying and selling clothes to housing transactions can be carried out through e-commerce. People are becoming more and more accustomed to staying at home and completing a lot of personal affairs. Relying on the advantages of the Internet, it is urgent to develop a network-based pet adoption and support system by combining animal adoption and support.

This paper describes the entire process of developing a stray cat and dog rescue system based on SSM. By accessing the platform on the Internet, users can decide the rescue method according to their own needs, family environment, pet conditions and other factors. Of course, taking into account the conditions of the animals themselves and the users themselves, the website administrator has the right to prevent users from rescuing them, and can also dynamically manage the rescue of animals, and determine whether members have the right to adopt according to national laws and regulations; finally, adoption People can upload life photos of animals through the platform for adoption feedback.

2. Development technology

2.1 B/S framework

The B/S architecture is a software system architecture, referring to the browser-Web server (Broswer-Server), which adopts a three-tier architecture, namely the presentation layer, business logic layer, and data access layer. In the B/S architecture, the user interface is completely implemented through the browser, and part of the business logic is implemented on the front end, but the main business logic is implemented on the server side, forming the so-called 30% architecture. In the B/S architecture system, the user sends requests to many servers distributed on the network through the browser, and the server processes the browser's request and returns the information required by the user to the browser. The rest, such as data request, processing, result return, generation of dynamic web page, access to database and execution of application program, etc., are all completed by Web Server. With Windows embedding browser technology inside the operating system, this structure has become the preferred structure of today's application software.

2.2 JSP technology

The full name of JSP is JavaServer Pages, which is a dynamic web page technology standard created by Sun Microsystems. It is built on a web server, can receive instructions sent by the client, dynamically generate HTML and other web pages according to the contents of the instructions, and then return them to the requester. JSP can be created independently according to the needs of R&D personnel, and various languages ​​can be run in other ways, which is universal.

Due to the JSP dynamic standard, it has many advantages compared with ordinary static standards. For example, JSP can embed codes in static pages and can change them at any time, and use static pages as templates to realize dynamic generation of some content. At the same time, it also has More powerful interactivity. It also introduces an XML tag called "action" for calling built-in functions. The tag library can be used dynamically with the platform, and has adaptability to various environments outside the platform. These easy-to-use functions are loved by many developers.

2.3 MVC framework

The full name of MVC is Model View Controller, which is the abbreviation of Model-View-Controller. It is a model of software design. It uses a method of separating business logic, data, and interface display to organize code and gather business logic into one component. Improve and personalize custom interfaces and user interactions without rewriting business logic. MVC was uniquely developed to map traditional input, processing, and output functions in a logical GUI structure.

2.4 MySQL

MySQL is a small and medium-sized relational database management system that can be processed on a web server that supports multithreading [13]. It is a software developed by ORACLE, and it is one of the best RDBMS applications in web applications.

MySQL can store data in different tables. These tables are equivalent to small warehouses, and various warehouses are intertwined. This "interweaving" connection method greatly improves the flexibility of data. MySQL uses the SQL language, has a free version, and is open to the public, and can build a good development environment with Apache. MySQL has the advantages of low cost, high speed, and small size. In terms of application, it also has the advantages of good security and fast development speed. For some enterprises and individual users who want to save costs, choosing MySQL is a very good choice.

3. Functional design

Members of this system are divided into three roles: tourists, users, and administrators. The system structure diagram shows:

Administrator privileges:

(1) The administrator has the authority to manage users mainly to delete user information of users who violate the agreement and who have not logged in for a long time.

(2) The administrator has the authority to manage pets mainly to publish new pet information, delete dead pet information, modify pet adoption status information, review pets released by users, etc.

(2) The administrator has the authority to manage orders, including: modifying order status, reviewing orders, canceling unreasonable orders, confirming orders, etc.

(3) Administrators have the authority to manage pet categories, including: adding, deleting, and modifying pet category information.

(4) The administrator has the authority to manage freight categories, including: adding, deleting, and modifying freight category information.

(5) The administrator has the authority to manage the adoption of pets, mainly to modify the adoption information.

User rights:

(6) Users have the authority to browse all pet information on the website and post information about pets in need of rescue.

(7) The user has the authority to retrieve pets by keyword.

(8) Personal information management: Modify personal registration information.

(9) Password management: retrieve password, modify password.

(10) Add, view or delete personal favorites.

(11) Put the selected pet into the pet cart.

(12) View, add and delete pets in the pet cart

(13) If adopting, submit the order directly; if adopting, submit the order and fill in the necessary receiving information.

(14) If directly sponsoring, directly modify the pet sponsorship information.

(15) View the total amount including shipping

(16) Check the monthly consumption details of sponsored pets.

(17) Upload recent photos of adopted pets for the administrator to return visits.

(18) Message information management: add a message

(19) Log out

Visitor Permissions:

(1) Visitors have the right to browse all pet information on the website, mainly to view pet information.

(2) Tourists have the authority to search for pets by keyword.

(3) Visitors have the right to register as members.

4. Functional renderings

4.1 Home page

4.2 Adoption Center

 4.3 Login

 4.4 Registration

4.5 Background administrator login 

5. Core code

@Controller
@RequestMapping("adopt")
public class AdoptAnimalController {

    @Autowired
    private AdoptAnimalService animalService;

    @Autowired
    private PetService petService;

    @Autowired
    private UsersService usersService;

    @RequestMapping("adopts.action")
    @ResponseBody
    public Message getAdoptAnimals(@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        PageHelper.startPage(pn,4);
        AdoptAnimal animal=new AdoptAnimal();
        List<AdoptAnimal> adoptAnimals = animalService.findByState(1);
        PageInfo page=new PageInfo(adoptAnimals,2);
        return Message.success().add("pageInfo",page);
    }


    @RequestMapping("ByAgree.action")
    @ResponseBody
    public Message getAdoptStates(@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        PageHelper.startPage(pn,4);
        int state=2;
        List<AdoptAnimal> adoptAnimals = animalService.findByState(state);
        PageInfo page=new PageInfo(adoptAnimals,2);
        return Message.success().add("pageInfo",page);
    }

    @RequestMapping("ByDisAgree.action")
    @ResponseBody
    public Message getAdoptDisagress(@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        PageHelper.startPage(pn,4);
        int state=0;
        List<AdoptAnimal> adoptAnimals = animalService.findByState(state);
        PageInfo page=new PageInfo(adoptAnimals,2);
        return Message.success().add("pageInfo",page);
    }

    @RequestMapping("create.action")
    @ResponseBody
    public Message createAdopt(HttpServletRequest request){
        Pet pet = (Pet)request.getSession().getAttribute("pet");
        Users user = (Users)request.getSession().getAttribute("user");
        pet.setState(1);
        AdoptAnimal animal=new AdoptAnimal();
        animal.setUser(user);
        animal.setPet(pet);
        animal.setState(1);
        animal.setAdoptTime(new Date());
        int i = animalService.addAdoptAnimal(animal);
        int t=petService.updateState(pet);
        if(i>0&&t>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("delete.action")
    @ResponseBody
    public Message deleteAdopt(Integer id){
        if(animalService.deleteAdoptAnimal(id)>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("update.action")
    @ResponseBody
    public Message updateAdoptAnimal(AdoptAnimal animal){
        if(animalService.updateAdoptAnimal(animal)>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping(value = "disAgree.action", method = RequestMethod.GET)
    @ResponseBody
    public Message updateAdoptState(Integer id) throws MessagingException {
        AdoptAnimal animal = animalService.findById(id);
        animal.setState(0);
        Pet pet = animal.getPet();
        pet.setState(0);
        int i = animalService.updateAdoptState(animal);
        int t=petService.updateState(pet);
        if(i>0&&t>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping(value = "agree.action",method = RequestMethod.GET)
    @ResponseBody
    public Message updateAdoptStates(Integer id) throws MessagingException {
        AdoptAnimal animal = animalService.findById(id);
        animal.setState(2);
        Pet pet = animal.getPet();
        pet.setState(2);
        int a = animalService.updateAdoptState(animal);
        int b=petService.updateState(pet);
        if(a>0&&b>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("findById.action")
    @ResponseBody
    public Message findById(Integer id){
        AdoptAnimal animal = animalService.findById(id);
        if(animal!=null){
            return Message.success().add("animal",animal);
        }else{
            return Message.fail();
        }
    }


    @RequestMapping("findByAdoptTime.action")
    @ResponseBody
    public Message findByAdoptTime(String adoptTime) throws ParseException {
        PageHelper.startPage(1,4);
        List<AdoptAnimal> adoptAnimals = animalService.findByAdoptTime(adoptTime);
        if(adoptAnimals!=null){
            PageInfo page=new PageInfo(adoptAnimals,3);
            return Message.success().add("pageInfo",page);
        }else{
            return Message.fail();
        }

    }

    @RequestMapping("findByName.action")
    @ResponseBody
    public Message findByName(@RequestParam(value = "pn",defaultValue = "1")Integer pn,@RequestParam(value = "userName") String userName,@RequestParam(value = "state") Integer state) throws ParseException {
        PageHelper.startPage(1,4);
        List<Users> users = usersService.findByName(userName);
        List<AdoptAnimal> adoptAnimals = animalService.findByName(users,state);
        if(adoptAnimals!=null){
            PageInfo page=new PageInfo(adoptAnimals,3);
            return Message.success().add("pageInfo",page);
        }else{
            return Message.fail();
        }

    }
}
@Controller
@RequestMapping("pet")
public class PetController {

    @Autowired
    private PetService petService;

    @RequestMapping("pets.action")
    @ResponseBody
    public Message getPets(@RequestParam(value = "pn",defaultValue = "1")Integer pn){
        PageHelper.startPage(pn,3);
        List<Pet> pets = petService.getPets();
        System.out.println(pets);
        PageInfo page=new PageInfo(pets,2);
        return Message.success().add("pageInfo",page);
    }

    @RequestMapping("petState.action")
    @ResponseBody
    public Message findByState(@RequestParam(value = "pn",defaultValue = "1")Integer pn){
        PageHelper.startPage(pn,3);
        int state=0;
        List<Pet> pets = petService.findByState(0);
        System.out.println(pets);
        PageInfo page=new PageInfo(pets,2);
        return Message.success().add("pageInfo",page);
    }

    @RequestMapping(value = "create.action")
    @ResponseBody
    public Message createPet(Pet pet,@RequestParam(value = "file") MultipartFile file, HttpServletRequest request){
        String load = FileLoad.load(file,request);
        pet.setPic(load);
        if(petService.addPet(pet)>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("delete.action")
    @ResponseBody
    public Message deletePet(Integer id){
        if(petService.deletePet(id)>0){
            return Message.success();
        }else {
            return Message.fail();
        }
    }

    @RequestMapping("update.action")
    @ResponseBody
    public Message updatePet(Pet pet){
        if(petService.updatePet(pet)>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("findById.action")
    @ResponseBody
    public Message findById(Integer id){
        Pet pet = petService.findById(id);
        if(pet!=null){
            return Message.success().add("pet",pet);
        }else{
            return Message.fail();
        }
    }
    @RequestMapping("findByPet.action")
    @ResponseBody
    public Message findByPet(Integer id, HttpServletRequest request){
        Pet pet = petService.findById(id);
        System.out.println(pet);
        String pic = pet.getPic();
        String[] split = pic.split(",");
        List<String> pics=new ArrayList<>();
        for(int i=0;i<split.length;i++){
            pics.add(split[i]);
        }

        request.getSession().setAttribute("pics",pic);
        request.getSession().setAttribute("pet",pet);
        if(pet!=null){
            return Message.success().add("pet",pet);
        } else{
            return Message.fail();
        }

    }
    @RequestMapping("findByPetType.action")
    @ResponseBody
    public Message findByName(@RequestParam(value = "pn",defaultValue = "1")Integer pn,String petType){
        PageHelper.startPage(pn,4);
        List<Pet> pets = petService.findByPetType(petType);
        if(pets!=null){
            PageInfo page=new PageInfo(pets,3);
            return Message.success().add("pageInfo",page);
        }else{
            return Message.fail();
        }
    }

}
@Controller
@RequestMapping("apply")
public class ApplyController {

    @Autowired
    private ApplyService applyService;


    @RequestMapping("applys.action")
    @ResponseBody
    public Message getBlog(@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        // 引入PageHelper分页插件
        // 在查询之前只需要调用,传入页码,以及每页的大小
        PageHelper.startPage(pn,3);
        List<Apply> applys = applyService.getApply();
        System.out.println(applys);
        // startPage后面紧跟的这个查询就是一个分页查询
        // 使用pageInfo包装查询后的结果,只需要将pageInfo交给页面就行了。
        // 封装了详细的分页信息,包括有我们查询出来的数据,传入连续显示的页数
        PageInfo page=new PageInfo(applys,2);
        return Message.success().add("pageInfo",page);
    }

    @RequestMapping("create.action")
    @ResponseBody
    public Message addApply(Apply apply){
        apply.setApplyTime(new Date());
        apply.setState(2);
        int i = applyService.addApply(apply);
        if(i>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("delete.action")
    @ResponseBody
    public Message deleteApply(Integer id){
        int i = applyService.deleteApply(id);
        if(i>0){
            return Message.success();
        }else {
            return Message.fail();
        }
    }

    @RequestMapping("update.action")
    @ResponseBody
    public Message updateApply(Apply apply){
        if(applyService.updateApply(apply)>0){
            return Message.success();
        }else{
            return Message.fail();
        }
    }

    @RequestMapping("findById.action")
    @ResponseBody
    public Message findById(Integer id){
        Apply apply=applyService.findById(id);
        if(apply!=null){
            return Message.success().add("apply",apply);
        }else{
            return Message.fail();
        }

    }

    @RequestMapping("findByState.action")
    @ResponseBody
    public Message findByTime(@RequestParam(defaultValue ="1",value = "pn") Integer pn,Integer state){
        PageHelper.startPage(pn,4);
        List<Apply> states = applyService.findByState(state);
        if(states!=null){
            PageInfo page=new PageInfo(states,3);
            return Message.success().add("pageInfo",page);
        }else{
            return Message.fail();
        }

    }

}

6. Reference Papers

 Summary

ABSTRACT

Chapter 1 Introduction

1.1 Introduction

1.2 The source and significance of the topic

1.3 Development at home and abroad

Chapter 2 System Development Tools and Techniques

2.1 System Development Tools

2.2 System Development Technology

Chapter 3 Requirements Analysis

3.1 Overall analysis of the system

3.2 Data description

Chapter 4 System Detailed Design

4.1 User login module

4.2 User registration module

4.3 Pet query module

4.4 Pet Details

4.5 Pet car

4.6 Member order management

4.7 Administrator login module

4.8 Add pet information module

4.9 Pet information modification module

4.10 Administrator order management module

4.11 Administrator report function

Chapter 5 Detailed Design and Implementation of System Functions

5.1 User detailed implementation

5.2 Administrator detailed implementation

Chapter 6 Functional Testing

6.1 Client function test

6.2 Background management function test

6.3 Analysis of test results

Chapter 7 Summary and Outlook

references

thank you

7. Summary

This system realizes the function of the stray cat and dog rescue system based on JSP. During the development of this system, I have benefited a lot. First of all, I realize the importance of code specification, especially in some large-scale projects, there may be hundreds of functions used, if the code written is not standardized, it will bring great trouble to the later inspection. And complete code testing is also very important, some errors may not be discovered until a long time later. Secondly, I am aware of the importance of software design. The projects I used to contact are often rapid development types. I hardly need to spend too much time on software logic design, and I can often proceed to the next step of design while developing. But this time I realized that it is very important to do software design. I did not pay attention to a design at the beginning, which may cause a large area of ​​rework in the subsequent coding. The last is the importance of the debugging method. The debugging process of the system is much more cumbersome than the development process. Every operation and every request submitted to the server actually includes the execution of many small pieces of code. If the correct debugging method cannot be adopted, it will be difficult to find out the errors in the program.

The system also has many expandable functions, such as adding the role of animal rescue stations. To manage pets, there are many deficiencies in the management of schedules, and there are certain defects in the management of orders. Due to the limited time, I can't make the function perfect yet, but I think I can definitely make a more perfect system in the future efforts.

Likes, likes, collections, and attention to private letters Author communication

Guess you like

Origin blog.csdn.net/lf21qp/article/details/131321864