Merge remote-tracking branch 'origin/server_five_liuyunhu' into server_five_xiaoyao

# Conflicts:
#	couplet-auth/src/main/resources/bootstrap.yml
#	couplet-gateway/src/main/resources/bootstrap.yml
#	couplet-modules/couplet-file/src/main/resources/bootstrap.yml
#	couplet-modules/couplet-gen/src/main/resources/bootstrap.yml
#	couplet-modules/couplet-job/src/main/resources/bootstrap.yml
#	couplet-modules/couplet-system/src/main/resources/bootstrap.yml
#	couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml
server_five_liuyunhu
lijiayao 2024-04-01 19:49:11 +08:00
commit 9c9dfb7090
24 changed files with 150 additions and 31 deletions

View File

@ -15,7 +15,6 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
@ -24,6 +23,5 @@ spring:
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true

View File

@ -15,7 +15,6 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
@ -24,7 +23,6 @@ spring:
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
sentinel: sentinel:
# 取消控制台懒加载 # 取消控制台懒加载
eager: true eager: true

View File

@ -16,9 +16,11 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: 172469
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: 172469
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,9 +15,11 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: 172469
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: 172469
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,11 +15,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,11 +15,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,11 +15,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,11 +15,11 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 namespace: 172469
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 namespace: 172469
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -84,6 +84,13 @@
<artifactId>couplet-common-swagger</artifactId> <artifactId>couplet-common-swagger</artifactId>
</dependency> </dependency>
<!-- Pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -10,6 +10,8 @@ import com.couplet.vehicle.domain.req.VehicleEditParams;
import com.couplet.vehicle.domain.req.VehicleInsertParams; import com.couplet.vehicle.domain.req.VehicleInsertParams;
import com.couplet.vehicle.domain.req.VehicleListParams; import com.couplet.vehicle.domain.req.VehicleListParams;
import com.couplet.vehicle.service.VehicleService; import com.couplet.vehicle.service.VehicleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -39,10 +41,13 @@ public class VehicleController extends BaseController {
@PostMapping("/list") @PostMapping("/list")
@Log(title = "车辆列表") @Log(title = "车辆列表")
public Result list(@RequestBody VehicleListParams listParams) { public Result list(@RequestBody VehicleListParams listParams) {
PageHelper.startPage(listParams.getPageNum(), listParams.getPageSize());
List<Vehicle> List = vehicleService.list(listParams); List<Vehicle> list = vehicleService.list(listParams);
return Result.success(List); PageInfo<Vehicle> vehiclePageInfo = new PageInfo<>(list);
return Result.success(vehiclePageInfo);
} }
/* /*
@ -90,9 +95,27 @@ public class VehicleController extends BaseController {
@PostMapping("/insert") @PostMapping("/insert")
@Log(title = "新增车辆", businessType = BusinessType.INSERT) @Log(title = "新增车辆", businessType = BusinessType.INSERT)
public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) { public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) {
System.out.println(insertParams);
String result = vehicleService.insert(insertParams); String result = vehicleService.insert(insertParams);
return Result.success(result); return Result.success(result);
} }
/*
* @Author: LiuYunHu
* @Date: 2024/3/31 21:34
* @Description:
* @Param: [vehicleId]
* @Return: com.couplet.common.core.domain.Result
**/
@RequiresPermissions("couplet:vehicle:list")
@GetMapping("/getBindLogoById/{vehicleId}")
public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
return Result.success(bindLogoById);
}
} }

View File

@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
@ -53,4 +54,7 @@ public class VehicleEditParams {
* */ * */
private String batteryNumber; private String batteryNumber;
//标识id集合
private List<Long> logoIds;
} }

View File

@ -57,7 +57,6 @@ public class VehicleInsertParams {
/* /*
* *
* */ * */
@Size(min = 1, message = "车辆至少绑定一个标识")
private List<Long> logoIds; private List<Long> logoIds;
} }

View File

@ -26,4 +26,10 @@ public class VehicleListParams {
* */ * */
private Integer vehicleState; private Integer vehicleState;
/*
*
* */
private Integer pageNum = 1;
private Integer pageSize = 5;
} }

