基于javaweb和mysql的springboot宠物商城系统宠物交易平台(java+springboot+maven+mybatis+vue+mysql)

私信源码获取及调试交流

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

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

前端:WebStorm/VSCode/HBuilderX等均可

适用

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

功能说明

基于javaweb的SpringBoot宠物商城系统宠物交易平台(java+springboot+maven+mybatis+vue+mysql)

一、项目运行 环境配置:

Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等。

分为后台管理员和前台用户

用户可以售卖宠物,也可以购买宠物

    @PostMapping("/addskind")
    public Map addSKind(SKind skind){
        sKindService.addSKind(skind);
        Map map = new HashMap();
        map.put("skid",skind.getSkid());
        map.put("msg","种类添加成功");
        return map;
    }

    @GetMapping("/deleteskind")
    public String deleteSKind(Long skid){
        Map map = new HashMap();
        map.put("skid",skid);
        sKindService.deleteSKind(map);
        return "品种删除成功";
    }

    @PostMapping("/updateskind")
    public String updateSKind(SKind skind){
        sKindService.updateSKind(skind);
        return "种类修改成功";
    }

    @GetMapping("/queryallskind")
    public List<SKind> queryAllSKind(SKind sKind){
        Map map = new HashMap();
        if(sKind.getBkid() != null){
            map.put("bkid",sKind.getBkid());
        }
        if(sKind.getSkid() != null) {
            map.put("skid",sKind.getSkid());
        }
        if(sKind.getSkindname() != null && sKind.getSkindname() != "") {
            map.put("skindname",sKind.getSkindname());
        }
        return sKindService.queryAllSKind(map);
    }
}


    //删除用户
    @GetMapping("/deleteUser")
    public String deleteUser(Long uid){
        Map map = new HashMap();
        map.put("uid",uid);
        userService.deleteUser(map);
        petService.deletePet(map);
        addressService.deleteAddress(map);
        map.remove("uid");
        map.put("fromuid",uid);
        contactService.deleteContact(map);
        return "该用户已被删除";
    }

    //查找所有用户
    @GetMapping("/queryalluser")
    public List<User> querAllUser(@RequestParam(name = "page",required = false) Integer page,@RequestParam(name = "count",required = false) Integer count){
        Map map = new HashMap();
        if (page != null && count != null) {
            map.put("min",(page-1)*count);
            map.put("max",count);
        }
        List<User> user = userService.queryAllUser(map);
        return user;
    }

    @GetMapping("/countuser")
    public int countuser() {
        Map map = new HashMap();
        return userService.countuser(map);
    }

    @GetMapping("/querycontactuser")
    public List<ContactUser> querycontactuser(Long uid){
        return userService.querycontactuser(uid);
    }

    @GetMapping("/queryuserby")
    public Map queryuserby(User user){
        Map map = new HashMap();
        if(user.getUid() != null){
            map.put("uid",user.getUid());
        }
        if(user.getUsername() != null && user.getUsername() != ""){
            map.put("username",user.getUsername());
        }
        if(user.getRealname() != null && user.getRealname() != ""){
            map.put("realname",user.getRealname());
        }
        if(user.getIdcard() != null && user.getIdcard() != ""){
            map.put("idcard",user.getIdcard());
        }
        if(user.getTelphone() != null && user.getTelphone() != ""){

    //根据id查询宠物
    @GetMapping("/querypetbyid")
    public Pet queryPetById(Long pid){
        Pet pet = petService.queryPetById(pid);
        return pet;
    }

    //根据名字模糊查询
    @GetMapping("/queryPetByName")
    public List<Pet> queryPetByName(String petname){
        List<Pet> pets = petService.queryPetByName(petname);
        return pets;
    }

    //查询所有宠物
    @GetMapping("/queryAllPet")
    public List<Pet> queryAllPet(@RequestParam(name = "uid",required = false)Long uid,@RequestParam(name = "pk",required = false)Integer pk){
        Map map = new HashMap();
        if(uid != null) {
            map.put("uid",uid);
        }
        if (pk != null) {
            map.put("pk",pk);
        }
        List<Pet> pet = petService.queryAllPet(map);
        return pet;
    }

    //分页查询宠物
    @GetMapping("/querypetpage")
    public List<Pet> querypetpage(int page,int count,
                                  @RequestParam(name = "pid",required = false) Integer pid,
                                  @RequestParam(name = "uid",required = false) Integer uid,
                                  @RequestParam(name = "pk",required = false) Integer pk,
                                  @RequestParam(name = "bkid",required = false) String bkid,
                                  @RequestParam(name = "skid",required = false) String skid,
                                  @RequestParam(name = "age",required = false) String age,
                                  @RequestParam(name = "maxprice",required = false) Double maxprice,
                                  @RequestParam(name = "price",required = false) Double price,
                                  @RequestParam(name = "petname",required = false) String petname,
    @GetMapping("/deleteskind")
    public String deleteSKind(Long skid){
        Map map = new HashMap();
        map.put("skid",skid);
        sKindService.deleteSKind(map);
        return "品种删除成功";
    }

    @PostMapping("/updateskind")
    public String updateSKind(SKind skind){
        sKindService.updateSKind(skind);
        return "种类修改成功";
    }

    @GetMapping("/queryallskind")
    public List<SKind> queryAllSKind(SKind sKind){
        Map map = new HashMap();
        if(sKind.getBkid() != null){
            map.put("bkid",sKind.getBkid());
        }
        if(sKind.getSkid() != null) {
            map.put("skid",sKind.getSkid());
        }
        if(sKind.getSkindname() != null && sKind.getSkindname() != "") {
            map.put("skindname",sKind.getSkindname());
        }
        return sKindService.queryAllSKind(map);
    }
}

@RestController
@RequestMapping("/contact")
public class ContactController {
    @Autowired
    private ContactService contactService;

    @PostMapping("/updatecontact")
    public String updatecontact(Contact contact){
        contactService.updateContact(contact);
        return "更改成功";
    }
        if(uid != null) {
            map.put("uid",uid);
        }
        if (pk != null) {
            map.put("pk", pk);
        }
        if (skid != null && skid != "") {
            map.put("skid", skid);
        } else if (bkid != null && bkid != "") {
            map.put("bkid", bkid);
        }
        if (age != null && age != ""){
            map.put("age",age);
        }
        if (petname != null && petname != ""){
            map.put("petname",petname);
        }
        if (price != null){
            map.put("price",price);
        }
        if (date != null && date != ""){
            map.put("date",date);
        }
        return petService.querypetcount(map);
    }

    //查询所有宠物的最高价
    @GetMapping("/queryMaxPrice")
    public String queryMaxPrice(){
        return petService.queryMaxPrice();
    }

    //查询所有宠物年龄
    @GetMapping("/queryage")
    public List<Map> queryage(){
        return petService.queryage();
    }
}

        if (maxprice != null){
            map.put("maxprice",maxprice);
        }
        if (price != null){
            map.put("price",price);
        }
        if (petname != null && petname != ""){
            map.put("petname",petname);
        }
        if (date != null && date != ""){
            map.put("date",date);
        }
        if (sort != null && sort != ""){
            map.put("sort",sort);
        }
        List<Pet> pet = petService.queryPetpage(map);
        return pet;
    }

    //查询宠物条数
    @GetMapping("/querypetcount")
    public int querypetcount(@RequestParam(name = "pid",required = false) Integer pid,
                             @RequestParam(name = "uid",required = false) Integer uid,
                             @RequestParam(name = "pk",required = false) Integer pk,
                             @RequestParam(name = "bkid",required = false) String bkid,
                             @RequestParam(name = "skid",required = false) String skid,
                             @RequestParam(name = "age",required = false) String age,
                             @RequestParam(name = "price",required = false) Double price,
                             @RequestParam(name = "date",required = false) String date,
                             @RequestParam(name = "petname",required = false) String petname) {
        Map map = new HashMap();
        if(pid != null) {
            map.put("pid",pid);
        }
        if(uid != null) {
            map.put("uid",uid);
        }
        if (pk != null) {
            map.put("pk", pk);
        }
        if (skid != null && skid != "") {
            map.put("skid", skid);
        } else if (bkid != null && bkid != "") {
            map.put("bkid", bkid);
        }
        if (age != null && age != ""){
            map.put("age",age);
        }
        if (petname != null && petname != ""){
    public int querypetcount(@RequestParam(name = "pid",required = false) Integer pid,
                             @RequestParam(name = "uid",required = false) Integer uid,
                             @RequestParam(name = "pk",required = false) Integer pk,
                             @RequestParam(name = "bkid",required = false) String bkid,
                             @RequestParam(name = "skid",required = false) String skid,
                             @RequestParam(name = "age",required = false) String age,
                             @RequestParam(name = "price",required = false) Double price,
                             @RequestParam(name = "date",required = false) String date,
                             @RequestParam(name = "petname",required = false) String petname) {
        Map map = new HashMap();
        if(pid != null) {
            map.put("pid",pid);
        }
        if(uid != null) {
            map.put("uid",uid);
        }
        if (pk != null) {
            map.put("pk", pk);
        }
        if (skid != null && skid != "") {
            map.put("skid", skid);
        } else if (bkid != null && bkid != "") {
            map.put("bkid", bkid);
        }
        if (age != null && age != ""){
            map.put("age",age);
        }
        if (petname != null && petname != ""){
            map.put("petname",petname);
        }
        if (price != null){
            map.put("price",price);
        }
        if (date != null && date != ""){
            map.put("date",date);
        }
        return petService.querypetcount(map);
    }

    //查询所有宠物的最高价
            map.put("max",count);
        }
        Map map1 = new HashMap();
        map1.put("total",addressService.countaddress(map));
        map1.put("address",addressService.queryAddress(map));
        return map1;
    }
}

