🔥博客主页: 【小扳_-CSDN博客】
❤感谢大家点赞👍收藏⭐评论✍

 

文章目录

        1.0 项目介绍

        1.1 项目功能

        2.0 用户登录功能

        3.0 首页界面

        4.0 车辆信息管理功能

        5.0 停车位管理功能

        6.0 入场登记管理功能

        7.0 预约管理功能

        8.0 收费规则功能

        9.0 出场登记管理功能

        10.0 用户信息管理功能

        11.0 SQL 数据库设计


        1.0 项目介绍

        开发工具:IDEA、VScode

        服务器:Tomcat, JDK 17

        项目构建:maven

        数据库:mysql 8.0

系统用户前台和管理后台两部分,项目采用前后端分离

        前端技术:vue + elementUI

        服务端技术:springboot + mybatis + redis + mysql

        1.1 项目功能

后台功能:

        1)登录、退出系统、首页

        2)用户信息管理

                (1) 用户信息管理:添加、修改、删除、查询等功能。

        3)车辆信息管理

                (1) 车辆信息管理:添加、修改、删除、查询等功能。

        4)停车位管理

                (1) 停车位管理:添加、修改、删除、查询、安排车位等功能。

        5)入场登记管理

                (1)入场登记管理:添加、修改、删除、查询等功能。

        6)预约管理

                (1) 车位预约管理:添加、修改、删除、查询等功能。

        7)收费规则

                (1) 收费规则:添加、修改、删除、查询等功能。

        8)出场登记管理

                (1) 出场登记管理:添加、修改、删除、查询等功能。

        9)权限管理

                (1)角色信息管理:添加、修改、删除、分配权限等功能。

                (2)资源信息管理:添加、修改、删除等功能。

        注意:不一定非要完全符合开发环境,有稍微的差别也是可以开发的。

         若需要项目完整源码,可以在 CSDN 私信给我,我每天都有查看消息的,感谢大家支持,希望可以帮助到大家!

        2.0 用户登录功能

        用户根据正确的用户名、密码且通过正确的校验码进行登录。

        实现了登录校验,还有用户注册功能:

        用到了 Spring Security 框架来实现登录、校验、验证等功能。 

相关的部分源码:

@RestController
public class SysLoginController
{
    @Autowired
    private SysLoginService loginService;
 
    @Autowired
    private ISysMenuService menuService;
 
    @Autowired
    private SysPermissionService permissionService;
 
    /**
     * 登录方法
     * 
     * @param loginBody 登录信息
     * @return 结果
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody loginBody)
    {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
                loginBody.getUuid());
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }
 
    /**
     * 获取用户信息
     * 
     * @return 用户信息
     */
    @GetMapping("getInfo")
    public AjaxResult getInfo()
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        // 角色集合
        Set<String> roles = permissionService.getRolePermission(user);
        // 权限集合
        Set<String> permissions = permissionService.getMenuPermission(user);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("user", user);
        ajax.put("roles", roles);
        ajax.put("permissions", permissions);
        return ajax;
    }
 
    /**
     * 获取路由信息
     * 
     * @return 路由信息
     */
    @GetMapping("getRouters")
    public AjaxResult getRouters()
    {
        Long userId = SecurityUtils.getUserId();
        List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
        return AjaxResult.success(menuService.buildMenus(menus));
    }
}
    public String login(String username, String password, String code, String uuid)
    {
        // 验证码校验
        validateCaptcha(username, code, uuid);
        // 登录前置校验
        loginPreCheck(username, password);
        // 用户验证
        Authentication authentication = null;
        try
        {
            UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
            AuthenticationContextHolder.setContext(authenticationToken);
            // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
            authentication = authenticationManager.authenticate(authenticationToken);
        }
        catch (Exception e)
        {
            if (e instanceof BadCredentialsException)
            {
                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
                throw new UserPasswordNotMatchException();
            }
            else
            {
                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
                throw new ServiceException(e.getMessage());
            }
        }
        finally
        {
            AuthenticationContextHolder.clearContext();
        }
        AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
        LoginUser loginUser = (LoginUser) authentication.getPrincipal();
        recordLoginInfo(loginUser.getUserId());
        // 生成token
        return tokenService.createToken(loginUser);
    }

        3.0 首页界面

        统计相关车辆的信息,使用柱状图和圆饼图来展示出来,会更加直观。