View File

@ -18,4 +18,8 @@ import java.util.List;
@Component @Component
public interface VehicleAndLogoMapper extends BaseMapper<VehicleAndLogo> { public interface VehicleAndLogoMapper extends BaseMapper<VehicleAndLogo> {
int vehicleBindLogo(@Param("vehicleId") Long vehicleId, @Param("logoIds") List<Long> logoIds); int vehicleBindLogo(@Param("vehicleId") Long vehicleId, @Param("logoIds") List<Long> logoIds);
int deleteByVehicleId(@Param("vehicleId") Long vehicleId);
List<Long> getBindLogoById(@Param("vehicleId") Long vehicleId);
} }

View File

@ -14,4 +14,8 @@ import java.util.List;
public interface VehicleAndLogoService extends IService<VehicleAndLogo> { public interface VehicleAndLogoService extends IService<VehicleAndLogo> {
int vehicleBindLogo(Long vehicleId, List<Long> logoIds); int vehicleBindLogo(Long vehicleId, List<Long> logoIds);
int deleteByVehicleId(Long vehicleId);
List<Long> getBindLogoById(Long vehicleId);
} }

View File

@ -23,4 +23,6 @@ public interface VehicleService extends IService<Vehicle> {
String editById(VehicleEditParams editParams); String editById(VehicleEditParams editParams);
String insert(VehicleInsertParams insertParams); String insert(VehicleInsertParams insertParams);
List<Long> getBindLogoById(Long vehicleId);
} }

View File

@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -34,7 +35,43 @@ public class VehicleAndLogoServiceImpl extends ServiceImpl<VehicleAndLogoMapper,
**/ **/
@Override @Override
public int vehicleBindLogo(Long vehicleId, List<Long> logoIds) { public int vehicleBindLogo(Long vehicleId, List<Long> logoIds) {
//将ids转为list
// ArrayList<Long> logoIdList = new ArrayList<>();
// String[] split = logoIds.split(",");
// for (String s : split) {
// logoIdList.add(Long.parseLong(s));
// }
//执行绑定
return mapper.vehicleBindLogo(vehicleId, logoIds); return mapper.vehicleBindLogo(vehicleId, logoIds);
} }
/*
* @Author: LiuYunHu
* @Date: 2024/3/31 21:21
* @Description:
* @Param: [vehicleId]
* @Return: int
**/
@Override
public int deleteByVehicleId(Long vehicleId) {
return mapper.deleteByVehicleId(vehicleId);
}
/*
* @Author: LiuYunHu
* @Date: 2024/3/31 21:35
* @Description:
* @Param: [vehicleId]
* @Return: java.util.List<java.lang.Long>
**/
@Override
public List<Long> getBindLogoById(Long vehicleId) {
return mapper.getBindLogoById(vehicleId);
}
} }

View File

