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

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

运行环境

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

开发工具

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

前端:WebStorm/VSCode/HBuilderX等均可

适用

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

功能说明

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

一、项目运行 环境配置:

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

项目技术:

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

        }
        if(address != null && address != "") {
            map.put("address",address);
        }
        if(phone != null && phone != "") {
            map.put("phone",phone);
        }
        if(postatu != null) {
            map.put("postatu",postatu);
        }
        if(date != null &&  date != "") {
            map.put("date",date);
        }
        Map map1 = new HashMap();
        map1.put("total",petorderService.countpetorder(map));
        map1.put("petorder",petorderService.querypetorderpage(map));
        return map1;
    }
}

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @PostMapping("/addAddress")
    public Map addAddress(Address address){
        addressService.addAddress(address);
        Map map = new HashMap();
        map.put("aid",address.getAid());
        map.put("msg","添加成功");
            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;
    }

    @GetMapping("/deleteBKind")
    public String deleteBKind(Long bkid){
    @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) {
            map.put("postatu",postatu);
        }
        if(date != null &&  date != "") {
            map.put("date",date);
        }
        return petorderService.querypetorder(map);
    }

    @GetMapping("/querypetorderpage")
    public Map querypetorderpage(@RequestParam(name = "page",required = false)Integer page,
                             @RequestParam(name = "count",required = false)Integer count,
                             @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,

@RestController
@RequestMapping("/skind")
public class SKindController {

    @Autowired
    private SKindService sKindService;

    @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);
    }
}

    public String deleteBKind(Long bkid){
        Map map = new HashMap();
        petService.setPetbkidNULL(bkid);
        map.put("bkid",bkid);
        sKindService.deleteSKind(map);
        BKindService.deleteBKind(bkid);
        return "类型删除成功";
    }

    @GetMapping("/updateBKind")
    public String updateBKind(BKind kind){
        BKindService.updateBKind(kind);
        return "类型修改成功";
    }

    @GetMapping("/queryBKind")
    public List<BKind> queryBKind(){
        List<BKind> kind = BKindService.queryBKind();
        return kind;
    }

    @GetMapping("/queryBKindname")
    public List<Map> queryBKindname(){
        List<Map> map = BKindService.queryBKindname();
        return map;
    }

    @GetMapping("/queryBKindandSKind")
    public List<BKind> queryBKindandSKind(BKind bkind){
        Map map = new HashMap();
        if(bkind.getBkid() != null) {
            map.put("bkid",bkind.getBkid());
        }
        if(bkind.getBkindname() != null && bkind.getBkindname() != "") {
            map.put("bkindname",bkind.getBkindname());
        }
        return BKindService.queryBKindandSKind(map);
    }
}

        }
        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 != ""){
                             @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(page != null && count != null){
            map.put("min",(page-1)*count);
            map.put("max",count);
        }
        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) {
            map.put("postatu",postatu);
        }
        if(date != null &&  date != "") {
            map.put("date",date);
        }
        Map map1 = new HashMap();
        map1.put("total",petorderService.countpetorder(map));
        map1.put("petorder",petorderService.querypetorderpage(map));
        return map1;
    }
}


    //发布宠物出售或购买请求
    @PostMapping("/addPet")
    public String addPet(@RequestParam(name = "files",required = false) MultipartFile[] files,Pet pet) throws IOException {
        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){
            petService.deletePet(map);
            photoService.deletePhoto(map);
            return "删除成功";
        }else {
            map.put("min",(page-1)*count);
            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;
    }

    @GetMapping("/deleteBKind")
    public String deleteBKind(Long bkid){
        Map map = new HashMap();
        petService.setPetbkidNULL(bkid);
        map.put("bkid",bkid);
            user = userService.queryUser(map);
            map.remove("idcard");
            if (user != null){
                map.put("flag",0);
                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());
@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("/notice")
public class NoticeController {
        }
        if(user.getTelphone() != null && user.getTelphone() != ""){
            map.put("telphone",user.getTelphone());
        }
        Map map1 = new HashMap();
        map1.put("total",userService.countuser(map));
        map1.put("user",userService.queryuserby(map));
        return map1;
    }
}

@RestController
@RequestMapping("/petorder")
public class PetorderController {

    @Autowired
    private PetorderService petorderService;

    @Autowired
    private PetService petService;

