소스 검색

停车卡

guoshuai 1 개월 전
부모
커밋
6dfc78b57d

+ 116 - 0
src/main/java/com/qmrb/system/controller/CarParkStoredCardController.java

@@ -0,0 +1,116 @@
+package com.qmrb.system.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.qmrb.system.common.exception.BusinessException;
+import org.springdoc.core.annotations.ParameterObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmrb.system.common.result.PageResult;
+import com.qmrb.system.common.result.Result;
+import com.qmrb.system.common.result.ResultCode;
+import com.qmrb.system.framework.resubmit.Resubmit;
+import com.qmrb.system.service.ICarParkStoredCardService;
+import com.qmrb.system.pojo.form.CarParkStoredCardForm;
+import com.qmrb.system.pojo.vo.CarParkStoredCardVO;
+import com.qmrb.system.pojo.query.CarParkStoredCardQuery;
+import com.qmrb.system.pojo.vo.Option;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.web.bind.annotation.RestController;
+import jakarta.validation.Valid;
+
+/**
+ * <p>
+ * 停车储值卡 前端控制器
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Tag(name = "停车储值卡接口")
+@RestController
+@RequestMapping("/api/v1/park_stored_card")
+@CrossOrigin
+public class CarParkStoredCardController{
+
+    @Autowired
+    private ICarParkStoredCardService carParkStoredCardService;
+
+	@Operation(summary = "停车储值卡分页列表", security = {@SecurityRequirement(name = "Authorization")})
+    @GetMapping("/page")
+    public PageResult<CarParkStoredCardVO> getPage(
+            @ParameterObject CarParkStoredCardQuery queryParams
+    ) {
+        if(queryParams.getUserId() == null){
+            throw new BusinessException("用户id不能为空");
+        }
+        Page<CarParkStoredCardVO> result = carParkStoredCardService.getPage(queryParams);
+        return PageResult.success(result);
+    }
+    
+    @Operation(summary = "新增停车储值卡", security = {@SecurityRequirement(name = "Authorization")})
+    @PostMapping
+    @PreAuthorize("@ss.hasPerm('park_stored_card:add')")
+    @Resubmit
+    public Result<CarParkStoredCardForm> saveForm(
+            @RequestBody @Valid CarParkStoredCardForm form
+    ) {
+        CarParkStoredCardForm result = carParkStoredCardService.saveForm(form);
+        return Result.success(result);
+    }
+
+    @Operation(summary = "停车储值卡表单数据", security = {@SecurityRequirement(name = "Authorization")})
+    @GetMapping("/{id}/form")
+    public Result<CarParkStoredCardForm> getForm(
+            @Parameter(description = "停车储值卡ID") @PathVariable Long id
+    ) {
+    	CarParkStoredCardForm formData = carParkStoredCardService.getFormData(id);
+        return Result.success(formData);
+    }
+
+    @Operation(summary = "修改停车储值卡", security = {@SecurityRequirement(name = "Authorization")})
+    @PutMapping(value = "/{id}")
+    @PreAuthorize("@ss.hasPerm('park_stored_card:edit')")
+    public Result<?> updateForm(
+            @Parameter(description = "停车储值卡ID") @PathVariable Long id,
+            @RequestBody @Validated CarParkStoredCardForm form) {
+    	
+        boolean result = carParkStoredCardService.updateForm(id,form);
+        return Result.judge(result);
+    }
+
+    @Operation(summary = "删除停车储值卡", security = {@SecurityRequirement(name = "Authorization")})
+    @DeleteMapping("/{ids}")
+    @PreAuthorize("@ss.hasPerm('park_stored_card:delete')")
+    public Result<?> deleteUsers(
+            @Parameter(description = "停车储值卡ID,多个以英文逗号(,)分割") @PathVariable String ids
+    ) {
+    	if(StrUtil.isBlank(ids)) {
+    		 return Result.failed(ResultCode.PARAM_ERROR, "删除的停车储值卡数据为空");
+    	}
+        // 逻辑删除
+        List<Long> idList = Arrays.asList(ids.split(",")).stream()
+                .map(idStr -> Long.parseLong(idStr)).collect(Collectors.toList());
+        boolean result = carParkStoredCardService.removeByIds(idList);
+        return Result.judge(result);
+    }
+    
+
+}

+ 29 - 0
src/main/java/com/qmrb/system/converter/CarParkStoredCardConverter.java

@@ -0,0 +1,29 @@
+package com.qmrb.system.converter;
+
+import org.mapstruct.InheritInverseConfiguration;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmrb.system.pojo.entity.CarParkStoredCard;
+import com.qmrb.system.pojo.form.CarParkStoredCardForm;
+import com.qmrb.system.pojo.vo.CarParkStoredCardVO;
+
+/**
+ * 停车储值卡数据项对象转换器
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface CarParkStoredCardConverter {
+
+    Page<CarParkStoredCardVO> entity2Page(Page<CarParkStoredCard> page);
+
+    CarParkStoredCardForm entity2Form(CarParkStoredCard entity);
+
+    @InheritInverseConfiguration(name="entity2Form")
+    CarParkStoredCard form2Entity(CarParkStoredCardForm form);
+    
+    CarParkStoredCardVO entity2Vo(CarParkStoredCard entity);
+}

+ 18 - 0
src/main/java/com/qmrb/system/mapper/CarParkStoredCardMapper.java

@@ -0,0 +1,18 @@
+package com.qmrb.system.mapper;
+
+import com.qmrb.system.pojo.entity.CarParkStoredCard;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 停车储值卡 Mapper 接口
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Mapper
+public interface CarParkStoredCardMapper extends BaseMapper<CarParkStoredCard> {
+
+}

+ 86 - 0
src/main/java/com/qmrb/system/pojo/entity/CarParkStoredCard.java

@@ -0,0 +1,86 @@
+package com.qmrb.system.pojo.entity;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.qmrb.system.common.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 停车储值卡
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Data
+@EqualsAndHashCode()
+@TableName("car_park_stored_card")
+public class CarParkStoredCard extends BaseEntity{
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 停车场id
+     */
+    @TableField("car_park_id")
+    private Long carParkId;
+
+    /**
+     * 停车场名
+     */
+    @TableField("car_park_name")
+    private String carParkName;
+
+    /**
+     * 车牌号
+     */
+    @TableField("plate_number")
+    private String plateNumber;
+
+    /**
+     * 所属者
+     */
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 开始时间
+     */
+    @TableField("start_time")
+    private LocalDateTime startTime;
+
+    /**
+     * 过期时间
+     */
+    @TableField("end_time")
+    private LocalDateTime endTime;
+
+    /**
+     * 金额余额
+     */
+    @TableField("amount_balance")
+    private BigDecimal amountBalance;
+
+    /**
+     * 手机号
+     */
+    @TableField("phone")
+    private String phone;
+
+    /**
+     * 月卡状态0停用1启用
+     */
+    @TableField("status")
+    private String status;
+    
+    
+}