相关的源码:

<template>
  <div class="statistics-container">
    <!-- <h1>智行无忧停车场</h1> -->
    <div class="data-summary">
      <div class="summary-item">
        <h2>今日车辆总数</h2>
        <p>{{ totalVehicles }}</p>
      </div>
      <div class="summary-item">
        <h2>今日车辆进入数</h2>
        <p>{{ todayEntries }}</p>
      </div>
      <div class="summary-item">
        <h2>今日车辆离开数</h2>
        <p>{{ todayExits }}</p>
      </div>
      <div class="summary-item">
        <h2>当前空闲车位数</h2>
        <p>{{ availableSpots }}</p>
      </div>
    </div>
    <div class="chart-container">
      <div id="vehicleEntryExitChart" style="width: 100%; height: 400px;"></div>
    </div>
    <div class="chart-container">
      <div id="spotUsageChart" style="width: 100%; height: 400px;"></div>
    </div>
  </div>
</template>

<script setup>
import * as echarts from 'echarts';
import { onMounted, ref, computed } from 'vue';

const vehicleEntryExitChart = ref(null);
const spotUsageChart = ref(null);

// 模拟数据
const mockVehicleEntryExitData = {
  dates: ['2024-12-04', '2024-12-05', '2024-12-06'],
  entries: [120, 200, 150],
  exits: [90, 180, 130]
};

const mockSpotUsageData = {
  spotUsages: [
    { value: 335, name: '已使用' },
    { value: 310, name: '未使用' }
  ]
};

const totalVehicles = computed(() => mockVehicleEntryExitData.entries.reduce((a, b) => a + b, 0));
const todayEntries = computed(() => mockVehicleEntryExitData.entries[mockVehicleEntryExitData.entries.length - 1]);
const todayExits = computed(() => mockVehicleEntryExitData.exits[mockVehicleEntryExitData.exits.length - 1]);
const availableSpots = computed(() => mockSpotUsageData.spotUsages.find(item => item.name === '未使用')?.value || 0);

onMounted(() => {
  initVehicleEntryExitChart();
  initSpotUsageChart();
});

function initVehicleEntryExitChart() {
  const chartDom = document.getElementById('vehicleEntryExitChart');
  if (chartDom) {
    const myChart = echarts.init(chartDom);
    const option = {
      title: {
        text: '车辆进出统计'
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      xAxis: {
        type: 'category',
        data: mockVehicleEntryExitData.dates
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          name: '车辆进入',
          data: mockVehicleEntryExitData.entries,
          type: 'bar'
        },
        {
          name: '车辆离开',
          data: mockVehicleEntryExitData.exits,
          type: 'bar'
        }
      ]
    };
    myChart.setOption(option);
  }
}