@RestController
@RequestMapping("/bkind")
public class BKindController {

    @Autowired
    private BKindService BKindService;
    @Autowired
    private PetService petService;
    @Autowired
    private SKindService sKindService;

    @PostMapping("/addBKind")
    public Map addBKind(BKind bkind){
        BKindService.addBKind(bkind);
        Map map = new HashMap();
        map.put("bkid",bkind.getBkid());
        map.put("msg","类型添加成功");
        return map;
            map.put("msg","旧密码错误");
            return map;
        }
    }

    //删除用户
    @GetMapping("/deleteUser")
    public String deleteUser(Long uid){
        Map map = new HashMap();
        map.put("uid",uid);
        userService.deleteUser(map);
        petService.deletePet(map);
        addressService.deleteAddress(map);
        map.remove("uid");
        map.put("fromuid",uid);
        contactService.deleteContact(map);
        return "该用户已被删除";
    }

    //查找所有用户
    @GetMapping("/queryalluser")
    public List<User> querAllUser(@RequestParam(name = "page",required = false) Integer page,@RequestParam(name = "count",required = false) Integer count){
        Map map = new HashMap();
        if (page != null && count != null) {
            map.put("min",(page-1)*count);
            map.put("max",count);
        }
        List<User> user = userService.queryAllUser(map);
        return user;
    }

    @GetMapping("/countuser")
    public int countuser() {
        Map map = new HashMap();
        return userService.countuser(map);
    }

    @GetMapping("/querycontactuser")
    public List<ContactUser> querycontactuser(Long uid){
        return userService.querycontactuser(uid);
    }

    @GetMapping("/queryuserby")
    public Map queryuserby(User user){
        Map map = new HashMap();
        if(user.getUid() != null){
            map.put("uid",user.getUid());
        }
        if(user.getUsername() != null && user.getUsername() != ""){
            map.put("username",user.getUsername());
        }
        if(user.getRealname() != null && user.getRealname() != ""){
            map.put("realname",user.getRealname());
            List<Photo> photos = photoService.queryPhotobypid(pet.getPid());
            if(photos.size() == 0) {
                photo.setUrl("defaultpetimg/nodata.jpg");
                photoService.addPhoto(photo);
            }
        }
        petService.updatePet(pet);
        return "修改完成";
    }

    //根据id查询宠物
    @GetMapping("/querypetbyid")
    public Pet queryPetById(Long pid){
        Pet pet = petService.queryPetById(pid);
        return pet;
    }

    //根据名字模糊查询
    @GetMapping("/queryPetByName")
    public List<Pet> queryPetByName(String petname){
        List<Pet> pets = petService.queryPetByName(petname);
        return pets;
    }

    //查询所有宠物
    @GetMapping("/queryAllPet")
    public List<Pet> queryAllPet(@RequestParam(name = "uid",required = false)Long uid,@RequestParam(name = "pk",required = false)Integer pk){
        Map map = new HashMap();
        if(uid != null) {
            map.put("uid",uid);
        }
        if (pk != null) {
            map.put("pk",pk);
        }
        List<Pet> pet = petService.queryAllPet(map);
        return pet;
    }

    //分页查询宠物
    @GetMapping("/querypetpage")
    public List<Pet> querypetpage(int page,int count,
                                  @RequestParam(name = "pid",required = false) Integer pid,
                                  @RequestParam(name = "uid",required = false) Integer uid,
                                  @RequestParam(name = "pk",required = false) Integer pk,
                                  @RequestParam(name = "bkid",required = false) String bkid,
                                  @RequestParam(name = "skid",required = false) String skid,
                                  @RequestParam(name = "age",required = false) String age,
                Map photomap = new HashMap();
                for(int i=0; i < ppid.length; i++) {
                    photomap.put("ppid",ppid[i]);
                    photoService.deletePhoto(photomap);
                    photomap.remove("ppid");
                }
            }
        }
        //增加图片
        if(files != null) {
            if(files.length > 0) {
                for (int i=0;i< files.length;i++){
                    //获取当前项目路径
                    String path = System.getProperty("user.dir") + "\\src\\main\\resources\\resources\\petimg\\";
                    //获取文件名字,前面拼接uiid是为了防止名字重复
                    String filename = createUUID.getUUID() + files[i].getOriginalFilename();
                    //创建文件对象,设置文件保存路径
                    File dest = new File(path + filename);
                    //将文件对象转化为文件
                    files[i].transferTo(dest);
                    photo.setUrl("petimg/" + filename);
                    photoService.addPhoto(photo);
                }
            } else {
                System.out.println("没有新加图片");
            }
        }
        //宠物为求购时,若没有图片,增加无数据图片
        if(pet.getPk() == 3) {
            List<Photo> photos = photoService.queryPhotobypid(pet.getPid());
            if(photos.size() == 0) {
                photo.setUrl("defaultpetimg/nodata.jpg");
                photoService.addPhoto(photo);
            }
        }
        petService.updatePet(pet);
        return "修改完成";
    }

    //根据id查询宠物
    @GetMapping("/querypetbyid")
    public Pet queryPetById(Long pid){
        Pet pet = petService.queryPetById(pid);
        return pet;
    }

    //根据名字模糊查询
    @GetMapping("/queryPetByName")
    public List<Pet> queryPetByName(String petname){
        List<Pet> pets = petService.queryPetByName(petname);
                                  @RequestParam(name = "date",required = false) String date,
                                  @RequestParam(name = "sort",required = false) String sort){
        Map map = new HashMap();
        map.put("min",(page-1)*count);
        map.put("max",count);
        if(pid != null) {
            map.put("pid",pid);
        }
        if(uid != null) {
            map.put("uid",uid);
        }
        if(pk != null) {
            map.put("pk",pk);
        }
        if(skid != null && skid != ""){
            map.put("skid",skid);
        }else if (bkid !=null && bkid != ""){
            map.put("bkid",bkid);
        }
        if (age != null && age != ""){
            map.put("age",age);
        }
        if (maxprice != null){
            map.put("maxprice",maxprice);
        }
        if (price != null){
            map.put("price",price);
        }
        if (petname != null && petname != ""){
            map.put("petname",petname);
        }
        if (date != null && date != ""){
            map.put("date",date);
        }
        if (sort != null && sort != ""){
            map.put("sort",sort);
        }
        List<Pet> pet = petService.queryPetpage(map);
        return pet;
    }

                map.put("msg","该身份证号已被注册");
                return map;
            }else {
                map.put("flag",1);
                map.put("msg","验证完成,可进行注册");
                return map;
            }
        }
    }

    //注册账号
    @PostMapping("/register")
    public Map register(User user){
        Map map = new HashMap();
        String path = "defaultavatar/avatar1.jpeg";
        user.setAvatar(path);
        user.setSex("保密");
        user.setType(1);
        userService.addUser(user);
        map.put("flag",1);
        map.put("msg","注册成功");
        return map;
    }

    //登录
    @GetMapping("/login")
    public Map login(String username, String password){
        //查找该用户名(即该账户)是否存在
        Map map = new HashMap();
        map.put("username", username);
        map.put("telphone", username);
        map.put("email", username);
        User user = userService.queryUser(map);
        map.remove("username");
        map.remove("telphone");
        map.remove("email");
        if (user == null){
            map.put("flag",0);
            map.put("msg","用户不存在");
            return map;
        }else if (password.equals(user.getPassword())){
            map.put("flag",1);
            map.put("uid",user.getUid());
            map.put("avatar",user.getAvatar());
            map.put("type",user.getType());
            map.put("msg","欢迎,"+user.getUsername());
            return map;
        }else {
            map.put("flag",0);
            map.put("msg","密码错误");
            return map;
        Date date = new Date();
        pet.setDate(date);
        petService.addPet(pet);
        Photo photo = new Photo();
        photo.setPid(pet.getPid());
        if (files != null){
            if (files.length > 0){
                for (int i=0;i< files.length;i++){
                    //获取当前项目路径
                    String path = System.getProperty("user.dir") + "\\src\\main\\resources\\resources\\petimg\\";
                    //前面拼接uiid是为了防止名字重复,获取文件的后缀名,不使用原文件名是防止文件名格式导致无法显示
                    String filename = createUUID.getUUID() + files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf("."));
                    //创建文件对象,设置文件保存路径
                    File dest = new File(path + filename);
                    //将文件对象转化为文件
                    files[i].transferTo(dest);
                    photo.setUrl("petimg/" + filename);
                    photoService.addPhoto(photo);
                }
            }
            else {
                photo.setUrl("defaultpetimg/nodata.jpg");
                photoService.addPhoto(photo);
            }
        }
        return "发布成功";
    }

    //删除宠物
    @GetMapping("/deletePet")
    public String deletePet(@RequestParam(name = "uid",required = false) Long uid, @RequestParam(name = "pid",required = false) Long pid){
        Map map = new HashMap();
        if(uid != null){
            map.put("uid",uid);
        }else{
            map.put("pid",pid);
            map.put("postatu",0);
        }
        List<Petorder> petorder = petorderService.querypetorder(map);
        map.remove("postatu");
        if(petorder.size() == 0){
            pet.setPk(pk);
            petService.updatePet(pet);
        }
        if(petorder.getPostatu() == 3){
            return "订单修改中,等待卖家确认";
        }else if(petorder.getPostatu() == 0){
            return "订单已修改成功";
        }else if(petorder.getPostatu() == 2){
            return "订单已取消";
        }else if(petorder.getPostatu() == 4){
            return "订单正在取消,等待卖方确认";
        }else {
            return "订单已完成";
        }
    }

    @GetMapping("/querypetorder")
    public List<Petorder> querypetorder(
                            @RequestParam(name = "uid",required = false) Long uid,
                            @RequestParam(name = "pid",required = false) Long pid,
                            @RequestParam(name = "poid",required = false) Long poid,
                            @RequestParam(name = "recipientname",required = false) String recipientname,
                            @RequestParam(name = "address",required = false) String address,
                            @RequestParam(name = "phone",required = false) String phone,
                            @RequestParam(name = "postatu",required = false) Integer postatu,
                            @RequestParam(name = "date",required = false) String date){
        Map map = new HashMap();
        if(uid != null) {
            map.put("uid",uid);
        }
        if(pid != null) {
            map.put("pid",pid);
        }
        if(poid != null) {
            map.put("poid",poid);
        }
        if(recipientname != null && recipientname != "") {
            map.put("recipientname",recipientname);
        }
        if(address != null && address != "") {
            map.put("address",address);
        }
        if(phone != null && phone != "") {
            map.put("phone",phone);
        }
        if(postatu != null) {

@RestController
@RequestMapping("/contact")
public class ContactController {
    @Autowired
    private ContactService contactService;

    @PostMapping("/updatecontact")
    public String updatecontact(Contact contact){
        contactService.updateContact(contact);
        return "更改成功";
    }

    @PostMapping("/addContact")
    public Long addContact(Contact contact){
        Map map = new HashMap();
        map.put("fromuid",contact.getFromuid());
        map.put("touid",contact.getTouid());
        List<Contact> contacts = contactService.queryContact(map);
        if (contacts.size() == 0){
            contactService.addContact(contact);
            return contact.getCid();
        }else {
            return contacts.get(0).getCid();
        }
    }

}


@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
//    @Qualifier("userServiceImpl")
    private UserService userService;

    @Autowired
    private PetService petService;

    @Autowired
    private AddressService addressService;

    @Autowired
    private ContactService contactService;

    //注册前检验用户是否存在
    @GetMapping("/checkuser")
    public Map checkuser(@RequestParam(value = "telphone",required = false)String telphone, @RequestParam(value = "idcard",required = false)String idcard){
        Map map = new HashMap();
        User user = new User();
        if (telphone != null) {
            map.put("telphone",telphone);
            user = userService.queryUser(map);
            map.remove("telphone");
            if(user != null){
                map.put("flag",0);
                map.put("msg","手机号已经被注册");
                return map;
            }else {
                map.put("flag",1);
                map.put("msg","可进行下一步");
                return map;
            }
        }else {
            map.put("idcard",idcard);
                }
            } else {
                System.out.println("没有新加图片");
            }
        }
        //宠物为求购时,若没有图片,增加无数据图片
        if(pet.getPk() == 3) {
            List<Photo> photos = photoService.queryPhotobypid(pet.getPid());
            if(photos.size() == 0) {
                photo.setUrl("defaultpetimg/nodata.jpg");
                photoService.addPhoto(photo);
            }
        }
        petService.updatePet(pet);
        return "修改完成";
    }

    //根据id查询宠物
    @GetMapping("/querypetbyid")
    public Pet queryPetById(Long pid){
        Pet pet = petService.queryPetById(pid);
        return pet;
    }

    //根据名字模糊查询
    @GetMapping("/queryPetByName")
    public List<Pet> queryPetByName(String petname){
        List<Pet> pets = petService.queryPetByName(petname);
        return pets;
    }

    //查询所有宠物
    @GetMapping("/queryAllPet")
    public List<Pet> queryAllPet(@RequestParam(name = "uid",required = false)Long uid,@RequestParam(name = "pk",required = false)Integer pk){
        Map map = new HashMap();
        if(uid != null) {
            map.put("uid",uid);
        }
        if (pk != null) {
            map.put("pk",pk);
        }
        List<Pet> pet = petService.queryAllPet(map);
        return pet;
    }

    //分页查询宠物
    @GetMapping("/querypetpage")
    public List<Pet> querypetpage(int page,int count,
                                  @RequestParam(name = "pid",required = false) Integer pid,
                                  @RequestParam(name = "uid",required = false) Integer uid,
                                  @RequestParam(name = "pk",required = false) Integer pk,

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