+ 68 - 0
src/main/java/com/qmrb/system/pojo/form/CarParkStoredCardForm.java

@@ -0,0 +1,68 @@
+package com.qmrb.system.pojo.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 停车储值卡表单
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Data
+public class CarParkStoredCardForm {
+
+    private Long id;
+    /**
+     * 停车场id
+     */
+	@Schema(description = "停车场id",type="Long")
+    private Long carParkId;
+    /**
+     * 停车场名
+     */
+	@Schema(description = "停车场名",type="String")
+    private String carParkName;
+    /**
+     * 车牌号
+     */
+	@Schema(description = "车牌号",type="String")
+    private String plateNumber;
+    /**
+     * 所属者
+     */
+	@Schema(description = "所属者",type="Long")
+    private Long userId;
+    /**
+     * 开始时间
+     */
+	@Schema(description = "开始时间",type="LocalDateTime")
+    private LocalDateTime startTime;
+    /**
+     * 过期时间
+     */
+	@Schema(description = "过期时间",type="LocalDateTime")
+    private LocalDateTime endTime;
+    /**
+     * 金额余额
+     */
+	@Schema(description = "金额余额",type="BigDecimal")
+    private BigDecimal amountBalance;
+    /**
+     * 手机号
+     */
+	@Schema(description = "手机号",type="String")
+    private String phone;
+    /**
+     * 月卡状态0停用1启用
+     */
+	@Schema(description = "月卡状态0停用1启用",type="String")
+    private String status;
+
+
+}