function initSpotUsageChart() {
  const chartDom = document.getElementById('spotUsageChart');
  if (chartDom) {
    const myChart = echarts.init(chartDom);
    const option = {
      title: {
        text: '车位使用情况'
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        top: '5%',
        left: 'center'
      },
      series: [
        {
          name: '车位使用情况',
          type: 'pie',
          radius: '50%',
          data: mockSpotUsageData.spotUsages,
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    };
    myChart.setOption(option);
  }
}
</script>

        4.0 车辆信息管理功能

        上传图片使用了第三方接口:x-File-Storage 框架。

相关源码:

@RestController
@RequestMapping("/manage/vehicle")
public class VehicleController extends BaseController
{
    @Autowired
    private IVehicleService vehicleService;

    /**
     * 查询车辆信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:vehicle:list')")
    @GetMapping("/list")
    public TableDataInfo list(Vehicle vehicle)
    {
        startPage();
        List<Vehicle> list = vehicleService.selectVehicleList(vehicle);
        return getDataTable(list);
    }

    /**
     * 导出车辆信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:vehicle:export')")
    @Log(title = "车辆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vehicle vehicle)
    {
        List<Vehicle> list = vehicleService.selectVehicleList(vehicle);
        ExcelUtil<Vehicle> util = new ExcelUtil<Vehicle>(Vehicle.class);
        util.exportExcel(response, list, "车辆信息数据");
    }

    /**
     * 获取车辆信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:vehicle:query')")
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return success(vehicleService.selectVehicleByVehicleId(vehicleId));
    }

    /**
     * 新增车辆信息
     */
    @PreAuthorize("@ss.hasPermi('manage:vehicle:add')")
    @Log(title = "车辆信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Vehicle vehicle)
    {
        return toAjax(vehicleService.insertVehicle(vehicle));
    }

    /**
     * 修改车辆信息
     */
    @PreAuthorize("@ss.hasPermi('manage:vehicle:edit')")
    @Log(title = "车辆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Vehicle vehicle)
    {
        return toAjax(vehicleService.updateVehicle(vehicle));
    }

    /**
     * 删除车辆信息
     */
    @PreAuthorize("@ss.hasPermi('manage:vehicle:remove')")
    @Log(title = "车辆信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(vehicleService.deleteVehicleByVehicleIds(vehicleIds));
    }
}

        5.0 停车位管理功能

相关源码:

@RestController
@RequestMapping("/manage/spot")
public class ParkingSpotController extends BaseController
{
    @Autowired
    private IParkingSpotService parkingSpotService;

    /**
     * 查询停车位列表
     */
    @PreAuthorize("@ss.hasPermi('manage:spot:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkingSpot parkingSpot)
    {
        startPage();
        List<ParkingSpot> list = parkingSpotService.selectParkingSpotList(parkingSpot);
        return getDataTable(list);
    }

    /**
     * 导出停车位列表
     */
    @PreAuthorize("@ss.hasPermi('manage:spot:export')")
    @Log(title = "停车位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingSpot parkingSpot)
    {
        List<ParkingSpot> list = parkingSpotService.selectParkingSpotList(parkingSpot);
        ExcelUtil<ParkingSpot> util = new ExcelUtil<ParkingSpot>(ParkingSpot.class);
        util.exportExcel(response, list, "停车位数据");
    }

    /**
     * 获取停车位详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:spot:query')")
    @GetMapping(value = "/{spotId}")
    public AjaxResult getInfo(@PathVariable("spotId") Long spotId)
    {
        return success(parkingSpotService.selectParkingSpotBySpotId(spotId));
    }

    /**
     * 新增停车位
     */
    @PreAuthorize("@ss.hasPermi('manage:spot:add')")
    @Log(title = "停车位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingSpot parkingSpot)
    {
        return toAjax(parkingSpotService.insertParkingSpot(parkingSpot));
    }

    /**
     * 修改停车位
     */
    @PreAuthorize("@ss.hasPermi('manage:spot:edit')")
    @Log(title = "停车位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingSpot parkingSpot)
    {
        return toAjax(parkingSpotService.updateParkingSpot(parkingSpot));
    }

    /**
     * 删除停车位
     */
    @PreAuthorize("@ss.hasPermi('manage:spot:remove')")
    @Log(title = "停车位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{spotIds}")
    public AjaxResult remove(@PathVariable Long[] spotIds)
    {
        return toAjax(parkingSpotService.deleteParkingSpotBySpotIds(spotIds));
    }
}

        6.0 入场登记管理功能

相关源码:

@RestController
@RequestMapping("/manage/record")
public class EntryRecordController extends BaseController
{
    @Autowired
    private IEntryRecordService entryRecordService;

    /**
     * 查询入场记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(EntryRecord entryRecord)
    {
        startPage();
        List<EntryRecord> list = entryRecordService.selectEntryRecordList(entryRecord);
        return getDataTable(list);
    }

    /**
     * 导出入场记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:record:export')")
    @Log(title = "入场记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EntryRecord entryRecord)
    {
        List<EntryRecord> list = entryRecordService.selectEntryRecordList(entryRecord);
        ExcelUtil<EntryRecord> util = new ExcelUtil<EntryRecord>(EntryRecord.class);
        util.exportExcel(response, list, "入场记录数据");
    }

    /**
     * 获取入场记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:record:query')")
    @GetMapping(value = "/{entryId}")
    public AjaxResult getInfo(@PathVariable("entryId") Long entryId)
    {
        return success(entryRecordService.selectEntryRecordByEntryId(entryId));
    }

    /**
     * 新增入场记录
     */
    @PreAuthorize("@ss.hasPermi('manage:record:add')")
    @Log(title = "入场记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EntryRecord entryRecord)
    {
        return toAjax(entryRecordService.insertEntryRecord(entryRecord));
    }

    /**
     * 修改入场记录
     */
    @PreAuthorize("@ss.hasPermi('manage:record:edit')")
    @Log(title = "入场记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EntryRecord entryRecord)
    {
        return toAjax(entryRecordService.updateEntryRecord(entryRecord));
    }

    /**
     * 删除入场记录
     */
    @PreAuthorize("@ss.hasPermi('manage:record:remove')")
    @Log(title = "入场记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{entryIds}")
    public AjaxResult remove(@PathVariable Long[] entryIds)
    {
        return toAjax(entryRecordService.deleteEntryRecordByEntryIds(entryIds));
    }
}

        7.0 预约管理功能

相关源码:

@RestController
@RequestMapping("/manage/reservation")
public class ReservationController extends BaseController
{
    @Autowired
    private IReservationService reservationService;

    /**
     * 查询预约记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:reservation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Reservation reservation)
    {
        startPage();
        List<Reservation> list = reservationService.selectReservationList(reservation);
        return getDataTable(list);
    }

    /**
     * 导出预约记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:reservation:export')")
    @Log(title = "预约记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Reservation reservation)
    {
        List<Reservation> list = reservationService.selectReservationList(reservation);
        ExcelUtil<Reservation> util = new ExcelUtil<Reservation>(Reservation.class);
        util.exportExcel(response, list, "预约记录数据");
    }

    /**
     * 获取预约记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:reservation:query')")
    @GetMapping(value = "/{reservationId}")
    public AjaxResult getInfo(@PathVariable("reservationId") Long reservationId)
    {
        return success(reservationService.selectReservationByReservationId(reservationId));
    }

    /**
     * 新增预约记录
     */
    @PreAuthorize("@ss.hasPermi('manage:reservation:add')")
    @Log(title = "预约记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Reservation reservation)
    {
        return toAjax(reservationService.insertReservation(reservation));
    }

    /**
     * 修改预约记录
     */
    @PreAuthorize("@ss.hasPermi('manage:reservation:edit')")
    @Log(title = "预约记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Reservation reservation)
    {
        return toAjax(reservationService.updateReservation(reservation));
    }

    /**
     * 删除预约记录
     */
    @PreAuthorize("@ss.hasPermi('manage:reservation:remove')")
    @Log(title = "预约记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reservationIds}")
    public AjaxResult remove(@PathVariable Long[] reservationIds)
    {
        return toAjax(reservationService.deleteReservationByReservationIds(reservationIds));
    }
}

        8.0 收费规则功能

相关源码:

@RestController
@RequestMapping("/manage/rule")
public class FeeRuleController extends BaseController
{
    @Autowired
    private IFeeRuleService feeRuleService;

    /**
     * 查询收费规则列表
     */
    @PreAuthorize("@ss.hasPermi('manage:rule:list')")
    @GetMapping("/list")
    public TableDataInfo list(FeeRule feeRule)
    {
        startPage();
        List<FeeRule> list = feeRuleService.selectFeeRuleList(feeRule);
        return getDataTable(list);
    }

    /**
     * 导出收费规则列表
     */
    @PreAuthorize("@ss.hasPermi('manage:rule:export')")
    @Log(title = "收费规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeeRule feeRule)
    {
        List<FeeRule> list = feeRuleService.selectFeeRuleList(feeRule);
        ExcelUtil<FeeRule> util = new ExcelUtil<FeeRule>(FeeRule.class);
        util.exportExcel(response, list, "收费规则数据");
    }

    /**
     * 获取收费规则详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:rule:query')")
    @GetMapping(value = "/{ruleId}")
    public AjaxResult getInfo(@PathVariable("ruleId") Long ruleId)
    {
        return success(feeRuleService.selectFeeRuleByRuleId(ruleId));
    }

    /**
     * 新增收费规则
     */
    @PreAuthorize("@ss.hasPermi('manage:rule:add')")
    @Log(title = "收费规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeeRule feeRule)
    {
        return toAjax(feeRuleService.insertFeeRule(feeRule));
    }

    /**
     * 修改收费规则
     */
    @PreAuthorize("@ss.hasPermi('manage:rule:edit')")
    @Log(title = "收费规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeeRule feeRule)
    {
        return toAjax(feeRuleService.updateFeeRule(feeRule));
    }

    /**
     * 删除收费规则
     */
    @PreAuthorize("@ss.hasPermi('manage:rule:remove')")
    @Log(title = "收费规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ruleIds}")
    public AjaxResult remove(@PathVariable Long[] ruleIds)
    {
        return toAjax(feeRuleService.deleteFeeRuleByRuleIds(ruleIds));
    }
}

        9.0 出场登记管理功能

相关源码:

@RestController
@RequestMapping("/manage/exitRecord")
public class ExitRecordController extends BaseController
{
    @Autowired
    private IExitRecordService exitRecordService;

    /**
     * 查询出场记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:exitRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExitRecord exitRecord)
    {
        startPage();
        List<ExitRecord> list = exitRecordService.selectExitRecordList(exitRecord);
        return getDataTable(list);
    }

    /**
     * 导出出场记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:exitRecord:export')")
    @Log(title = "出场记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExitRecord exitRecord)
    {
        List<ExitRecord> list = exitRecordService.selectExitRecordList(exitRecord);
        ExcelUtil<ExitRecord> util = new ExcelUtil<ExitRecord>(ExitRecord.class);
        util.exportExcel(response, list, "出场记录数据");
    }

    /**
     * 获取出场记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:exitRecord:query')")
    @GetMapping(value = "/{exitId}")
    public AjaxResult getInfo(@PathVariable("exitId") Long exitId)
    {
        return success(exitRecordService.selectExitRecordByExitId(exitId));
    }

    /**
     * 新增出场记录
     */
    @PreAuthorize("@ss.hasPermi('manage:exitRecord:add')")
    @Log(title = "出场记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExitRecord exitRecord)
    {
        return toAjax(exitRecordService.insertExitRecord(exitRecord));
    }

    /**
     * 修改出场记录
     */
    @PreAuthorize("@ss.hasPermi('manage:exitRecord:edit')")
    @Log(title = "出场记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExitRecord exitRecord)
    {
        return toAjax(exitRecordService.updateExitRecord(exitRecord));
    }

    /**
     * 删除出场记录
     */
    @PreAuthorize("@ss.hasPermi('manage:exitRecord:remove')")
    @Log(title = "出场记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{exitIds}")
    public AjaxResult remove(@PathVariable Long[] exitIds)
    {
        return toAjax(exitRecordService.deleteExitRecordByExitIds(exitIds));
    }
}

        10.0 用户信息管理功能

相关源码:

@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController
{
    @Autowired
    private ISysUserService userService;

    @Autowired
    private ISysRoleService roleService;

    @Autowired
    private ISysDeptService deptService;

    @Autowired
    private ISysPostService postService;

    /**
     * 获取用户列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUser user)
    {
        startPage();
        List<SysUser> list = userService.selectUserList(user);
        return getDataTable(list);
    }

    @Log(title = "用户管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('system:user:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUser user)
    {
        List<SysUser> list = userService.selectUserList(user);
        ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
        util.exportExcel(response, list, "用户数据");
    }

    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('system:user:import')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
        List<SysUser> userList = util.importExcel(file.getInputStream());
        String operName = getUsername();
        String message = userService.importUser(userList, updateSupport, operName);
        return success(message);
    }

    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response)
    {
        ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
        util.importTemplateExcel(response, "用户数据");
    }

    /**
     * 根据用户编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping(value = { "/", "/{userId}" })
    public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
    {
        userService.checkUserDataScope(userId);
        AjaxResult ajax = AjaxResult.success();
        List<SysRole> roles = roleService.selectRoleAll();
        ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
        ajax.put("posts", postService.selectPostAll());
        if (StringUtils.isNotNull(userId))
        {
            SysUser sysUser = userService.selectUserById(userId);
            ajax.put(AjaxResult.DATA_TAG, sysUser);
            ajax.put("postIds", postService.selectPostListByUserId(userId));
            ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
        }
        return ajax;
    }

    /**
     * 新增用户
     */
    @PreAuthorize("@ss.hasPermi('system:user:add')")
    @Log(title = "用户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysUser user)
    {
        if (!userService.checkUserNameUnique(user))
        {
            return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
        }
        else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
        {
            return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
        }
        else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
        {
            return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
        }
        user.setCreateBy(getUsername());
        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
        return toAjax(userService.insertUser(user));
    }

    /**
     * 修改用户
     */
    @PreAuthorize("@ss.hasPermi('system:user:edit')")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysUser user)
    {
        userService.checkUserAllowed(user);
        userService.checkUserDataScope(user.getUserId());
        if (!userService.checkUserNameUnique(user))
        {
            return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
        }
        else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
        {
            return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
        }
        else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
        {
            return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
        }
        user.setUpdateBy(getUsername());
        return toAjax(userService.updateUser(user));
    }

    /**
     * 删除用户
     */
    @PreAuthorize("@ss.hasPermi('system:user:remove')")
    @Log(title = "用户管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        if (ArrayUtils.contains(userIds, getUserId()))
        {
            return error("当前用户不能删除");
        }
        return toAjax(userService.deleteUserByIds(userIds));
    }

    /**
     * 重置密码
     */
    @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @PutMapping("/resetPwd")
    public AjaxResult resetPwd(@RequestBody SysUser user)
    {
        userService.checkUserAllowed(user);
        userService.checkUserDataScope(user.getUserId());
        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
        user.setUpdateBy(getUsername());
        return toAjax(userService.resetPwd(user));
    }

    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:user:edit')")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody SysUser user)
    {
        userService.checkUserAllowed(user);
        userService.checkUserDataScope(user.getUserId());
        user.setUpdateBy(getUsername());
        return toAjax(userService.updateUserStatus(user));
    }

    /**
     * 根据用户编号获取授权角色
     */
    @PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping("/authRole/{userId}")
    public AjaxResult authRole(@PathVariable("userId") Long userId)
    {
        AjaxResult ajax = AjaxResult.success();
        SysUser user = userService.selectUserById(userId);
        List<SysRole> roles = roleService.selectRolesByUserId(userId);
        ajax.put("user", user);
        ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
        return ajax;
    }

    /**
     * 用户授权角色
     */
    @PreAuthorize("@ss.hasPermi('system:user:edit')")
    @Log(title = "用户管理", businessType = BusinessType.GRANT)
    @PutMapping("/authRole")
    public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
    {
        userService.checkUserDataScope(userId);
        userService.insertUserAuth(userId, roleIds);
        return success();
    }

    /**
     * 获取部门树列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/deptTree")
    public AjaxResult deptTree(SysDept dept)
    {
        return success(deptService.selectDeptTreeList(dept));
    }
}

        11.0 SQL 数据库设计

CREATE TABLE vehicle (
    vehicle_id INT AUTO_INCREMENT,
    license_plate VARCHAR(20) NOT NULL UNIQUE COMMENT '车牌号',
    vehicle_type INT COMMENT '车型: 1-轿车, 2-SUV, 3-MPV',
    user_id INT NOT NULL COMMENT '用户ID (逻辑外键,关联到User表)',
    contact_info VARCHAR(100) COMMENT '联系方式',
    PRIMARY KEY (vehicle_id)
) COMMENT='车辆信息表';

INSERT INTO vehicle (license_plate, vehicle_type, user_id, contact_info) VALUES
('A123BC', 1, 1, 'john.doe@example.com'),  -- 用户ID 1 的轿车
('B456DE', 2, 1, 'john.doe@example.com'),  -- 用户ID 1 的SUV
('C789FG', 3, 2, 'jane.smith@example.com'),  -- 用户ID 2 的MPV
('D012HI', 1, 2, 'jane.smith@example.com');  -- 用户ID 2 的轿车


CREATE TABLE parking_spot (
    spot_id INT AUTO_INCREMENT,
    spot_status INT DEFAULT 1 COMMENT '车位状态: 1-空闲, 2-占用, 3-预约',
    location VARCHAR(100) COMMENT '车位位置',
    PRIMARY KEY (spot_id)
) COMMENT='停车位表';


CREATE TABLE vehicle (
    vehicle_id INT AUTO_INCREMENT,
    license_plate VARCHAR(20) NOT NULL UNIQUE COMMENT '车牌号',
    vehicle_type INT COMMENT '车型: 1-轿车, 2-SUV, 3-MPV',
    user_id INT NOT NULL COMMENT '用户ID (逻辑外键,关联到User表)',
    contact_info VARCHAR(100) COMMENT '联系方式',
    vehicle_image_path VARCHAR(255) COMMENT '车辆图片路径或URL',
    PRIMARY KEY (vehicle_id)
) COMMENT='车辆信息表';


INSERT INTO vehicle (license_plate, vehicle_type, user_id, contact_info, vehicle_image_path) VALUES
('ABC123', 1, 1, 'John Doe, 123-456-7890', '/images/vehicles/abc123.jpg'),
('XYZ456', 2, 1, 'Jane Smith, 987-654-3210', '/images/vehicles/xyz456.jpg'),
('JKL789', 3, 2, 'Alice Johnson, 555-555-5555', '/images/vehicles/jkl789.jpg'),
('MNO012', 1, 2, 'Bob Brown, 111-222-3333', '/images/vehicles/mno012.jpg');


INSERT INTO parking_spot (spot_status, location) VALUES
(1, 'A座 - 一层 - 车位 1'),
(1, 'A座 - 一层 - 车位 2'),
(2, 'A座 - 一层 - 车位 3'),
(1, 'A座 - 一层 - 车位 4'),
(3, 'B座 - 一层 - 车位 1'),
(1, 'B座 - 一层 - 车位 2'),
(2, 'B座 - 一层 - 车位 3'),
(1, 'C座 - 一层 - 车位 1'),
(3, 'C座 - 一层 - 车位 2'),
(2, 'C座 - 一层 - 车位 3');


CREATE TABLE entry_record (
    entry_id INT AUTO_INCREMENT comment '自增ID',
    vehicle_id INT NOT NULL COMMENT '车辆ID (逻辑外键,关联到vehicle表)',
    entry_time DATETIME COMMENT '入场时间',
    spot_id INT COMMENT '分配的车位ID (逻辑外键,关联到parking_spot表)',
    is_reserved INT DEFAULT 1 COMMENT '1表示预约入场、2表示非预约入场',
    PRIMARY KEY (entry_id)
) COMMENT='入场记录表';


CREATE TABLE fee_rule (
    rule_id INT AUTO_INCREMENT,
    vehicle_type INT COMMENT '车型: 1-轿车, 2-SUV, 3-MPV',
    base_fee DECIMAL(8,2) COMMENT '基础费用',
    additional_fee_per_hour DECIMAL(8,2) COMMENT '每小时额外费用',
    PRIMARY KEY (rule_id)
) COMMENT='收费规则表';


CREATE TABLE reservation (
    reservation_id INT AUTO_INCREMENT comment '预约表ID',
    vehicle_id INT NOT NULL COMMENT '车辆ID (逻辑外键,关联到vehicle表)',
    spot_id INT NOT NULL COMMENT '车位ID (逻辑外键,关联到parking_spot表)',
    start_time DATETIME NOT NULL COMMENT '预约开始时间',
    end_time DATETIME NOT NULL COMMENT '预约结束时间',
    status INT DEFAULT 1 COMMENT '预约状态: 1-已确认, 2-已取消',
    PRIMARY KEY (reservation_id)
) COMMENT='预约记录表';


INSERT INTO fee_rule (vehicle_type, base_fee, additional_fee_per_hour) VALUES
(1, 50.00, 10.00),  -- 轿车, 基础费用50.00元, 每小时额外费用10.00元
(2, 80.00, 15.00),  -- SUV, 基础费用80.00元, 每小时额外费用15.00元
(3, 100.00, 20.00); -- MPV, 基础费用100.00元, 每小时额外费用20.00元

CREATE TABLE exit_record (
    exit_id INT AUTO_INCREMENT COMMENT '出场ID',
    vehicle_id INT NOT NULL COMMENT '车辆ID (逻辑外键,关联到vehicle表)',
    exit_time DATETIME COMMENT '出场时间',
    fee_charged DECIMAL(8,2) COMMENT '收费金额',
    is_reserved BOOLEAN DEFAULT FALSE COMMENT '是否基于预约入场',
    PRIMARY KEY (exit_id)
) COMMENT='出场记录表';

         若需要项目完整源码,可以在 CSDN 私信给我,我每天都有查看消息的,感谢大家支持,希望可以帮助到大家!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