基于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 (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();
}
}
@RestController
@RequestMapping("/user")
public class UserController {
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);
}
}
@RestController
@RequestMapping("/skind")
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(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","添加成功");
return map;
}
@GetMapping("/deleteAddress")
public String deleteAddress(@RequestParam(name = "aid",required = false)Long aid,@RequestParam(name = "uid",required = false)String uid){
Map map = new HashMap();
if(aid != null){
map.put("aid",aid);
@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;
}
//查询所有宠物
@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,
@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.remove("uid");
String oldavatar = uuser.getAvatar();
int index = oldavatar.indexOf("defaultavatar/");
//判断旧头像是否为默认头像,不是则删除旧头像
if(index == -1) {
//得到旧头像的地址
String oldpath = System.getProperty("user.dir") + "\\src\\main\\resources\\resources\\" + oldavatar.replace("/", "\\");
File olddest = new File(oldpath);
//删除旧头像
// olddest.delete();
}
}
}
userService.updateUser(user);
map.put("avatar",user.getAvatar());
map.put("flag",1);
map.put("msg","修改成功");
}else {
map.put("flag",0);
map.put("msg","用户名已存在");
}
return map;
}
//修改密码
@PostMapping("/changepassword")
public Map changepsaaword(User user,@RequestParam(value = "oldpassword")String oldpassword){
Map map = new HashMap();
map.put("uid",user.getUid());
User user1 = userService.queryUser(map);
map.remove("uid");
if(user1.getPassword().equals(oldpassword)){
userService.updateUser(user);
map.put("flag",1);
map.put("msg","修改成功");
return map;
}else {
map.put("flag",0);
map.put("msg","旧密码错误");
return map;
}
}
//删除用户
@GetMapping("/deleteUser")
public String deleteUser(Long uid){
Map map = new HashMap();
map.put("uid",uid);
userService.deleteUser(map);
}
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 (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();
}
}
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
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","添加成功");
return map;
}
@GetMapping("/deleteAddress")
public String deleteAddress(@RequestParam(name = "aid",required = false)Long aid,@RequestParam(name = "uid",required = false)String uid){
Map map = new HashMap();
if(aid != null){
map.put("aid",aid);
}
if(uid != null){
map.put("uid",uid);
}
addressService.deleteAddress(map);
return "改地址已被删除";
}
@PostMapping("/updateAddress")
public String updateAddress(Address address){
addressService.updateAddress(address);
return "修改成功";
}
@GetMapping("/queryAddressbyuid")
public List<Address> queryAddressbyuid(Long uid){
Map map = new HashMap();
}
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();
}
}
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 {
return "该宠物已被购买,无法删除";
}
@GetMapping("/queryAddressbyuid")
public List<Address> queryAddressbyuid(Long uid){
Map map = new HashMap();
map.put("uid",uid);
return addressService.queryAddressbyuid(map);
}
@GetMapping("/queryaddress")
public Map queryaddress(@RequestParam(name = "page",required = false)Integer page,@RequestParam(name = "count",required = false)Integer count,Address address) {
Map map =new HashMap();
if(address.getAid() != null){
map.put("aid",address.getAid());
}
if(address.getUid() != null){
map.put("uid",address.getUid());
}
if(address.getAddress() != null && address.getAddress() != ""){
map.put("address",address.getAddress());
}
if(address.getPhone() != null && address.getPhone() != ""){
map.put("phone",address.getPhone());
}
if(address.getUsername() != null && address.getUsername() != ""){
map.put("username",address.getUsername());
}
if(page != null && count != null){
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;
}
}
map.put("uid",address.getUid());
}
if(address.getAddress() != null && address.getAddress() != ""){
map.put("address",address.getAddress());
}
if(address.getPhone() != null && address.getPhone() != ""){
map.put("phone",address.getPhone());
}
if(address.getUsername() != null && address.getUsername() != ""){
map.put("username",address.getUsername());
}
if(page != null && count != null){
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 {
}
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;
}
}
@RestController
@RequestMapping("/address")
public class AddressController {
@Autowired
private AddressService addressService;
@PostMapping("/addAddress")
public Map addAddress(Address address){
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);
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);
}
@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() != ""){
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 {