+ 74 - 0
src/main/java/com/qmrb/system/pojo/query/CarParkStoredCardQuery.java

@@ -0,0 +1,74 @@
+package com.qmrb.system.pojo.query;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import com.qmrb.system.common.base.BasePageQuery;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 停车储值卡查询对象
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CarParkStoredCardQuery extends BasePageQuery{
+
+ 	@Schema(description="关键字")
+    private String keywords;
+
+    private Long id;
+    /**
+     * 停车场id
+     */
+	@Schema(description = "停车场id",type="Long")
+    private Long carParkId;
+    /**
+     * 停车场名
+     */
+	@Schema(description = "停车场名",type="String")
+    private String carParkName;
+    /**
+     * 车牌号
+     */
+	@Schema(description = "车牌号",type="String")
+    private String plateNumber;
+    /**
+     * 所属者
+     */
+	@Schema(description = "所属者",type="Long")
+    private Long userId;
+    /**
+     * 开始时间
+     */
+	@Schema(description = "开始时间",type="LocalDateTime")
+    private LocalDateTime startTime;
+    /**
+     * 过期时间
+     */
+	@Schema(description = "过期时间",type="Long")
+    private LocalDateTime endTime;
+    /**
+     * 金额余额
+     */
+	@Schema(description = "金额余额",type="BigDecimal")
+    private BigDecimal amountBalance;
+    /**
+     * 手机号
+     */
+	@Schema(description = "手机号",type="String")
+    private String phone;
+    /**
+     * 月卡状态0停用1启用
+     */
+	@Schema(description = "月卡状态0停用1启用",type="String")
+    private String status;
+
+
+}

+ 71 - 0
src/main/java/com/qmrb/system/pojo/vo/CarParkStoredCardVO.java

@@ -0,0 +1,71 @@
+package com.qmrb.system.pojo.vo;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * <p>
+ * 停车储值卡视图对象
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Data
+public class CarParkStoredCardVO {
+
+    private Long id;
+    /**
+     * 停车场id
+     */
+	@Schema(description = "停车场id",type="Long")
+    private Long carParkId;
+    /**
+     * 停车场名
+     */
+	@Schema(description = "停车场名",type="String")
+    private String carParkName;
+    /**
+     * 车牌号
+     */
+	@Schema(description = "车牌号",type="String")
+    private String plateNumber;
+    /**
+     * 所属者
+     */
+	@Schema(description = "所属者",type="Long")
+    private Long userId;
+    /**
+     * 开始时间
+     */
+	@Schema(description = "开始时间",type="LocalDateTime")
+    private LocalDateTime startTime;
+    /**
+     * 过期时间
+     */
+	@Schema(description = "过期时间",type="LocalDateTime")
+    private LocalDateTime endTime;
+    /**
+     * 金额余额
+     */
+	@Schema(description = "金额余额",type="BigDecimal")
+    private BigDecimal amountBalance;
+    /**
+     * 手机号
+     */
+	@Schema(description = "手机号",type="String")
+    private String phone;
+    /**
+     * 月卡状态0停用1启用
+     */
+	@Schema(description = "月卡状态0停用1启用",type="String")
+    private String status;
+
+	@Schema(description = "子分类")
+    private List<CarParkStoredCardVO> children;
+
+
+}

+ 41 - 0
src/main/java/com/qmrb/system/service/ICarParkStoredCardService.java