@ -3,13 +3,13 @@ package com.couplet.vehicle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.couplet.common.core.domain.Result;
import com.couplet.common.core.utils.StringUtils; import com.couplet.common.core.utils.StringUtils;
import com.couplet.vehicle.domain.Vehicle; import com.couplet.vehicle.domain.Vehicle;
import com.couplet.vehicle.domain.VehicleType; import com.couplet.vehicle.domain.VehicleType;
import com.couplet.vehicle.domain.req.VehicleEditParams; import com.couplet.vehicle.domain.req.VehicleEditParams;
import com.couplet.vehicle.domain.req.VehicleInsertParams; import com.couplet.vehicle.domain.req.VehicleInsertParams;
import com.couplet.vehicle.domain.req.VehicleListParams; import com.couplet.vehicle.domain.req.VehicleListParams;
import com.couplet.vehicle.exception.VehicleException;
import com.couplet.vehicle.mapper.VehicleMapper; import com.couplet.vehicle.mapper.VehicleMapper;
import com.couplet.vehicle.service.VehicleAndLogoService; import com.couplet.vehicle.service.VehicleAndLogoService;
import com.couplet.vehicle.service.VehicleService; import com.couplet.vehicle.service.VehicleService;
@ -107,7 +107,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
if (!update) { if (!update) {
result = "删除失败"; result = "删除失败";
throw new VehicleException(result); Result.error(result);
} }
result = "删除成功!"; result = "删除成功!";
@ -126,10 +126,14 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
public String editById(VehicleEditParams editParams) { public String editById(VehicleEditParams editParams) {
String result = ""; String result = "";
if ((editParams.getLogoIds() == null || editParams.getLogoIds().isEmpty())) {
result = "未选择电子围栏";
Result.error(result);
}
UpdateWrapper<Vehicle> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Vehicle> updateWrapper = new UpdateWrapper<>();
//编辑车辆类型 //编辑车辆类型
updateWrapper.set("vehicle_type", editParams.getVehicleType()) updateWrapper.set("vehicle_type", editParams.getVehicleType())
//编辑电机厂商 //编辑电机厂商
@ -152,9 +156,15 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
if (!update) { if (!update) {
result = "编辑失败"; result = "编辑失败";
throw new VehicleException(result); Result.error(result);
} }
//删除掉车辆id为入参的车辆、标识的中间表数据
int delete = vehicleAndLogoService.deleteByVehicleId(editParams.getVehicleId());
//删除绑定之后,再添加新的绑定
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
result = "编辑成功!"; result = "编辑成功!";
return result; return result;
@ -171,6 +181,12 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
public String insert(VehicleInsertParams insertParams) { public String insert(VehicleInsertParams insertParams) {
String result = ""; String result = "";
if ((insertParams.getLogoIds() == null || insertParams.getLogoIds().isEmpty())) {
result = "未选择电子围栏";
Result.error(result);
}
//雪花算法生成随机数 //雪花算法生成随机数
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1); SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
long randomId = idGenerator.nextId(); long randomId = idGenerator.nextId();
@ -195,7 +211,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
if (insert == 0) { if (insert == 0) {
result = "新增失败"; result = "新增失败";
throw new VehicleException(result); Result.error(result);
} }
//获取新增的车辆id值 //获取新增的车辆id值
@ -208,4 +224,19 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
return result; return result;
} }
/*
* @Author: LiuYunHu
* @Date: 2024/3/31 21:34
* @Description:
* @Param: [vehicleId]
* @Return: java.util.List<java.lang.Long>
**/
@Override
public List<Long> getBindLogoById(Long vehicleId) {
List<Long> logoIds = vehicleAndLogoService.getBindLogoById(vehicleId);
return logoIds;
}
} }

View File

@ -15,11 +15,11 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 namespace: 172469
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 namespace: 172469
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -12,4 +12,16 @@
(#{vehicleId},#{logoId}) (#{vehicleId},#{logoId})
</foreach> </foreach>
</insert> </insert>
<delete id="deleteByVehicleId">
DELETE
FROM `couplet_vehicle_and_logo`
WHERE `vehicle_id` = #{vehicleId}
</delete>
<select id="getBindLogoById" resultType="java.lang.Long">
SELECT val.logo_id
FROM `couplet_vehicle_and_logo` val
WHERE val.vehicle_id = #{vehicleId}
</select>
</mapper> </mapper>

View File

@ -15,7 +15,6 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
@ -24,7 +23,6 @@ spring:
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
logging: logging:

View File

@ -15,11 +15,11 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 namespace: 172469
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 namespace: 172469
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,11 +15,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -250,14 +250,14 @@
<dependency> <dependency>
<groupId>com.couplet</groupId> <groupId>com.couplet</groupId>
<artifactId>couplet-modules-vehicle</artifactId> <artifactId>couplet-modules-vehicle</artifactId>
<version>3.6.3</version> <version>${couplet.version}</version>
</dependency> </dependency>
<!-- RabbitMq模块 --> <!-- RabbitMq模块 -->
<dependency> <dependency>
<groupId>com.couplet</groupId> <groupId>com.couplet</groupId>
<artifactId>couplet-modules-mq</artifactId> <artifactId>couplet-modules-mq</artifactId>
<version>3.6.3</version> <version>${couplet.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>