不会调试运行的同学,你只需打开远程,会帮你搭建调试好一切(JDK、Idea/Eclipse、MySQL、Tomcat、Maven………)
前后端分离,前端用vue,后端用springboot,采用B/S模
package com.qingge.springboot.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qingge.springboot.common.Result;
import com.qingge.springboot.service.IAddressService;
import com.qingge.springboot.entity.Address;
import org.springframework.web.bind.annotation.RestController;
/**
*
* 前端控制器
*
*
*/
@RestController
@RequestMapping("/address")
public class AddressController {
@Resource
private IAddressService addressService;
// 新增或者更新
@PostMapping
public Result save(@RequestBody Address address) {
addressService.saveOrUpdate(address);
return Result.success();
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Integer id) {
addressService.removeById(id);
return Result.success();
}
@PostMapping("/del/batch")
public Result deleteBatch(@RequestBody List<Integer> ids) {
addressService.removeByIds(ids);
return Result.success();
}
@GetMapping
public Result findAll() {
return Result.success(addressService.list());
}
@GetMapping("/{id}")
public Result findOne(@PathVariable Integer id) {
return Result.success(addressService.getById(id));
}
@GetMapping("/page")
public Result findPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam String address,
@RequestParam Integer uid
) {
QueryWrapper<Address> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("id");
queryWrapper.like("address",address);
queryWrapper.eq("uid",uid);
return Result.success(addressService.page(new Page<>(pageNum, pageSize), queryWrapper));
}
}
import Vue from 'vue'
import VueRouter from 'vue-router'
import store from "@/store";
Vue.use(VueRouter)
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('../views/Login.vue')
},
{
path: '/register',
name: 'Register',
component: () => import('../views/Register.vue')
},
{
path: '/',
name: 'Jrh',
component: () => import('../views/jrh.vue')
},
{
path: '/mange',
name: 'Mange',
component: () => import('../views/mange.vue'),
children: [
{
path: '/mange/user',
name: 'User',
component: () => import('../views/User.vue')
},
{
path:'/mange/home',
name:'Home',
component:() => import('../views/Home.vue')
},
{
path:'/mange/list',
name:'List',
component:() => import('../views/List.vue')
},
{
path:'/mange/members',
name:'Members',
component:() => import('../views/Members.vue')
},
{
path:'/mange/orders',
name:'Orders',
component:() => import('../views/Orders.vue')
},
{
path:'/mange/Type',
name:'type',
component:() => import('../views/Type.vue')
},
]
},
{
path: '/404',
name: '404',
component: () => import('../views/404.vue')
},
{
path: '/front',
name: 'Front',
component: () => import('../views/front/fronthome.vue'),
children: [
{
path: 'home',
name: 'FrontHome',
component: () => import('../views/front/Home.vue')
},
{
path: 'item1',
name: 'Item1',
component: () => import('../views/front/Item1.vue')
},
{
path: 'person',
name: 'FrontPerson',
component: () => import('../views/front/Person')
},
{
path: 'password',
name: 'FrontPassword',
component: () => import('../views/front/Password')
},
{
path: 'information',
name: 'Information',
component: () => import('../views/front/Information')
},
{
path: 'message',
name: 'Message',
component: () => import('../views/front/Message')
},
{
path: 'adress',
name: 'Adress',
component: () => import('../views/front/Adress')
},
{
path: 'order',
name: 'Order',
component: () => import('../views/front/Order')
},
{
path: 'collect',
name: 'Collect',
component: () => import('../views/front/Collect')
},
{
path: 'shopping',
name: 'Shopping',
component: () => import('../views/front/Shopping')
},
{
path: 'txdd',
name: 'txdd',
component: () => import('../views/front/txdd')
},
{
path: 'txt1',
name: 'txt1',
component: () => import('../views/front/txt1.vue')
},
{
path: 'txt2',
name: 'txt2',
component: () => import('../views/front/txt2.vue')
},
{
path: 'txt3',
name: 'txt3',
component: () => import('../views/front/txt3.vue')
},
{
path: 'txt4',
name: 'txt4',
component: () => import('../views/front/txt4.vue')
},
{
path: 'txt5',
name: 'txt5',
component: () => import('../views/front/txt5.vue')
},
{
path: 'txt6',
name: 'txt6',
component: () => import('../views/front/txt6.vue')
},
{
path: 'txt7',
name: 'txt7',
component: () => import('../views/front/txt7.vue')
},
{
path: 'txt8',
name: 'txt8',
component: () => import('../views/front/txt8.vue')
},
{
path: 'txt9',
name: 'txt9',
component: () => import('../views/front/txt9.vue')
},
{
path: 'txt10',
name: 'txt10',
component: () => import('../views/front/txt10.vue')
},
{
path: 'txt11',
name: 'txt11',
component: () => import('../views/front/txt11.vue')
},
{
path: 'txt12',
name: 'txt12',
component: () => import('../views/front/txt12.vue')
},
{
path:'/chat',
name:'Chat',
component:() => import('../views/front/Chat.vue')
}
]
},
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export const resetRouter = () => {
router.matcher = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
}
export const setRoutes = () => {
const storeMenus = localStorage.getItem("menus");
if (storeMenus) {
// 获取当前的路由对象名称数组
const currentRouteNames = router.getRoutes().map(v => v.name)
if (!currentRouteNames.includes('Manage')) {
// 拼装动态路由
const manageRoute = {}
const menus = JSON.parse(storeMenus)
menus.forEach(item => {
if (item.path) { // 当且仅当path不为空的时候才去设置路由
let itemMenu = { path: item.path.replace("/", ""), name: item.name, component: () => import('../views/' + item.pagePath + '.vue')}
manageRoute.children.push(itemMenu)
} else if(item.children.length) {
item.children.forEach(item => {
if (item.path) {
let itemMenu = { path: item.path.replace("/", ""), name: item.name, component: () => import('../views/' + item.pagePath + '.vue')}
manageRoute.children.push(itemMenu)
}
})
}
})
// 动态添加到现在的路由对象中去
router.addRoute(manageRoute)
}
}
}
// 重置我就再set一次路由
setRoutes()
router.beforeEach((to, from, next) => {
localStorage.setItem("currentPathName", to.name) // 设置当前的路由名称
store.commit("setPath")
// 未找到路由的情况
if (!to.matched.length) {
const storeMenus = localStorage.getItem("menus")
if (storeMenus) {
next("/404")
} else {
// 跳回登录页面
next("/login")
}
}
// 其他的情况都放行
next()
})
export default router