@@ -0,0 +1,41 @@
+package com.qmrb.system.service;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmrb.system.pojo.entity.CarParkStoredCard;
+import com.qmrb.system.pojo.form.CarParkStoredCardForm;
+import com.qmrb.system.pojo.vo.CarParkStoredCardVO;
+import com.qmrb.system.pojo.query.CarParkStoredCardQuery;
+import com.qmrb.system.pojo.vo.Option;
+import com.baomidou.mybatisplus.extension.service.IService;
+import jakarta.validation.Valid;
+
+/**
+ * <p>
+ * 停车储值卡 服务类
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+public interface ICarParkStoredCardService extends IService<CarParkStoredCard> {
+	
+	/**分页查询
+	 * */
+	public Page<CarParkStoredCardVO> getPage(CarParkStoredCardQuery queryParams);
+
+	/**
+	 * 保存表单
+	 * */
+	public CarParkStoredCardForm saveForm(@Valid CarParkStoredCardForm form);
+	
+	/**更新
+	 * */
+	public boolean updateForm(Long id, CarParkStoredCardForm form);
+	
+	/**获取表单数据
+	 * */
+	public CarParkStoredCardForm getFormData(Long id);
+	
+}

+ 102 - 0
src/main/java/com/qmrb/system/service/impl/CarParkStoredCardServiceImpl.java

@@ -0,0 +1,102 @@
+package com.qmrb.system.service.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.qmrb.system.common.enums.StatusEnum;
+import com.qmrb.system.pojo.vo.Option;
+import com.qmrb.system.converter.CarParkStoredCardConverter;
+import com.qmrb.system.pojo.entity.CarParkStoredCard;
+import com.qmrb.system.pojo.form.CarParkStoredCardForm;
+import com.qmrb.system.pojo.vo.CarParkStoredCardVO;
+import com.qmrb.system.pojo.query.CarParkStoredCardQuery;
+import com.qmrb.system.mapper.CarParkStoredCardMapper;
+import com.qmrb.system.service.ICarParkStoredCardService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.lang.Assert;
+import jakarta.validation.Valid;
+
+/**
+ * <p>
+ * 停车储值卡 服务实现类
+ * </p>
+ *
+ * @author gs
+ * @since 2025-02-24
+ */
+@Service
+public class CarParkStoredCardServiceImpl extends ServiceImpl<CarParkStoredCardMapper, CarParkStoredCard> implements ICarParkStoredCardService {
+
+	@Autowired
+	private CarParkStoredCardConverter converter;
+
+	/**分页查询
+	 * */
+	@Override
+	public Page<CarParkStoredCardVO> getPage(CarParkStoredCardQuery queryParams) {
+		// 查询参数
+        int pageNum = queryParams.getPageNum();
+        int pageSize = queryParams.getPageSize();
+        //String keywords = queryParams.getKeywords();
+
+        // 查询数据
+        Page<CarParkStoredCard> dictItemPage = this.page(
+                new Page<>(pageNum, pageSize),
+                new LambdaQueryWrapper<CarParkStoredCard>()
+        );
+
+        // 实体转换
+        Page<CarParkStoredCardVO> pageResult = converter.entity2Page(dictItemPage);
+        return pageResult;
+	}
+
+	/**
+	 * 保存表单
+	 * */
+	@Override
+	public CarParkStoredCardForm saveForm(@Valid CarParkStoredCardForm form) {
+		// 实体对象转换 form->entity
+		CarParkStoredCard entity = converter.form2Entity(form);
+        // 持久化
+        this.save(entity);
+        CarParkStoredCardForm result = converter.entity2Form(entity);
+        return result;
+	}
+
+	/**更新
+	 * */
+	@Override
+	public boolean updateForm(Long id, CarParkStoredCardForm form) {
+		CarParkStoredCard entity = converter.form2Entity(form);
+		entity.setId(id);
+        boolean result = this.updateById(entity);
+        return result;
+	}
+
+	/**获取表单数据
+	 * */
+	@Override
+	public CarParkStoredCardForm getFormData(Long id) {
+		// 获取entity
+		CarParkStoredCard entity = this.getById(id);
+        Assert.isTrue(entity != null, "停车储值卡不存在");
+
+        // 实体转换
+        CarParkStoredCardForm form = converter.entity2Form(entity);
+        return form;
+	}
+	
+	
+	
+	
+}

+ 5 - 0
src/main/resources/mapper/CarParkStoredCardMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmrb.system.mapper.CarParkStoredCardMapper">
+
+</mapper>