Merge remote-tracking branch 'origin/lyh' into xiaoyao
# Conflicts: # couplet-modules/pom.xmlserver_five_liuyunhu
commit
a044923af3
|
@ -0,0 +1,114 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>couplet-modules-vehicle</artifactId>
|
||||||
|
|
||||||
|
<!-- <properties>-->
|
||||||
|
<!-- <maven.compiler.source>17</maven.compiler.source>-->
|
||||||
|
<!-- <maven.compiler.target>17</maven.compiler.target>-->
|
||||||
|
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
||||||
|
<!-- </properties>-->
|
||||||
|
|
||||||
|
<description>
|
||||||
|
couplet-modules-vehicle车辆管理模块
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.couplet.vehicle;
|
||||||
|
|
||||||
|
import com.couplet.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: Default (Template) Project
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class LyhVehicleApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(LyhVehicleApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.couplet.vehicle.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.vehicle.domain.LyhVehicle;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleEditParams;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleInsertParams;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleListParams;
|
||||||
|
import com.couplet.vehicle.service.LyhVehicleService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/vehicle")
|
||||||
|
public class LyhVehicleController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private LyhVehicleService lyhVehicleService;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 21:39
|
||||||
|
* @Description: 查询车辆列表
|
||||||
|
* @Param: [listParams]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@PostMapping("/list")
|
||||||
|
@Log(title = "车辆列表")
|
||||||
|
public Result list(@RequestBody LyhVehicleListParams listParams) {
|
||||||
|
|
||||||
|
List<LyhVehicle> List = lyhVehicleService.list(listParams);
|
||||||
|
|
||||||
|
return Result.success(List);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 22:35
|
||||||
|
* @Description: 通过id删除车辆
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@GetMapping("/deleteById/{vehicleId}")
|
||||||
|
@Log(title = "删除车辆", businessType = BusinessType.DELETE)
|
||||||
|
public Result deleteById(@PathVariable Long vehicleId) {
|
||||||
|
String result = lyhVehicleService.deleteById(vehicleId);
|
||||||
|
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 16:09
|
||||||
|
* @Description: 编辑车辆
|
||||||
|
* @Param: [editParams]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@PostMapping("/editById")
|
||||||
|
@Log(title = "编辑车辆", businessType = BusinessType.UPDATE)
|
||||||
|
public Result editById(@RequestBody LyhVehicleEditParams editParams) {
|
||||||
|
|
||||||
|
String result = lyhVehicleService.editById(editParams);
|
||||||
|
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 16:21
|
||||||
|
* @Description: 新增车辆
|
||||||
|
* @Param: [insertParams]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@PostMapping("/insert")
|
||||||
|
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
||||||
|
public Result insert(@RequestBody LyhVehicleInsertParams insertParams) {
|
||||||
|
|
||||||
|
String result = lyhVehicleService.insert(insertParams);
|
||||||
|
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.couplet.vehicle.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆信息表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("lyh_vehicle")
|
||||||
|
public class LyhVehicle {
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆id
|
||||||
|
* */
|
||||||
|
@TableId(type = IdType.AUTO, value = "vehicle_id")
|
||||||
|
private Long vehicleId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
@TableField(value = "vehicle_type")
|
||||||
|
private Integer vehicleType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机厂商
|
||||||
|
* */
|
||||||
|
@TableField(value = "motor_manufacturer")
|
||||||
|
private String motorManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池厂商
|
||||||
|
* */
|
||||||
|
@TableField(value = "battery_manufacturer")
|
||||||
|
private String batteryManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机编号
|
||||||
|
* */
|
||||||
|
@TableField(value = "motor_number")
|
||||||
|
private String motorNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池编号
|
||||||
|
* */
|
||||||
|
@TableField(value = "battery_number")
|
||||||
|
private String batteryNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*vin码
|
||||||
|
* */
|
||||||
|
@TableField(value = "vin")
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*0离线 1在线
|
||||||
|
* */
|
||||||
|
@TableField(value = "vehicle_state")
|
||||||
|
private Integer vehicleState;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*0未删除 1删除
|
||||||
|
* */
|
||||||
|
@TableField(value = "isdelete")
|
||||||
|
private Integer isdelete;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.couplet.vehicle.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description: 车辆编辑入参
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class LyhVehicleEditParams {
|
||||||
|
/*
|
||||||
|
*车辆id
|
||||||
|
* */
|
||||||
|
private Long vehicleId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
private Integer vehicleType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机厂商
|
||||||
|
* */
|
||||||
|
private String motorManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池厂商
|
||||||
|
* */
|
||||||
|
private String batteryManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机编号
|
||||||
|
* */
|
||||||
|
private String motorNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池编号
|
||||||
|
* */
|
||||||
|
private String batteryNumber;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.couplet.vehicle.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description: 车辆编辑入参
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class LyhVehicleInsertParams {
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
@NotNull(message = "车辆类型不能为空")
|
||||||
|
private Integer vehicleType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机厂商
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电机厂商不能为空")
|
||||||
|
private String motorManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池厂商
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电池厂商不能为空")
|
||||||
|
private String batteryManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机编号
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电机编号不能为空")
|
||||||
|
private String motorNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池编号
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电池编号不能为空")
|
||||||
|
private String batteryNumber;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.couplet.vehicle.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 查询车辆列表入参
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class LyhVehicleListParams {
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
private Integer vehicleType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*0离线 1在线
|
||||||
|
* */
|
||||||
|
private Integer vehicleState;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.couplet.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.vehicle.domain.LyhVehicle;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Component
|
||||||
|
public interface LyhVehicleMapper extends BaseMapper<LyhVehicle> {
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.couplet.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.vehicle.domain.LyhVehicle;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleEditParams;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleInsertParams;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleListParams;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface LyhVehicleService extends IService<LyhVehicle> {
|
||||||
|
List<LyhVehicle> list(LyhVehicleListParams listParams);
|
||||||
|
|
||||||
|
String deleteById(Long vehicleId);
|
||||||
|
|
||||||
|
String editById(LyhVehicleEditParams editParams);
|
||||||
|
|
||||||
|
String insert(LyhVehicleInsertParams insertParams);
|
||||||
|
}
|
|
@ -0,0 +1,162 @@
|
||||||
|
package com.couplet.vehicle.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.common.core.utils.StringUtils;
|
||||||
|
import com.couplet.vehicle.domain.LyhVehicle;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleEditParams;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleInsertParams;
|
||||||
|
import com.couplet.vehicle.domain.req.LyhVehicleListParams;
|
||||||
|
import com.couplet.vehicle.mapper.LyhVehicleMapper;
|
||||||
|
import com.couplet.vehicle.service.LyhVehicleService;
|
||||||
|
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class LyhVehicleServiceImpl extends ServiceImpl<LyhVehicleMapper, LyhVehicle> implements LyhVehicleService {
|
||||||
|
@Autowired
|
||||||
|
private LyhVehicleMapper lyhVehicleMapper;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 22:11
|
||||||
|
* @Description: 查询列表
|
||||||
|
* @Param: [listParams]
|
||||||
|
* @Return: java.util.List<com.couplet.vehicle.domain.LyhVehicle>
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<LyhVehicle> list(LyhVehicleListParams listParams) {
|
||||||
|
// 创建查询条件包装器
|
||||||
|
LambdaQueryWrapper<LyhVehicle> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 如果车辆类型不为空,添加车辆类型作为查询条件
|
||||||
|
if (!StringUtils.isNull(listParams.getVehicleType())) {
|
||||||
|
queryWrapper.eq(LyhVehicle::getVehicleType, listParams.getVehicleType());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果车辆状态不为空,添加车辆状态作为查询条件
|
||||||
|
if (!StringUtils.isNull(listParams.getVehicleState())) {
|
||||||
|
queryWrapper.eq(LyhVehicle::getVehicleState, listParams.getVehicleState());
|
||||||
|
}
|
||||||
|
|
||||||
|
//只查询车辆未被删除的
|
||||||
|
queryWrapper.eq(LyhVehicle::getIsdelete, 0);
|
||||||
|
|
||||||
|
// 执行查询并返回结果
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 22:31
|
||||||
|
* @Description: 通过id删除
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String deleteById(Long vehicleId) {
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
UpdateWrapper<LyhVehicle> updateWrapper = new UpdateWrapper<>();
|
||||||
|
|
||||||
|
updateWrapper.set("isdelete", 1)
|
||||||
|
.eq("vehicle_id", vehicleId);
|
||||||
|
|
||||||
|
boolean update = update(updateWrapper);
|
||||||
|
|
||||||
|
if (!update) {
|
||||||
|
result = "删除失败";
|
||||||
|
throw new RuntimeException(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = "删除成功!";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 15:21
|
||||||
|
* @Description: 通过id进行编辑
|
||||||
|
* @Param: [editParams]
|
||||||
|
* @Return: java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String editById(LyhVehicleEditParams editParams) {
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
UpdateWrapper<LyhVehicle> updateWrapper = new UpdateWrapper<>();
|
||||||
|
|
||||||
|
//编辑车辆类型
|
||||||
|
|
||||||
|
updateWrapper.set("vehicle_type", editParams.getVehicleType())
|
||||||
|
|
||||||
|
//编辑电机厂商
|
||||||
|
.set("motor_manufacturer", editParams.getMotorManufacturer())
|
||||||
|
|
||||||
|
//编辑电池厂商
|
||||||
|
.set("battery_manufacturer", editParams.getBatteryManufacturer())
|
||||||
|
|
||||||
|
//编辑电机编号
|
||||||
|
.set("motor_number", editParams.getMotorNumber())
|
||||||
|
|
||||||
|
//编辑电池编号
|
||||||
|
.set("battery_number", editParams.getBatteryNumber())
|
||||||
|
|
||||||
|
//匹配车辆id
|
||||||
|
.eq("vehicle_id", editParams.getVehicleId());
|
||||||
|
|
||||||
|
|
||||||
|
boolean update = update(updateWrapper);
|
||||||
|
|
||||||
|
if (!update) {
|
||||||
|
result = "编辑失败";
|
||||||
|
throw new RuntimeException(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = "编辑成功!";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 16:34
|
||||||
|
* @Description: 新增车辆
|
||||||
|
* @Param: [insertParams]
|
||||||
|
* @Return: java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String insert(LyhVehicleInsertParams insertParams) {
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
|
long randomId = idGenerator.nextId();
|
||||||
|
String vin = "VIN" + randomId;
|
||||||
|
|
||||||
|
int insert = lyhVehicleMapper.insert(new LyhVehicle(null, insertParams.getVehicleType(), insertParams.getMotorManufacturer(), insertParams.getBatteryManufacturer(), insertParams.getMotorNumber(), insertParams.getBatteryNumber(), vin, 0, 0));
|
||||||
|
|
||||||
|
if (insert == 0) {
|
||||||
|
result = "新增失败";
|
||||||
|
throw new RuntimeException(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = "新增成功!";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.couplet.vehicle.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description: 雪花ID生成器
|
||||||
|
* 使用方法
|
||||||
|
* SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1); // 创建一个 ID 生成器,传入机器 ID 和数据中心 ID
|
||||||
|
* long id = idGenerator.nextId(); // 生成 ID
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SnowflakeIdGenerator {
|
||||||
|
|
||||||
|
private final long epoch = 1420041600000L; // 起始时间戳,用于缩小时间戳范围,可根据实际情况调整
|
||||||
|
private final long workerIdBits = 5L; // 机器 ID 所占位数
|
||||||
|
private final long dataCenterIdBits = 5L; // 数据中心 ID 所占位数
|
||||||
|
private final long sequenceBits = 12L; // 序列号所占位数
|
||||||
|
|
||||||
|
private final long maxWorkerId = -1L ^ (-1L << workerIdBits); // 机器 ID 最大值
|
||||||
|
private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits); // 数据中心 ID 最大值
|
||||||
|
private final long maxSequence = -1L ^ (-1L << sequenceBits); // 序列号最大值
|
||||||
|
|
||||||
|
private final long workerIdShift = sequenceBits; // 机器 ID 向左移动位数
|
||||||
|
private final long dataCenterIdShift = sequenceBits + workerIdBits; // 数据中心 ID 向左移动位数
|
||||||
|
private final long timestampShift = sequenceBits + workerIdBits + dataCenterIdBits; // 时间戳向左移动位数
|
||||||
|
|
||||||
|
private long workerId; // 机器 ID
|
||||||
|
private long dataCenterId; // 数据中心 ID
|
||||||
|
private long sequence = 0L; // 序列号
|
||||||
|
private long lastTimestamp = -1L; // 上次生成的时间戳
|
||||||
|
|
||||||
|
public SnowflakeIdGenerator(long workerId, long dataCenterId) {
|
||||||
|
if (workerId > maxWorkerId || workerId < 0) {
|
||||||
|
throw new IllegalArgumentException("Worker ID can't be greater than " + maxWorkerId + " or less than 0");
|
||||||
|
}
|
||||||
|
if (dataCenterId > maxDataCenterId || dataCenterId < 0) {
|
||||||
|
throw new IllegalArgumentException("Data center ID can't be greater than " + maxDataCenterId + " or less than 0");
|
||||||
|
}
|
||||||
|
this.workerId = workerId;
|
||||||
|
this.dataCenterId = dataCenterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized long nextId() {
|
||||||
|
long timestamp = timeGen();
|
||||||
|
|
||||||
|
if (timestamp < lastTimestamp) {
|
||||||
|
throw new RuntimeException("Clock moved backwards, refusing to generate ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timestamp == lastTimestamp) {
|
||||||
|
sequence = (sequence + 1) & maxSequence;
|
||||||
|
if (sequence == 0) {
|
||||||
|
timestamp = tilNextMillis(lastTimestamp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sequence = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastTimestamp = timestamp;
|
||||||
|
|
||||||
|
return ((timestamp - epoch) << timestampShift) |
|
||||||
|
(dataCenterId << dataCenterIdShift) |
|
||||||
|
(workerId << workerIdShift) |
|
||||||
|
sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long tilNextMillis(long lastTimestamp) {
|
||||||
|
long timestamp = timeGen();
|
||||||
|
while (timestamp <= lastTimestamp) {
|
||||||
|
timestamp = timeGen();
|
||||||
|
}
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long timeGen() {
|
||||||
|
return System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9615
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: couplet-vehicle
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.couplet.system.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/couplet-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.couplet" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?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.couplet.vehicle.mapper.LyhVehicleMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,20 @@
|
||||||
|
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IdTest {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
|
|
||||||
|
long l = idGenerator.nextId();
|
||||||
|
System.out.println(l);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@
|
||||||
<module>couplet-job</module>
|
<module>couplet-job</module>
|
||||||
<module>couplet-file</module>
|
<module>couplet-file</module>
|
||||||
<module>couplet-trouble</module>
|
<module>couplet-trouble</module>
|
||||||
|
<module>couplet-modules-vehicle</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>couplet-modules</artifactId>
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue