guoshuai 3 semanas atrás
pai
commit
8e588dda00

+ 32 - 0
src/main/java/com/qmrb/system/controller/AuthController.java

@@ -16,9 +16,11 @@ import com.qmrb.system.framework.security.CaConstants;
 import com.qmrb.system.pojo.dto.SoapReturnDTO;
 import com.qmrb.system.pojo.dto.SoapTemplateDTO;
 import com.qmrb.system.pojo.form.UserForm;
+import com.qmrb.system.pojo.query.AuthLogin;
 import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
 import org.checkerframework.common.value.qual.StringVal;
+import org.springdoc.core.annotations.ParameterObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -125,6 +127,36 @@ public class AuthController {
             return Result.success(loginResult);
         }
     }
+    
+    
+    @Operation(summary = "客商登录")
+    @PostMapping("/loginByMerchants")
+    public Result<LoginResult> loginByMerchants(
+            @RequestBody AuthLogin authLogin) throws Exception {
+        //超级管理员登录
+        
+        SysUser doctor = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,authLogin.getAccount())
+                .eq(SysUser::getUserType,authLogin.getUserType()).eq(SysUser::getStatus,1));
+        if (doctor == null) {
+            return Result.failed("用户名不存在");
+        }
+
+        List<SimpleGrantedAuthority> roleList = userService.getUserAuthInfo(doctor.getUsername()).getRoles()
+                .stream().map(role -> new SimpleGrantedAuthority("ROLE_" + role)).toList();
+        UsernamePasswordAuthenticationToken authenticationToken =
+                new UsernamePasswordAuthenticationToken(authLogin.getAccount(), authLogin.getPassword(),
+                        roleList);
+        UserAuthInfo userAuthInfo = userService.getUserAuthInfo(doctor.getUsername());
+        SysUserDetails sysUserDetails = new SysUserDetails(userAuthInfo);
+        authenticationToken.setDetails(sysUserDetails);
+        SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+        String accessToken = jwtTokenManager.createToken(authenticationToken);
+        LoginResult loginResult = LoginResult.builder()
+                .tokenType("Bearer")
+                .accessToken(accessToken)
+                .build();
+        return Result.success(loginResult);
+    }
 
     @SuppressWarnings("unchecked")
     @Operation(summary = "注销", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})

+ 5 - 0
src/main/java/com/qmrb/system/controller/BarnRecordController.java

@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.qmrb.system.framework.security.util.SecurityUtils;
 import com.qmrb.system.pojo.entity.BarnRecord;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.rocketmq.client.exception.MQBrokerException;