    @PostMapping("/addpetorder")
    public Map addpetorder(Petorder petorder){
        Pet spet = petService.queryPetById(petorder.getPid());
        Map map = new HashMap();
        if(spet == null) {
            map.put("flag",0);
            map.put("msg","卖方已删除该宠物");
            return map;
        }else {
            if(spet.getPk() == 0){
                Date date = new Date();
                petorder.setDate(date);
                Pet pet = new Pet();
                pet.setPid(petorder.getPid());
                pet.setPk(1);
                petService.updatePet(pet);
                petorderService.addpetorder(petorder);
        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;
        }
    }

    //查找单个用户的信息
    @GetMapping("/queryuser")
    public User queryuser(Long uid){
        Map map = new HashMap();
        map.put("uid",uid);
        User user = userService.queryUser(map);
        if(user.getType() == 1){
            String idcard = user.getIdcard();
            String start = idcard.substring(0,1);
            String end = idcard.substring(idcard.length()-1);
            String center = idcard.substring(1,idcard.length()-1);
            String newidcard = start + center.replaceAll("[0-9Xx]","*") + end;
            user.setIdcard(newidcard);
        }
        return user;
    }

    //修改用户信息
    @PostMapping("/updateuser")
    public Map updateuser(@RequestParam(name = "file",required = false) MultipartFile file, User user) throws IOException {
        Map map = new HashMap();
        User uuser = null;
        if(user.getTelphone() != null){
            map.put("telphone",user.getTelphone());
            uuser = userService.queryUser(map);
            map.put("phone",phone);
        }
        if(postatu != null) {
            map.put("postatu",postatu);
        }
        if(date != null &&  date != "") {
            map.put("date",date);
        }
        return petorderService.querypetorder(map);
    }

    @GetMapping("/querypetorderpage")
    public Map querypetorderpage(@RequestParam(name = "page",required = false)Integer page,
                             @RequestParam(name = "count",required = false)Integer count,
                             @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(page != null && count != null){
            map.put("min",(page-1)*count);
            map.put("max",count);
        }
        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) {
            map.put("postatu",postatu);
        }
        if(date != null &&  date != "") {
            map.put("date",date);
        }
        Map map1 = new HashMap();
        map1.put("total",petorderService.countpetorder(map));
        map1.put("petorder",petorderService.querypetorderpage(map));
            map.put("flag",0);
            map.put("msg","密码错误");
            return map;
        }
    }

    //查找单个用户的信息
    @GetMapping("/queryuser")
    public User queryuser(Long uid){
        Map map = new HashMap();
        map.put("uid",uid);
        User user = userService.queryUser(map);
        if(user.getType() == 1){
            String idcard = user.getIdcard();
            String start = idcard.substring(0,1);
            String end = idcard.substring(idcard.length()-1);
            String center = idcard.substring(1,idcard.length()-1);
            String newidcard = start + center.replaceAll("[0-9Xx]","*") + end;
            user.setIdcard(newidcard);
        }
        return user;
    }

    //修改用户信息
    @PostMapping("/updateuser")
    public Map updateuser(@RequestParam(name = "file",required = false) MultipartFile file, User user) throws IOException {
        Map map = new HashMap();
        User uuser = null;
        if(user.getTelphone() != null){
            map.put("telphone",user.getTelphone());
            uuser = userService.queryUser(map);
            map.remove("telphone");
            if(uuser != null && uuser.getUid() != user.getUid()){
                map.put("flag",0);
                map.put("msg","该手机号已被注册");
                return map;
            }
        }
        if(user.getUsername() != null){
            map.put("username",user.getUsername());
            uuser = userService.queryUser(map);
            map.remove("username");
        }
        if(uuser == null || uuser.getUid() == user.getUid()){
            if(file != null) {
                if(!file.isEmpty()) {
                    //获取当前项目路径
                    String path = System.getProperty("user.dir") + "\\src\\main\\resources\\resources\\avatar\\";
                    //获取文件名字,前面拼接uiid是为了防止名字重复
                    String filename = createUUID.getUUID() + file.getOriginalFilename();
                    //创建文件对象,设置文件保存路径
                    File dest = new File(path + filename);
                    //将文件对象转化为文件
                                  @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,
                                  @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;
    }

    }

    //分页查询宠物
    @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,
                                  @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);

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值