@@ -88,6 +89,10 @@ public class BarnRecordController {
     public PageResult<BarnRecordVO> listByPlateNumber(
             @ParameterObject BarnRecordQuery queryParams
     ) {
+        if(SecurityUtils.getUserId() == null){
+            return PageResult.success(null);
+        }
+        queryParams.setUserId(SecurityUtils.getUserId());
         // Assert.isTrue(StringUtils.isNotBlank(queryParams.getCarNumber()), "请输入车牌号");
         Page<BarnRecordVO> result = barnRecordService.getPage(queryParams);
         return PageResult.success(result);

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

@@ -9,6 +9,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.druid.sql.visitor.functions.If;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.qmrb.system.common.exception.BusinessException;
+import com.qmrb.system.framework.security.util.SecurityUtils;
 import com.qmrb.system.pojo.entity.BarnRecord;
 import com.qmrb.system.pojo.entity.CarParkStoredCard;
 import com.qmrb.system.pojo.form.BarnRecordForm;

+ 50 - 7
src/main/java/com/qmrb/system/controller/MyCarPlateNumberController.java

@@ -8,11 +8,14 @@ import com.qmrb.system.common.exception.BusinessException;
 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.security.util.SecurityUtils;
 import com.qmrb.system.pojo.entity.MyCarPlateNumber;
+import com.qmrb.system.pojo.entity.UserPlateNumRelHis;
 import com.qmrb.system.pojo.form.MyCarPlateNumberForm;
 import com.qmrb.system.pojo.query.MyCarPlateNumberQuery;
 import com.qmrb.system.pojo.vo.MyCarPlateNumberVO;
 import com.qmrb.system.service.IMyCarPlateNumberService;
+import com.qmrb.system.service.IUserPlateNumRelHisService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -24,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -45,6 +50,9 @@ public class MyCarPlateNumberController{
 
     @Autowired
     private IMyCarPlateNumberService myCarPlateNumberService;
+    
+    @Autowired
+    private IUserPlateNumRelHisService userPlateNumRelHisService;
 
 	@Operation(summary = "我的车牌分页列表", security = {@SecurityRequirement(name = "Authorization")})
     @GetMapping("/page")
@@ -61,9 +69,10 @@ public class MyCarPlateNumberController{
     public PageResult<MyCarPlateNumberVO> getPageByUserId(
             @ParameterObject MyCarPlateNumberQuery queryParams
     ) {
-        if(queryParams.getUserId() == null){
-            throw new BusinessException("用户id不能为空");
+        if(SecurityUtils.getUserId() == null){
+            return PageResult.success(null);
         }
+        queryParams.setUserId(SecurityUtils.getUserId());
         Page<MyCarPlateNumberVO> result = myCarPlateNumberService.getPage(queryParams);
         return PageResult.success(result);
     }
@@ -73,15 +82,30 @@ public class MyCarPlateNumberController{
     public Result<MyCarPlateNumberForm> saveForm(
             @RequestBody @Valid MyCarPlateNumberForm form
     ) {
+        form.setUserId(SecurityUtils.getUserId());
         log.info("user_id:"+form.getUserId());
         log.info("plateNumber:"+form.getPlateNumber());
         log.info("cardType:"+form.getCarType());
-        if(form.getUserId() == null){
+        if(SecurityUtils.getUserId() == null){
             return Result.failed("用户id不能为空");
         }
         List<MyCarPlateNumber> list = myCarPlateNumberService.list(new LambdaQueryWrapper<MyCarPlateNumber>().eq(MyCarPlateNumber::getUserId, form.getUserId()));
         if(CollectionUtil.isNotEmpty(list)){
             myCarPlateNumberService.removeByIds(list);
+            Set<String> plateNumberSet = list.stream().map(item -> {
+                return item.getPlateNumber();
+            }).collect(Collectors.toSet());
+            // 删除之前已存在的历史记录
+            userPlateNumRelHisService.remove(new LambdaQueryWrapper<UserPlateNumRelHis>().in(UserPlateNumRelHis::getPlateNumber,plateNumberSet).eq(UserPlateNumRelHis::getUserId,form.getUserId()));
+            ArrayList<UserPlateNumRelHis> hisPlateNumberList = new ArrayList<>();
+            //添加到历史车牌中
+            for (MyCarPlateNumber myCarPlateNumber : list) {
+                UserPlateNumRelHis userPlateNumRelHis = new UserPlateNumRelHis();
+                userPlateNumRelHis.setUserId(myCarPlateNumber.getUserId());
+                userPlateNumRelHis.setPlateNumber(myCarPlateNumber.getPlateNumber());
+                hisPlateNumberList.add(userPlateNumRelHis);
+            }
+            userPlateNumRelHisService.saveBatch(hisPlateNumberList);
         }
         MyCarPlateNumberForm result = myCarPlateNumberService.saveForm(form);
         return Result.success(result);
@@ -97,14 +121,13 @@ public class MyCarPlateNumberController{
     }
     
     @Operation(summary = "我的车牌表单数据", security = {@SecurityRequirement(name = "Authorization")})
-    @GetMapping("/{userId}/formByUserId")
+    @GetMapping("/formByUserId")
     public Result<?> getFormByUserId(
-            @Parameter(description = "用户ID") @PathVariable Long userId
     ) {
-        if(userId == null){
+        if(SecurityUtils.getUserId() == null){
             return Result.failed("用户id不能为空");
         }
-        List<MyCarPlateNumber> list = myCarPlateNumberService.list(new LambdaQueryWrapper<MyCarPlateNumber>().eq(MyCarPlateNumber::getUserId, userId));
+        List<MyCarPlateNumber> list = myCarPlateNumberService.list(new LambdaQueryWrapper<MyCarPlateNumber>().eq(MyCarPlateNumber::getUserId, SecurityUtils.getUserId()));
         return Result.success(list);
     }
 
@@ -129,7 +152,27 @@ public class MyCarPlateNumberController{
         // 逻辑删除
         List<Long> idList = Arrays.asList(ids.split(",")).stream()
                 .map(idStr -> Long.parseLong(idStr)).collect(Collectors.toList());
+        List<MyCarPlateNumber> list = myCarPlateNumberService.listByIds(idList);
         boolean result = myCarPlateNumberService.removeByIds(idList);
+
+        if(CollectionUtil.isNotEmpty(list)){
+
+            Set<String> plateNumberSet = list.stream().map(item -> {
+                return item.getPlateNumber();
+            }).collect(Collectors.toSet());
+            // 删除之前已存在的历史记录
+            userPlateNumRelHisService.remove(new LambdaQueryWrapper<UserPlateNumRelHis>().in(UserPlateNumRelHis::getPlateNumber,plateNumberSet).eq(UserPlateNumRelHis::getUserId, SecurityUtils.getUserId()));
+            ArrayList<UserPlateNumRelHis> hisPlateNumberList = new ArrayList<>();
+            //添加到历史车牌中
+            for (MyCarPlateNumber myCarPlateNumber : list) {
+                UserPlateNumRelHis userPlateNumRelHis = new UserPlateNumRelHis();
+                userPlateNumRelHis.setUserId(myCarPlateNumber.getUserId());
+                userPlateNumRelHis.setPlateNumber(myCarPlateNumber.getPlateNumber());
+                hisPlateNumberList.add(userPlateNumRelHis);
+            }
+            userPlateNumRelHisService.saveBatch(hisPlateNumberList);
+        }
+       
         return Result.judge(result);
     }
 

+ 3 - 0
src/main/java/com/qmrb/system/controller/OrderController.java

@@ -10,6 +10,7 @@ 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.framework.security.util.SecurityUtils;
 import com.qmrb.system.mq.PickCarProducer;
 import com.qmrb.system.pojo.dto.LoginParam;
 import com.qmrb.system.pojo.dto.UserParam;
@@ -34,6 +35,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.rocketmq.client.exception.MQBrokerException;
 import org.apache.rocketmq.client.exception.MQClientException;
 import org.apache.rocketmq.remoting.exception.RemotingException;
@@ -104,6 +106,7 @@ public class OrderController extends CommonController {
     public PageResult<PayOrderVO> getPageByUserId(
             @ParameterObject PayOrderQuery queryParams
     ) {
+        queryParams.setUserId(SecurityUtils.getUserId() != null ? SecurityUtils.getUserId().toString() : "");
         if(StrUtil.isNotBlank(queryParams.getUserId())){
             Page<PayOrderVO> pageResult = orderService.getPageByUserId(queryParams);
             if(CollectionUtil.isNotEmpty(pageResult.getRecords())){

+ 127 - 0
src/main/java/com/qmrb/system/controller/UserPlateNumRelHisController.java

@@ -0,0 +1,127 @@
+package com.qmrb.system.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.qmrb.system.framework.security.util.SecurityUtils;
+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.IUserPlateNumRelHisService;
+import com.qmrb.system.pojo.form.UserPlateNumRelHisForm;
+import com.qmrb.system.pojo.vo.UserPlateNumRelHisVO;
+import com.qmrb.system.pojo.query.UserPlateNumRelHisQuery;
+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-03-10
+ */
+@Tag(name = "客商车牌关系接口")
+@RestController
+@RequestMapping("/api/v1/plate_num_rel_his")
+@CrossOrigin
+public class UserPlateNumRelHisController{
+
+    @Autowired
+    private IUserPlateNumRelHisService userPlateNumRelHisService;
+
+	@Operation(summary = "客商车牌关系分页列表", security = {@SecurityRequirement(name = "Authorization")})
+    @GetMapping("/page")
+    public PageResult<UserPlateNumRelHisVO> getPage(
+            @ParameterObject UserPlateNumRelHisQuery queryParams
+    ) {
+        Page<UserPlateNumRelHisVO> result = userPlateNumRelHisService.getPage(queryParams);
+        return PageResult.success(result);
+    }
+    
+    @Operation(summary = "客商车牌关系分页列表", security = {@SecurityRequirement(name = "Authorization")})
+    @GetMapping("/pageByUserId")
+    public PageResult<UserPlateNumRelHisVO> pageByUserId(
+            @ParameterObject UserPlateNumRelHisQuery queryParams
+    ) {
+        if(SecurityUtils.getUserId() == null){
+            return PageResult.success(null);
+        }
+        queryParams.setUserId(SecurityUtils.getUserId());
+        Page<UserPlateNumRelHisVO> result = userPlateNumRelHisService.getPage(queryParams);
+        return PageResult.success(result);
+    }
+    
+    @Operation(summary = "新增客商车牌关系", security = {@SecurityRequirement(name = "Authorization")})
+    @PostMapping
+    @PreAuthorize("@ss.hasPerm('plate_num_rel_his:add')")
+    @Resubmit
+    public Result<UserPlateNumRelHisForm> saveForm(
+            @RequestBody @Valid UserPlateNumRelHisForm form
+    ) {
+        UserPlateNumRelHisForm result = userPlateNumRelHisService.saveForm(form);
+        return Result.success(result);
+    }
+
+    @Operation(summary = "客商车牌关系表单数据", security = {@SecurityRequirement(name = "Authorization")})
+    @GetMapping("/{id}/form")
+    public Result<UserPlateNumRelHisForm> getForm(
+            @Parameter(description = "客商车牌关系ID") @PathVariable Long id
+    ) {
+    	UserPlateNumRelHisForm formData = userPlateNumRelHisService.getFormData(id);
+        return Result.success(formData);
+    }
+
+    @Operation(summary = "修改客商车牌关系", security = {@SecurityRequirement(name = "Authorization")})
+    @PutMapping(value = "/{id}")
+    @PreAuthorize("@ss.hasPerm('plate_num_rel_his:edit')")
+    public Result<?> updateForm(
+            @Parameter(description = "客商车牌关系ID") @PathVariable Long id,
+            @RequestBody @Validated UserPlateNumRelHisForm form) {
+    	
+        boolean result = userPlateNumRelHisService.updateForm(id,form);
+        return Result.judge(result);
+    }
+
+    @Operation(summary = "删除客商车牌关系", security = {@SecurityRequirement(name = "Authorization")})
+    @DeleteMapping("/{ids}")
+    @PreAuthorize("@ss.hasPerm('plate_num_rel_his: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 = userPlateNumRelHisService.removeByIds(idList);
+        return Result.judge(result);
+    }
+    
+
+
+}

+ 29 - 0
src/main/java/com/qmrb/system/converter/UserPlateNumRelHisConverter.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.UserPlateNumRelHis;
+import com.qmrb.system.pojo.form.UserPlateNumRelHisForm;
+import com.qmrb.system.pojo.vo.UserPlateNumRelHisVO;
+
+/**
+ * 客商车牌关系数据项对象转换器
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface UserPlateNumRelHisConverter {
+
+    Page<UserPlateNumRelHisVO> entity2Page(Page<UserPlateNumRelHis> page);
+
+    UserPlateNumRelHisForm entity2Form(UserPlateNumRelHis entity);
+
+    @InheritInverseConfiguration(name="entity2Form")
+    UserPlateNumRelHis form2Entity(UserPlateNumRelHisForm form);
+    
+    UserPlateNumRelHisVO entity2Vo(UserPlateNumRelHis entity);
+}

+ 1 - 0
src/main/java/com/qmrb/system/framework/security/config/SecurityConfig.java

@@ -100,6 +100,7 @@ public class SecurityConfig {
                         "/api/v1/patientSign/getCaUnSignQrcode",
                         "/api/v1/patientSign/getFwzxScanQrcode",
                         "/api/ucenter/**",
+                        "/api/v1/auth/loginByMerchants",
                         "/api/order/wechatPayCallback"
 
                 );

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

@@ -0,0 +1,18 @@
+package com.qmrb.system.mapper;
+
+import com.qmrb.system.pojo.entity.UserPlateNumRelHis;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 客商车牌关系 Mapper 接口
+ * </p>
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+@Mapper
+public interface UserPlateNumRelHisMapper extends BaseMapper<UserPlateNumRelHis> {
+
+}

+ 42 - 0
src/main/java/com/qmrb/system/pojo/entity/UserPlateNumRelHis.java

@@ -0,0 +1,42 @@
+package com.qmrb.system.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.qmrb.system.common.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 客商车牌关系
+ * </p>
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("user_plate_num_rel_his")
+public class UserPlateNumRelHis extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 车牌
+     */
+    @TableField("plate_number")
+    private String plateNumber;
+
+    /**
+     * 用户ID
+     */
+    @TableField("user_id")
+    private Long userId;
+
+
+}

+ 30 - 0
src/main/java/com/qmrb/system/pojo/form/UserPlateNumRelHisForm.java

@@ -0,0 +1,30 @@
+package com.qmrb.system.pojo.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * <p>
+ * 客商车牌关系表单
+ * </p>
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+@Data
+public class UserPlateNumRelHisForm {
+
+    private Long id;
+    /**
+     * 车牌
+     */
+	@Schema(description = "车牌",type="String")
+    private String plateNumber;
+    /**
+     * 用户ID
+     */
+	@Schema(description = "用户ID",type="Long")
+    private Long userId;
+
+
+}

+ 1 - 0
src/main/java/com/qmrb/system/pojo/query/AuthLogin.java

@@ -6,4 +6,5 @@ import lombok.Data;
 public class AuthLogin {
     String account;
     String password;
+    String userType;
 }

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

@@ -42,8 +42,8 @@ public class CarParkStoredCardQuery extends BasePageQuery{
     /**
      * 所属者
      */
-	@Schema(description = "所属者",type="Long")
-    private Long userId;
+	// @Schema(description = "所属者",type="Long")
+    // private Long userId;
 
     private String startTimeBegin;
     private String startTimeEnd;

+ 36 - 0
src/main/java/com/qmrb/system/pojo/query/UserPlateNumRelHisQuery.java

@@ -0,0 +1,36 @@
+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;
+
+/**
+ * <p>
+ * 客商车牌关系查询对象
+ * </p>
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class UserPlateNumRelHisQuery extends BasePageQuery{
+
+ 	@Schema(description="关键字")
+    private String keywords;
+
+    private Long id;
+    /**
+     * 车牌
+     */
+	@Schema(description = "车牌",type="String")
+    private String plateNumber;
+    /**
+     * 用户ID
+     */
+	@Schema(description = "用户ID",type="Long")
+    private Long userId;
+
+
+}

+ 40 - 0
src/main/java/com/qmrb/system/pojo/vo/UserPlateNumRelHisVO.java

@@ -0,0 +1,40 @@
+package com.qmrb.system.pojo.vo;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * <p>
+ * 客商车牌关系视图对象
+ * </p>
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+@Data
+public class UserPlateNumRelHisVO {
+
+    private Long id;
+    /**
+     * 车牌
+     */
+	@Schema(description = "车牌",type="String")
+    private String plateNumber;
+    /**
+     * 用户ID
+     */
+	@Schema(description = "用户ID",type="Long")
+    private Long userId;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime createTime;
+
+	@Schema(description = "子分类")
+    private List<UserPlateNumRelHisVO> children;
+
+
+}

+ 41 - 0
src/main/java/com/qmrb/system/service/IUserPlateNumRelHisService.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.UserPlateNumRelHis;
+import com.qmrb.system.pojo.form.UserPlateNumRelHisForm;
+import com.qmrb.system.pojo.vo.UserPlateNumRelHisVO;
+import com.qmrb.system.pojo.query.UserPlateNumRelHisQuery;
+import com.qmrb.system.pojo.vo.Option;
+import com.baomidou.mybatisplus.extension.service.IService;
+import jakarta.validation.Valid;
+
+/**
+ * <p>
+ * 客商车牌关系 服务类
+ * </p>
+ *
+ * @author gs
+ * @since 2025-03-10
+ */
+public interface IUserPlateNumRelHisService extends IService<UserPlateNumRelHis> {
+	
+	/**分页查询
+	 * */
+	public Page<UserPlateNumRelHisVO> getPage(UserPlateNumRelHisQuery queryParams);
+
+	/**
+	 * 保存表单
+	 * */
+	public UserPlateNumRelHisForm saveForm(@Valid UserPlateNumRelHisForm form);
+	
+	/**更新
+	 * */
+	public boolean updateForm(Long id, UserPlateNumRelHisForm form);
+	
+	/**获取表单数据
+	 * */
+	public UserPlateNumRelHisForm getFormData(Long id);
+	
+}

+ 103 - 0
src/main/java/com/qmrb/system/service/impl/UserPlateNumRelHisServiceImpl.java

@@ -0,0 +1,103 @@
+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.UserPlateNumRelHisConverter;
+import com.qmrb.system.pojo.entity.UserPlateNumRelHis;
+import com.qmrb.system.pojo.form.UserPlateNumRelHisForm;
+import com.qmrb.system.pojo.vo.UserPlateNumRelHisVO;
+import com.qmrb.system.pojo.query.UserPlateNumRelHisQuery;
+import com.qmrb.system.mapper.UserPlateNumRelHisMapper;
+import com.qmrb.system.service.IUserPlateNumRelHisService;
+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-03-10
+ */
+@Service
+public class UserPlateNumRelHisServiceImpl extends ServiceImpl<UserPlateNumRelHisMapper, UserPlateNumRelHis> implements IUserPlateNumRelHisService {
+
+	@Autowired
+	private UserPlateNumRelHisConverter converter;
+
+	/**分页查询
+	 * */
+	@Override
+	public Page<UserPlateNumRelHisVO> getPage(UserPlateNumRelHisQuery queryParams) {
+		// 查询参数
+        int pageNum = queryParams.getPageNum();
+        int pageSize = queryParams.getPageSize();
+        //String keywords = queryParams.getKeywords();
+
+        // 查询数据
+        Page<UserPlateNumRelHis> dictItemPage = this.page(
+                new Page<>(pageNum, pageSize),
+                new LambdaQueryWrapper<UserPlateNumRelHis>()
+						.eq(queryParams.getUserId() != null,UserPlateNumRelHis::getUserId,queryParams.getUserId())
+						.orderByDesc(UserPlateNumRelHis::getUpdateTime)
+                	//.like(StrUtil.isNotBlank(keywords), UserPlateNumRelHis::getCategoryName, keywords)
+        );
+
+        // 实体转换
+        Page<UserPlateNumRelHisVO> pageResult = converter.entity2Page(dictItemPage);
+        return pageResult;
+	}
+
+	/**
+	 * 保存表单
+	 * */
+	@Override
+	public UserPlateNumRelHisForm saveForm(@Valid UserPlateNumRelHisForm form) {
+		// 实体对象转换 form->entity
+		UserPlateNumRelHis entity = converter.form2Entity(form);
+        // 持久化
+        this.save(entity);
+        UserPlateNumRelHisForm result = converter.entity2Form(entity);
+        return result;
+	}
+
+	/**更新
+	 * */
+	@Override
+	public boolean updateForm(Long id, UserPlateNumRelHisForm form) {
+		UserPlateNumRelHis entity = converter.form2Entity(form);
+		entity.setId(id);
+        boolean result = this.updateById(entity);
+        return result;
+	}
+
+	/**获取表单数据
+	 * */
+	@Override
+	public UserPlateNumRelHisForm getFormData(Long id) {
+		// 获取entity
+		UserPlateNumRelHis entity = this.getById(id);
+        Assert.isTrue(entity != null, "客商车牌关系不存在");
+
+        // 实体转换
+        UserPlateNumRelHisForm form = converter.entity2Form(entity);
+        return form;
+	}
+	
+	
+}

+ 5 - 0
src/main/resources/mapper/UserPlateNumRelHisMapper.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.UserPlateNumRelHisMapper">
+
+</mapper>