From 7e5de439d51ac44a72807a82ea0caa26e7440d99 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 13 八月 2024 11:14:00 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/IPartnerService.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TInvoiceTypeController.java | 64 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/query/TOrderEvaluateQuery.java | 26 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java | 2 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RoleSiteFallbackFactory.java | 11 ruoyi-api/ruoyi-api-chargingPile/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 3 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java | 360 +--- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TEvaluationTagMapper.java | 19 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RoleSiteClient.java | 26 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java | 27 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java | 6 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java | 2 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TEvaluationTagFallbackFactory.java | 40 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/UserSiteFallbackFactory.java | 11 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java | 4 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java | 3 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml | 3 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java | 2 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java | 25 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TChargingPileNotificationMapper.java | 14 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/StrategyPriceVO.java | 26 ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLoginLogMapper.xml | 35 ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/ChargingPileClient.java | 2 ruoyi-service/ruoyi-order/pom.xml | 7 ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java | 10 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java | 23 ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java | 32 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java | 2 ruoyi-service/ruoyi-other/src/main/resources/mapper/TInvoiceTypeMapper.xml | 14 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java | 3 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLoginLogServiceImpl.java | 66 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/query/InvoiceTypePageList.java | 21 ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/PartnerMapper.xml | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TRoleSiteController.java | 30 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java | 22 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageList.java | 23 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java | 42 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateMapper.java | 34 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java | 484 ++-- ruoyi-service/ruoyi-other/src/main/resources/mapper/TEvaluationTagMapper.xml | 19 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java | 69 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java | 77 ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 20 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java | 11 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java | 23 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java | 33 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java | 21 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileNotificationService.java | 12 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TAccountingStrategyDetailService.java | 16 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java | 8 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateTagMapper.java | 10 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteLogFallbackFactory.java | 10 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/SysOperLogQuery.java | 21 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java | 31 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java | 22 ruoyi-api/ruoyi-api-payment/src/main/java/com/ruoyi/payment/api/feignClient/ChargingOrderClient.java | 2 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java | 14 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLoginLogService.java | 32 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java | 15 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLoginLogController.java | 63 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java | 3 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java | 11 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ExchangeOrderClient.java | 2 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java | 11 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java | 252 +- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TInvoiceTypeMapper.java | 9 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPileNotification.java | 8 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TEvaluationTagServiceImpl.java | 23 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TOrderEvaluateService.java | 37 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java | 27 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TInvoiceTypeServiceImpl.java | 19 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TOrderEvaluate.java | 4 ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileMapper.xml | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java | 185 ++ ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysPasswordService.java | 8 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/PartnerServiceImpl.java | 27 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/TEvaluationTagVO.java | 15 ruoyi-modules/ruoyi-system/pom.xml | 18 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageListDTO.java | 40 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderEvaluateController.java | 98 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TEvaluationTagClient.java | 38 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java | 132 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileNotificationController.java | 37 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml | 104 + ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/ISiteService.java | 2 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java | 61 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RoleInfoVo.java | 14 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ParkingLotClient.java | 29 ruoyi-api/ruoyi-api-system/pom.xml | 8 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/SiteClient.java | 27 ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileNotificationMapper.xml | 21 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/SiteFallbackFactory.java | 34 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java | 36 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/PartnerController.java | 6 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLoginLogMapper.java | 24 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateTagMapper.xml | 12 ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/SiteMapper.xml | 2 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java | 17 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TOrderEvaluateVO.java | 27 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java | 51 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLoginLog.java | 91 + ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java | 30 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ParkingLotFallbackFactory.java | 36 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java | 2 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileNotificationServiceImpl.java | 69 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TEvaluationTagService.java | 19 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/SiteDetailEvaluateVO.java | 24 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysLoginLogFallbackFactory.java | 28 ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java | 53 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TInvoiceTypeService.java | 10 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java | 208 +- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/UserSiteClient.java | 26 ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 1 /dev/null | 54 ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java | 162 + ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java | 247 +- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java | 5 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java | 15 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TEvaluationTagController.java | 88 + ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysLoginLogClient.java | 26 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 61 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TUserSiteController.java | 25 123 files changed, 3,456 insertions(+), 1,364 deletions(-) diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java index 370b476..cec1394 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppCouponFallbackFactory.java @@ -2,7 +2,10 @@ import com.ruoyi.account.api.feignClient.AppCouponClient; import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; +import com.ruoyi.account.api.vo.ExchangeRecordVO; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.web.page.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; @@ -34,6 +37,11 @@ public R<Integer> getUseCountByCouponId(Integer couponId) { return null; } + + @Override + public R<PageInfo<ExchangeRecordVO>> getExchangeRecordByCouponId(ExchangeRecordGoodsQuery couponId) { + return R.fail("根据优惠券id查询领取记录:"+throwable.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java new file mode 100644 index 0000000..7a5d7e1 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java @@ -0,0 +1,36 @@ +package com.ruoyi.account.api.factory; + +import com.ruoyi.account.api.feignClient.AppUserCarClient; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.TAppUser; +import com.ruoyi.account.api.model.TAppUserCar; +import com.ruoyi.common.core.domain.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 门店服务降级处理 + * + * @author ruoyi + */ +@Component +public class AppUserCarFallbackFactory implements FallbackFactory<AppUserCarClient> +{ + private static final Logger log = LoggerFactory.getLogger(AppUserCarFallbackFactory.class); + + @Override + public AppUserCarClient create(Throwable throwable) { + log.error("用户车辆服务调用失败:{}", throwable.getMessage()); + return new AppUserCarClient() { + + @Override + public R<List<TAppUserCar>> getCarByIds(List<Integer> carIds) { + return R.fail("根据用户车辆id查询车辆信息失败:"+throwable.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java index 22549a5..ca9289e 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java @@ -1,6 +1,7 @@ package com.ruoyi.account.api.factory; import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.TAppUser; import com.ruoyi.common.core.domain.R; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,6 +29,16 @@ public R<List<Long>> getUserIdsByPhone(String phone) { return R.fail("根据手机号查询用户ids失败:"+throwable.getMessage()); } + + @Override + public R<TAppUser> getUserById(Long id) { + return R.fail("根据id查询用户失败:"+throwable.getMessage()); + } + + @Override + public R<List<TAppUser>> getUserByIds(List<Long> appUserIds) { + return R.fail("根据用户id查询用户信息失败:"+throwable.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java index aa5698e..f2cae45 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppCouponClient.java @@ -18,7 +18,7 @@ * 用户服务 * @author ruoyi */ -@FeignClient(contextId = "AppCouponClient", value = ServiceNameConstants.CONTRACT_ACCOUNT, fallbackFactory = AppCouponFallbackFactory.class) +@FeignClient(contextId = "AppCouponClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = AppCouponFallbackFactory.class) public interface AppCouponClient { /** diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java new file mode 100644 index 0000000..82bb2c5 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java @@ -0,0 +1,31 @@ +package com.ruoyi.account.api.feignClient; + +import com.ruoyi.account.api.factory.AppUserCarFallbackFactory; +import com.ruoyi.account.api.factory.AppUserFallbackFactory; +import com.ruoyi.account.api.model.TAppUser; +import com.ruoyi.account.api.model.TAppUserCar; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import io.swagger.annotations.ApiOperation; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 用户车辆服务 + * @author ruoyi + */ +@FeignClient(contextId = "AppUserCarClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = AppUserCarFallbackFactory.class) +public interface AppUserCarClient { + + /** + * 根据用户车辆id查询车辆信息 + * @param carIds 车辆id集合 + * @return + */ + @PostMapping(value = "/t-app-user-car/getCarByIds") + public R<List<TAppUserCar>> getCarByIds(@RequestBody List<Integer> carIds); +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java index a4ffe85..931d00a 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java @@ -1,11 +1,14 @@ package com.ruoyi.account.api.feignClient; +import com.ruoyi.account.api.model.TAppUser; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.account.api.factory.AppUserFallbackFactory; import com.ruoyi.common.core.domain.R; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -14,10 +17,26 @@ * 用户服务 * @author ruoyi */ -@FeignClient(contextId = "AppUserClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = AppUserFallbackFactory.class) +@FeignClient(contextId = "AppUserClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = AppUserFallbackFactory.class) public interface AppUserClient { @ApiOperation(value = "管理后台-根据手机号查询用户ids", tags = {"管理后台-活动费用统计"}) @PostMapping(value = "/t-app-user/user/getUserIdsByPhone") public R<List<Long>> getUserIdsByPhone(@RequestParam("phone") String phone); + /** + * 根据用户id查询用户信息 + * @param appUserIds 用户id集合 + * @return + */ + @PostMapping(value = "/t-app-user/user/getUserByIds") + public R<List<TAppUser>> getUserByIds(@RequestBody List<Long> appUserIds); + + + /** + * 根据id获取用户 + * @param id + * @return + */ + @GetMapping(value = "/user/getUserById") + R<TAppUser> getUserById(Long id); } diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ParkingLotFallbackFactory.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ParkingLotFallbackFactory.java new file mode 100644 index 0000000..20090c6 --- /dev/null +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ParkingLotFallbackFactory.java @@ -0,0 +1,36 @@ +package com.ruoyi.chargingPile.api.factory; + +import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; +import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient; +import com.ruoyi.chargingPile.api.model.TChargingPile; +import com.ruoyi.chargingPile.api.model.TParkingLot; +import com.ruoyi.common.core.domain.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 停车场服务降级处理 + * + * @author ruoyi + */ +@Component +public class ParkingLotFallbackFactory implements FallbackFactory<ParkingLotClient> +{ + private static final Logger log = LoggerFactory.getLogger(ParkingLotFallbackFactory.class); + + @Override + public ParkingLotClient create(Throwable throwable) { + log.error("停车场调用失败:{}", throwable.getMessage()); + return new ParkingLotClient() { + + @Override + public R<TParkingLot> getLotBySiteId(Integer siteId) { + return R.fail("通过站点id查询停车场信息调用失败:" + throwable.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/SiteFallbackFactory.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/SiteFallbackFactory.java new file mode 100644 index 0000000..106e23b --- /dev/null +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/SiteFallbackFactory.java @@ -0,0 +1,34 @@ +package com.ruoyi.chargingPile.api.factory; + +import com.ruoyi.chargingPile.api.feignClient.SiteClient; +import com.ruoyi.chargingPile.api.model.Site; +import com.ruoyi.common.core.domain.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 充电桩服务降级处理 + * + * @author ruoyi + */ +@Component +public class SiteFallbackFactory implements FallbackFactory<SiteClient> +{ + private static final Logger log = LoggerFactory.getLogger(SiteFallbackFactory.class); + + @Override + public SiteClient create(Throwable throwable) { + log.error("站点调用失败:{}", throwable.getMessage()); + return new SiteClient() { + + @Override + public R<List<Site>> getSiteByIds(List<Integer> ids) { + return R.fail("根据id集合获取站点数据调用失败:" + throwable.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java index 35f0bbb..024bd8a 100644 --- a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java @@ -15,7 +15,7 @@ * 充电桩服务 * @author ruoyi */ -@FeignClient(contextId = "ChargingPileClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = ChargingPileFallbackFactory.class) +@FeignClient(contextId = "ChargingPileClient", value = ServiceNameConstants.CHARGINGPILE_SERVICE, fallbackFactory = ChargingPileFallbackFactory.class) public interface ChargingPileClient { /** diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ParkingLotClient.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ParkingLotClient.java new file mode 100644 index 0000000..0312dd8 --- /dev/null +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ParkingLotClient.java @@ -0,0 +1,29 @@ +package com.ruoyi.chargingPile.api.feignClient; + +import com.ruoyi.chargingPile.api.factory.ParkingLotFallbackFactory; +import com.ruoyi.chargingPile.api.model.TChargingPile; +import com.ruoyi.chargingPile.api.model.TParkingLot; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import io.swagger.annotations.ApiOperation; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 停车场服务 + * @author ruoyi + */ +@FeignClient(contextId = "ParkingLotClient", value = ServiceNameConstants.CHARGINGPILE_SERVICE, fallbackFactory = ParkingLotFallbackFactory.class) +public interface ParkingLotClient { + + /** + * 通过站点id查询停车场信息 + */ + @GetMapping(value = "/t-parking-lot/getLotBySiteId") + public R<TParkingLot> getLotBySiteId(@RequestParam("siteId") Integer siteId); + +} diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/SiteClient.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/SiteClient.java new file mode 100644 index 0000000..ecedc5b --- /dev/null +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/SiteClient.java @@ -0,0 +1,27 @@ +package com.ruoyi.chargingPile.api.feignClient; + +import com.ruoyi.chargingPile.api.factory.SiteFallbackFactory; +import com.ruoyi.chargingPile.api.model.Site; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/8/10 14:38 + */ +@FeignClient(contextId = "SiteClient", value = ServiceNameConstants.CHARGINGPILE_SERVICE, fallbackFactory = SiteFallbackFactory.class) +public interface SiteClient { + + /** + * 根据id集合获取数据 + * @param ids + * @return + */ + @PostMapping("/site/getSiteByIds") + R<List<Site>> getSiteByIds(@RequestBody List<Integer> ids); +} diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPileNotification.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPileNotification.java index 3fd2438..23a5d14 100644 --- a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPileNotification.java +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPileNotification.java @@ -35,10 +35,18 @@ @ApiModelProperty(value = "站点id") @TableField("site_id") private Integer siteId; + + @ApiModelProperty(value = "站点名称") + @TableField(exist = false) + private String siteName; @ApiModelProperty(value = "充电桩id") @TableField("charging_pile_id") private Integer chargingPileId; + + @ApiModelProperty(value = "通知电话") + @TableField("phone") + private String phone; @ApiModelProperty(value = "通知内容") @TableField("content") diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/StrategyPriceVO.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/StrategyPriceVO.java new file mode 100644 index 0000000..2c026bc --- /dev/null +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/StrategyPriceVO.java @@ -0,0 +1,26 @@ +package com.ruoyi.chargingPile.api.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@ApiModel(value = "StrategyPriceVO对象",description = "价格说明金额返回,会员开通金额说明") +public class StrategyPriceVO implements Serializable { + + @ApiModelProperty(value = "优惠金额") + private BigDecimal discountAmount; + + @ApiModelProperty(value = "最高优惠金额") + private BigDecimal maxDiscountAmount; + + @ApiModelProperty(value = "会员起步价") + private BigDecimal vipStartPrice; + + @ApiModelProperty(value = "服务费折扣") + private BigDecimal serviceFeeDiscount; + +} diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-chargingPile/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index e4d9cf2..7d5f8b3 100644 --- a/ruoyi-api/ruoyi-api-chargingPile/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,2 @@ -com.ruoyi.chargingPile.api.factory.ChargingPileFallbackFactory \ No newline at end of file +com.ruoyi.chargingPile.api.factory.ChargingPileFallbackFactory +com.ruoyi.chargingPile.api.factory.SiteFallbackFactory \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/ChargingPileClient.java b/ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/ChargingPileClient.java index 462bc13..c7c1277 100644 --- a/ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/ChargingPileClient.java +++ b/ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/ChargingPileClient.java @@ -8,7 +8,7 @@ * 充电订单服务 * @author ruoyi */ -@FeignClient(contextId = "ChargingPileClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = ChargingPileFallbackFactory.class) +@FeignClient(contextId = "ChargingPileClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = ChargingPileFallbackFactory.class) public interface ChargingPileClient { diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java index 6a48e86..6fcf8eb 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java @@ -12,7 +12,7 @@ * 充电订单服务 * @author ruoyi */ -@FeignClient(contextId = "ChargingOrderClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = ChargingOrderFallbackFactory.class) +@FeignClient(contextId = "ChargingOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = ChargingOrderFallbackFactory.class) public interface ChargingOrderClient { @PostMapping(value = "/t-charging-order/useOrderCount") R<Long> useOrderCount(@RequestParam Long userId); diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ExchangeOrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ExchangeOrderClient.java index ac22284..d690334 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ExchangeOrderClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ExchangeOrderClient.java @@ -14,7 +14,7 @@ * 充电订单服务 * @author ruoyi */ -@FeignClient(contextId = "ChargingOrderClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = ExchangeOrderFallbackFactory.class) +@FeignClient(contextId = "ChargingOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = ExchangeOrderFallbackFactory.class) public interface ExchangeOrderClient { diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java index eff0890..c00f97c 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java @@ -16,7 +16,7 @@ * 后台订单服务 * @author ruoyi */ -@FeignClient(contextId = "OrderClient", value = ServiceNameConstants.CONTRACT_ORDER, fallbackFactory = OrderFallbackFactory.class) +@FeignClient(contextId = "OrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderFallbackFactory.class) public interface OrderClient { @PostMapping("/t-exchange-order/getSalesCountByGoodsIds") diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java index a48b136..3f36bcb 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java @@ -52,6 +52,10 @@ @TableField("app_user_car_id") private Integer appUserCarId; + @ApiModelProperty(value = "站点 id") + @TableField("site_id") + private Integer siteId; + @ApiModelProperty(value = "停车场id") @TableField("parking_lot_id") private Integer parkingLotId; diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TOrderEvaluate.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TOrderEvaluate.java index 8222276..c44dd0e 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TOrderEvaluate.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TOrderEvaluate.java @@ -43,6 +43,10 @@ @TableField("app_user_id") private Long appUserId; + @ApiModelProperty(value = "充电车辆 id") + @TableField("app_user_car_id") + private Integer appUserCarId; + @ApiModelProperty(value = "评分") @TableField("mark") private Integer mark; diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/query/TOrderEvaluateQuery.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/query/TOrderEvaluateQuery.java new file mode 100644 index 0000000..baa8356 --- /dev/null +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/query/TOrderEvaluateQuery.java @@ -0,0 +1,26 @@ +package com.ruoyi.order.api.query; + +import com.ruoyi.common.core.web.page.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "TOrderEvaluateQuery对象",description = "订单评价查询条件") +public class TOrderEvaluateQuery extends BasePage { + + @ApiModelProperty(value = "站点id") + private Integer siteId; + + @ApiModelProperty(value = "订单id集合 前端忽略") + private List<Long> orderIds; + + @ApiModelProperty(value = "标签类型 1=最新 2=有图 3=好评 4=中差评 5=其他") + private Integer tagType; + + @ApiModelProperty(value = "标签id 标签类型为5时传输此字段") + private Integer tagId; + +} diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/SiteDetailEvaluateVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/SiteDetailEvaluateVO.java new file mode 100644 index 0000000..75770da --- /dev/null +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/SiteDetailEvaluateVO.java @@ -0,0 +1,24 @@ +package com.ruoyi.order.api.vo; + +import com.ruoyi.order.api.model.TOrderEvaluate; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +@ApiModel(value = "SiteDetailEvaluateVO对象",description = "站点详情订单评价") +public class SiteDetailEvaluateVO extends TOrderEvaluate { + + @ApiModelProperty(value = "好评率") + private BigDecimal reviewRate; + + @ApiModelProperty(value = "评价数") + private Integer evaluateCount; + + @ApiModelProperty(value = "评价列表取三条") + private List<TOrderEvaluateVO> orderEvaluateVOS; + +} diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TOrderEvaluateVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TOrderEvaluateVO.java new file mode 100644 index 0000000..769dd96 --- /dev/null +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TOrderEvaluateVO.java @@ -0,0 +1,27 @@ +package com.ruoyi.order.api.vo; + +import com.ruoyi.order.api.model.TOrderEvaluate; +import com.ruoyi.order.api.model.TOrderEvaluateTag; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "TOrderEvaluateVO对象",description = "订单评价") +public class TOrderEvaluateVO extends TOrderEvaluate { + + @ApiModelProperty(value = "用户") + private String name; + + @ApiModelProperty(value = "头像") + private String avatar; + + @ApiModelProperty(value = "车辆品牌名称") + private String carName; + + @ApiModelProperty(value = "评价标签列表") + private List<TOrderEvaluateTag> orderEvaluateTags; + +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java index f25f364..bad9133 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -40,7 +41,7 @@ @ApiModelProperty(value = "月卡价格") @TableField("monthly_card") - private Double monthlyCard; + private BigDecimal monthlyCard; @ApiModelProperty(value = "月卡显示(0=否,1=是)") @TableField("monthly_card_reveal") @@ -48,7 +49,7 @@ @ApiModelProperty(value = "月卡折扣") @TableField("monthly_card_discount") - private Double monthlyCardDiscount; + private BigDecimal monthlyCardDiscount; @ApiModelProperty(value = "月卡折扣开始时间") @TableField("monthly_card_discount_start") @@ -64,7 +65,7 @@ @ApiModelProperty(value = "季卡价格") @TableField("season_card") - private Double seasonCard; + private BigDecimal seasonCard; @ApiModelProperty(value = "季卡显示(0=否,1=是)") @TableField("season_card_reveal") @@ -72,7 +73,7 @@ @ApiModelProperty(value = "季卡折扣") @TableField("season_card_discount") - private Double seasonCardDiscount; + private BigDecimal seasonCardDiscount; @ApiModelProperty(value = "季卡折扣开始时间") @TableField("season_card_discount_start") @@ -88,7 +89,7 @@ @ApiModelProperty(value = "年卡价格") @TableField("annual_card") - private Double annualCard; + private BigDecimal annualCard; @ApiModelProperty(value = "年卡显示(0=否,1=是)") @TableField("annual_card_reveal") @@ -96,7 +97,7 @@ @ApiModelProperty(value = "年卡折扣") @TableField("annual_card_discount") - private Double annualCardDiscount; + private BigDecimal annualCardDiscount; @ApiModelProperty(value = "年卡折扣开始时间") @TableField("annual_card_discount_start") @@ -116,7 +117,7 @@ @ApiModelProperty(value = "最高抵扣金额") @TableField("maximum_deduction") - private Double maximumDeduction; + private BigDecimal maximumDeduction; @ApiModelProperty(value = "抵扣类型(1=服务费)") @TableField("deduction_type") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RoleSiteFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RoleSiteFallbackFactory.java index 2fd74a2..c2e0853 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RoleSiteFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RoleSiteFallbackFactory.java @@ -1,6 +1,7 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TRoleSite; import com.ruoyi.other.api.feignClient.RoleSiteClient; import com.ruoyi.other.api.feignClient.UserSiteClient; import org.slf4j.Logger; @@ -28,6 +29,16 @@ public R<List<Integer>> getSiteIds(Long roleId) { return R.fail("获取角色站点失败:" + throwable.getMessage()); } + + @Override + public R addRoleSite(List<TRoleSite> roleSites) { + return R.fail("添加角色站点失败:" + throwable.getMessage()); + } + + @Override + public R delRoleSite(Long roleId) { + return R.fail("删除角色站点失败:" + throwable.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TEvaluationTagFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TEvaluationTagFallbackFactory.java new file mode 100644 index 0000000..7bc1399 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TEvaluationTagFallbackFactory.java @@ -0,0 +1,40 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.feignClient.RoleSiteClient; +import com.ruoyi.other.api.feignClient.TEvaluationTagClient; +import com.ruoyi.other.api.vo.TEvaluationTagVO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 评价标签服务降级处理 + * + * @author ruoyi + */ +@Component +public class TEvaluationTagFallbackFactory implements FallbackFactory<TEvaluationTagClient> { + private static final Logger log = LoggerFactory.getLogger(TEvaluationTagFallbackFactory.class); + + @Override + public TEvaluationTagClient create(Throwable throwable) { + log.error("调用失败:{}", throwable.getMessage()); + return new TEvaluationTagClient() { + + @Override + public R<List<TEvaluationTagVO>> getTagList(Integer type) { + return R.fail("获取标签列表:" + throwable.getMessage()); + } + + @Override + public R<List<TEvaluationTag>> getListByIds(List<Integer> tagIds) { + return R.fail("根据id集合获取数据失败:" + throwable.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/UserSiteFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/UserSiteFallbackFactory.java index 8b5c1d9..7e63bb3 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/UserSiteFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/UserSiteFallbackFactory.java @@ -1,6 +1,7 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TUserSite; import com.ruoyi.other.api.feignClient.UserSiteClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,6 +28,16 @@ public R<List<Integer>> getSiteIds(Long userId) { return R.fail("获取用户站点失败:" + throwable.getMessage()); } + + @Override + public R addUserSite(List<TUserSite> userSite) { + return R.fail("添加用户站点失败:" + throwable.getMessage()); + } + + @Override + public R delUserSite(Long userId) { + return R.fail("删除用户站点失败:" + throwable.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java new file mode 100644 index 0000000..0965d9a --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java @@ -0,0 +1,33 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TVip; +import com.ruoyi.other.api.feignClient.VipClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 会员服务降级处理 + * + * @author ruoyi + */ +@Component +public class VipFallbackFactory implements FallbackFactory<VipClient> +{ + private static final Logger log = LoggerFactory.getLogger(VipFallbackFactory.class); + + @Override + public VipClient create(Throwable throwable) { + log.error("会员调用失败:{}", throwable.getMessage()); + return new VipClient() { + + @Override + public R<TVip> getVipInfoByType(Integer type) { + return R.fail("获取最高抵扣、最低起步价,最高折扣的会员失败:" + throwable.getMessage()); + + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java index c4e9382..d07fd62 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java @@ -21,7 +21,7 @@ * 商品服务 * @author ruoyi */ -@FeignClient(contextId = "UnitClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = OtherFallbackFactory.class) +@FeignClient(contextId = "UnitClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = OtherFallbackFactory.class) public interface OtherClient { //单位分页 @PostMapping(value = "/t-company/unit/page") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RoleSiteClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RoleSiteClient.java index 55cd966..e4dc369 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RoleSiteClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RoleSiteClient.java @@ -2,10 +2,13 @@ import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TRoleSite; import com.ruoyi.other.api.factory.RoleSiteFallbackFactory; import com.ruoyi.other.api.factory.UserSiteFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -14,7 +17,7 @@ * @author zhibing.pu * @Date 2024/8/9 18:14 */ -@FeignClient(contextId = "RoleSiteClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = RoleSiteFallbackFactory.class) +@FeignClient(contextId = "RoleSiteClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = RoleSiteFallbackFactory.class) public interface RoleSiteClient { @@ -23,6 +26,23 @@ * @param roleId * @return */ - @GetMapping("/t-user-site/getSiteIds") - R<List<Integer>> getSiteIds(@RequestParam("roleId") Long roleId); + @GetMapping("/t-role-site/getSiteIds") + R<List<Integer>> getSiteIds(Long roleId); + + + /** + * 添加角色站点数据 + * @param roleSites + * @return + */ + @PostMapping("/t-role-site/addRoleSite") + R addRoleSite(List<TRoleSite> roleSites); + + /** + * 删除角色站点数据 + * @param roleId + * @return + */ + @DeleteMapping("/t-role-site/delRoleSite") + R delRoleSite(Long roleId); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TEvaluationTagClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TEvaluationTagClient.java new file mode 100644 index 0000000..4d7e87a --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TEvaluationTagClient.java @@ -0,0 +1,38 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.factory.RoleSiteFallbackFactory; +import com.ruoyi.other.api.vo.TEvaluationTagVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/8/9 18:14 + */ +@FeignClient(contextId = "TEvaluationTagClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = RoleSiteFallbackFactory.class) +public interface TEvaluationTagClient { + + + /** + * 获取标签列表 + * @return + */ + @PostMapping("/t-evaluation-tag/getTagList") + R<List<TEvaluationTagVO>> getTagList(Integer type); + + + /** + * 根据id集合获取数据 + * @param tagIds + * @return + */ + @GetMapping("/t-evaluation-tag/getListByIds") + R<List<TEvaluationTag>> getListByIds(List<Integer> tagIds); +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/UserSiteClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/UserSiteClient.java index 57d0450..4cd3910 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/UserSiteClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/UserSiteClient.java @@ -2,9 +2,13 @@ import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TUserSite; import com.ruoyi.other.api.factory.UserSiteFallbackFactory; +import org.apache.ibatis.annotations.Delete; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -13,7 +17,7 @@ * @author zhibing.pu * @Date 2024/8/9 18:14 */ -@FeignClient(contextId = "UserSiteClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = UserSiteFallbackFactory.class) +@FeignClient(contextId = "UserSiteClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = UserSiteFallbackFactory.class) public interface UserSiteClient { @@ -23,5 +27,23 @@ * @return */ @GetMapping("/t-user-site/getSiteIds") - R<List<Integer>> getSiteIds(@RequestParam("userId") Long userId); + R<List<Integer>> getSiteIds(Long userId); + + + /** + * 添加用户站点关系数据 + * @param userSite + * @return + */ + @PostMapping("/t-user-site/getSiteIds") + R addUserSite(List<TUserSite> userSite); + + + /** + * 删除用户站点数据 + * @param userId + * @return + */ + @DeleteMapping("/t-user-site/delUserSite") + R delUserSite(Long userId); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java new file mode 100644 index 0000000..b1a8126 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java @@ -0,0 +1,27 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TVip; +import com.ruoyi.other.api.factory.VipFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * 会员服务 + * @author ruoyi + */ +@FeignClient(contextId = "VipClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = VipFallbackFactory.class) +public interface VipClient { + + /** + * 获取最高抵扣、最低起步价,最高折扣的会员 + * @param type 1=最高抵扣、2=最低起步价,3=最高折扣 + * @return + */ + @PostMapping(value = "/vip/getVipInfoByType") + R<TVip> getVipInfoByType(@RequestParam Integer type); + + +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/TEvaluationTagVO.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/TEvaluationTagVO.java new file mode 100644 index 0000000..49e0e4a --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/TEvaluationTagVO.java @@ -0,0 +1,15 @@ +package com.ruoyi.other.api.vo; + +import com.ruoyi.other.api.domain.TEvaluationTag; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "TEvaluationTagVO对象", description = "评价标签") +public class TEvaluationTagVO extends TEvaluationTag{ + + @ApiModelProperty(value = "评价标签数量") + private Integer tagCount; + +} diff --git a/ruoyi-api/ruoyi-api-payment/src/main/java/com/ruoyi/payment/api/feignClient/ChargingOrderClient.java b/ruoyi-api/ruoyi-api-payment/src/main/java/com/ruoyi/payment/api/feignClient/ChargingOrderClient.java index 628318d..d9f4240 100644 --- a/ruoyi-api/ruoyi-api-payment/src/main/java/com/ruoyi/payment/api/feignClient/ChargingOrderClient.java +++ b/ruoyi-api/ruoyi-api-payment/src/main/java/com/ruoyi/payment/api/feignClient/ChargingOrderClient.java @@ -8,7 +8,7 @@ * 充电订单服务 * @author ruoyi */ -@FeignClient(contextId = "ChargingOrderClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = ChargingOrderFallbackFactory.class) +@FeignClient(contextId = "ChargingOrderClient", value = ServiceNameConstants.PAYMENT_SERVICE, fallbackFactory = ChargingOrderFallbackFactory.class) public interface ChargingOrderClient { diff --git a/ruoyi-api/ruoyi-api-system/pom.xml b/ruoyi-api/ruoyi-api-system/pom.xml index a9f9845..723a3c0 100644 --- a/ruoyi-api/ruoyi-api-system/pom.xml +++ b/ruoyi-api/ruoyi-api-system/pom.xml @@ -28,7 +28,13 @@ </exclusion> </exclusions> </dependency> - + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>ruoyi-modules-system</artifactId> + <version>3.6.2</version> + <scope>compile</scope> + </dependency> + </dependencies> </project> \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java index 525eda3..dc247b3 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java @@ -28,14 +28,5 @@ */ @PostMapping("/operlog") public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception; - - /** - * 保存访问记录 - * - * @param sysLogininfor 访问实体 - * @param source 请求来源 - * @return 结果 - */ - @PostMapping("/logininfor") - public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java index a3c350f..1e04af6 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java @@ -1,6 +1,7 @@ package com.ruoyi.system.api.domain; import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel.ColumnType; @@ -8,248 +9,247 @@ /** * 操作日志记录表 oper_log - * + * * @author ruoyi */ -public class SysOperLog extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 日志主键 */ - @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) - private Long operId; - - /** 操作模块 */ - @Excel(name = "操作模块") - private String title; - - /** 业务类型(0其它 1新增 2修改 3删除) */ - @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") - private Integer businessType; - - /** 业务类型数组 */ - private Integer[] businessTypes; - - /** 请求方法 */ - @Excel(name = "请求方法") - private String method; - - /** 请求方式 */ - @Excel(name = "请求方式") - private String requestMethod; - - /** 操作类别(0其它 1后台用户 2手机端用户) */ - @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") - private Integer operatorType; - - /** 操作人员 */ - @Excel(name = "操作人员") - private String operName; - - /** 部门名称 */ - @Excel(name = "部门名称") - private String deptName; - - /** 请求url */ - @Excel(name = "请求地址") - private String operUrl; - - /** 操作地址 */ - @Excel(name = "操作地址") - private String operIp; - - /** 请求参数 */ - @Excel(name = "请求参数") - private String operParam; - - /** 返回参数 */ - @Excel(name = "返回参数") - private String jsonResult; - - /** 操作状态(0正常 1异常) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=异常") - private Integer status; - - /** 错误消息 */ - @Excel(name = "错误消息") - private String errorMsg; - - /** 操作时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") - private Date operTime; - - /** 消耗时间 */ - @Excel(name = "消耗时间", suffix = "毫秒") - private Long costTime; - - public Long getOperId() - { - return operId; - } - - public void setOperId(Long operId) - { - this.operId = operId; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Integer getBusinessType() - { - return businessType; - } - - public void setBusinessType(Integer businessType) - { - this.businessType = businessType; - } - - public Integer[] getBusinessTypes() - { - return businessTypes; - } - - public void setBusinessTypes(Integer[] businessTypes) - { - this.businessTypes = businessTypes; - } - - public String getMethod() - { - return method; - } - - public void setMethod(String method) - { - this.method = method; - } - - public String getRequestMethod() - { - return requestMethod; - } - - public void setRequestMethod(String requestMethod) - { - this.requestMethod = requestMethod; - } - - public Integer getOperatorType() - { - return operatorType; - } - - public void setOperatorType(Integer operatorType) - { - this.operatorType = operatorType; - } - - public String getOperName() - { - return operName; - } - - public void setOperName(String operName) - { - this.operName = operName; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public String getOperUrl() - { - return operUrl; - } - - public void setOperUrl(String operUrl) - { - this.operUrl = operUrl; - } - - public String getOperIp() - { - return operIp; - } - - public void setOperIp(String operIp) - { - this.operIp = operIp; - } - - public String getOperParam() - { - return operParam; - } - - public void setOperParam(String operParam) - { - this.operParam = operParam; - } - - public String getJsonResult() - { - return jsonResult; - } - - public void setJsonResult(String jsonResult) - { - this.jsonResult = jsonResult; - } - - public Integer getStatus() - { - return status; - } - - public void setStatus(Integer status) - { - this.status = status; - } - - public String getErrorMsg() - { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) - { - this.errorMsg = errorMsg; - } - - public Date getOperTime() - { - return operTime; - } - - public void setOperTime(Date operTime) - { - this.operTime = operTime; - } - - public Long getCostTime() - { - return costTime; - } - - public void setCostTime(Long costTime) - { - this.costTime = costTime; - } +public class SysOperLog extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 日志主键 + */ + @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) + private Long operId; + + /** + * 操作模块 + */ + @Excel(name = "操作模块") + private String title; + + /** + * 业务类型(0其它 1新增 2修改 3删除) + */ + @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") + private Integer businessType; + + /** + * 业务类型数组 + */ + private Integer[] businessTypes; + + /** + * 请求方法 + */ + @Excel(name = "请求方法") + private String method; + + /** + * 请求方式 + */ + @Excel(name = "请求方式") + private String requestMethod; + + /** + * 操作类别(0其它 1后台用户 2手机端用户) + */ + @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") + private Integer operatorType; + + /** + * 操作人员 + */ + @Excel(name = "操作人员") + private String operName; + + /** + * 部门名称 + */ + @Excel(name = "部门名称") + private String deptName; + + /** + * 请求url + */ + @Excel(name = "请求地址") + private String operUrl; + + /** + * 操作地址 + */ + @Excel(name = "操作地址") + private String operIp; + + /** + * 请求参数 + */ + @Excel(name = "请求参数") + private String operParam; + + /** + * 返回参数 + */ + @Excel(name = "返回参数") + private String jsonResult; + + /** + * 操作状态(0正常 1异常) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=异常") + private Integer status; + + /** + * 错误消息 + */ + @Excel(name = "错误消息") + private String errorMsg; + + /** + * 操作时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date operTime; + + /** + * 消耗时间 + */ + @Excel(name = "消耗时间", suffix = "毫秒") + private Long costTime; + + public Long getOperId() { + return operId; + } + + public void setOperId(Long operId) { + this.operId = operId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getBusinessType() { + return businessType; + } + + public void setBusinessType(Integer businessType) { + this.businessType = businessType; + } + + public Integer[] getBusinessTypes() { + return businessTypes; + } + + public void setBusinessTypes(Integer[] businessTypes) { + this.businessTypes = businessTypes; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getRequestMethod() { + return requestMethod; + } + + public void setRequestMethod(String requestMethod) { + this.requestMethod = requestMethod; + } + + public Integer getOperatorType() { + return operatorType; + } + + public void setOperatorType(Integer operatorType) { + this.operatorType = operatorType; + } + + public String getOperName() { + return operName; + } + + public void setOperName(String operName) { + this.operName = operName; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public String getOperUrl() { + return operUrl; + } + + public void setOperUrl(String operUrl) { + this.operUrl = operUrl; + } + + public String getOperIp() { + return operIp; + } + + public void setOperIp(String operIp) { + this.operIp = operIp; + } + + public String getOperParam() { + return operParam; + } + + public void setOperParam(String operParam) { + this.operParam = operParam; + } + + public String getJsonResult() { + return jsonResult; + } + + public void setJsonResult(String jsonResult) { + this.jsonResult = jsonResult; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public Date getOperTime() { + return operTime; + } + + public void setOperTime(Date operTime) { + this.operTime = operTime; + } + + public Long getCostTime() { + return costTime; + } + + public void setCostTime(Long costTime) { + this.costTime = costTime; + } } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java index 3602929..ee2f671 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java @@ -1,11 +1,13 @@ package com.ruoyi.system.api.domain; +import java.util.List; import java.util.Set; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; @@ -77,20 +79,9 @@ /** 角色菜单权限 */ @TableField(exist = false) private Set<String> permissions; - - /** 车辆数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限 */ - private Integer carDataAuth; - - /** 车务数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限 */ - private Integer carTrainOperAuth; - - /** 合同数据权限:1=所有数据 2=仅自己负责的合同 3=无数据权限 */ - private Integer contractDataAuth; - - /** 公司id */ - private Integer companyId; - - + @ApiModelProperty(value = "站点名称") + @TableField(exist = false) + private List<String> siteNames; public SysRole() { @@ -100,38 +91,6 @@ public SysRole(Long roleId) { this.roleId = roleId; - } - - public Integer getCarDataAuth() { - return carDataAuth; - } - - public void setCarDataAuth(Integer carDataAuth) { - this.carDataAuth = carDataAuth; - } - - public Integer getCarTrainOperAuth() { - return carTrainOperAuth; - } - - public void setCarTrainOperAuth(Integer carTrainOperAuth) { - this.carTrainOperAuth = carTrainOperAuth; - } - - public Integer getContractDataAuth() { - return contractDataAuth; - } - - public void setContractDataAuth(Integer contractDataAuth) { - this.contractDataAuth = contractDataAuth; - } - - public Integer getCompanyId() { - return companyId; - } - - public void setCompanyId(Integer companyId) { - this.companyId = companyId; } public Long getRoleId() @@ -278,7 +237,15 @@ { this.permissions = permissions; } - + + public List<String> getSiteNames() { + return siteNames; + } + + public void setSiteNames(List<String> siteNames) { + this.siteNames = siteNames; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java index dbebc60..91df803 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java @@ -113,7 +113,7 @@ /** * 角色类型 1=平台 2=公司 3=门店 4=修理厂 */ - @ApiModelProperty(value = "角色类型 1=平台 2=公司 3=门店 4=修理厂") + @ApiModelProperty(value = "角色类型 1=平台 2=合作商") private Integer roleType; @Excel(name = "密码修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) @@ -124,6 +124,20 @@ @ApiModelProperty(value = "备注") private String remark; + + @ApiModelProperty(value = "充电站") + @TableField(exist = false) + private List<String> siteNames; + + @ApiModelProperty(value = "充电站id", required = true) + @TableField(exist = false) + private List<Integer> siteIds; + + @ApiModelProperty(value = "角色") + @TableField(exist = false) + private List<String> roleNames; + + @Override public String getRemark() { @@ -365,6 +379,32 @@ { this.roleId = roleId; } + + + public List<String> getSiteNames() { + return siteNames; + } + + public void setSiteNames(List<String> siteNames) { + this.siteNames = siteNames; + } + + public List<String> getRoleNames() { + return roleNames; + } + + public List<Integer> getSiteIds() { + return siteIds; + } + + public void setSiteIds(List<Integer> siteIds) { + this.siteIds = siteIds; + } + + public void setRoleNames(List<String> roleNames) { + this.roleNames = roleNames; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteLogFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteLogFallbackFactory.java index 6acb505..599d97a 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteLogFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteLogFallbackFactory.java @@ -20,8 +20,7 @@ private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class); @Override - public RemoteLogService create(Throwable throwable) - { + public RemoteLogService create(Throwable throwable) { log.error("日志服务调用失败:{}", throwable.getMessage()); return new RemoteLogService() { @@ -30,12 +29,7 @@ { return null; } - - @Override - public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source) - { - return null; - } + }; } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysLoginLogFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysLoginLogFallbackFactory.java new file mode 100644 index 0000000..df6782c --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysLoginLogFallbackFactory.java @@ -0,0 +1,28 @@ +package com.ruoyi.system.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.api.domain.SysRole; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.feignClient.SysLoginLogClient; +import com.ruoyi.system.api.feignClient.SysUserClient; +import com.ruoyi.system.api.model.*; +import com.ruoyi.system.domain.SysLoginLog; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class SysLoginLogFallbackFactory implements FallbackFactory<SysLoginLogClient> { + @Override + public SysLoginLogClient create(Throwable cause) { + return new SysLoginLogClient(){ + + + @Override + public R saveLoginLog(SysLoginLog loginLog) { + return R.fail("添加登录日志失败!" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysLoginLogClient.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysLoginLogClient.java new file mode 100644 index 0000000..f4283ec --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysLoginLogClient.java @@ -0,0 +1,26 @@ +package com.ruoyi.system.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.api.factory.SysLoginLogFallbackFactory; +import com.ruoyi.system.domain.SysLoginLog; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author zhibing.pu + * @Date 2024/8/12 16:30 + */ +@FeignClient(contextId = "SysLoginLogClient", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = SysLoginLogFallbackFactory.class) +public interface SysLoginLogClient { + + + /** + * 添加登陆日志 + * @param loginLog + * @return + */ + @PostMapping("/saveLoginLog") + R saveLoginLog(@RequestBody SysLoginLog loginLog); +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 7104897..4dfeaf3 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -3,3 +3,4 @@ com.ruoyi.system.api.factory.RemoteFileFallbackFactory com.ruoyi.system.api.factory.SysUserFallbackFactory com.ruoyi.system.api.factory.SysRoleFallbackFactory +com.ruoyi.system.api.factory.SysLoginLogFallbackFactory diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java index 9868d190..85ebf14 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java @@ -1,12 +1,15 @@ package com.ruoyi.auth.controller; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import com.ruoyi.common.core.constant.SecurityConstants; import com.ruoyi.system.api.RemoteUserService; import com.ruoyi.system.api.domain.SysRole; import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.feignClient.SysLoginLogClient; import com.ruoyi.system.api.feignClient.SysUserClient; +import com.ruoyi.system.domain.SysLoginLog; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.DeleteMapping; @@ -24,6 +27,9 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.model.LoginUser; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.time.LocalDateTime; import java.util.*; /** @@ -39,14 +45,18 @@ @Autowired private SysLoginService sysLoginService; - @Autowired + @Resource private SysUserClient userClient; + + + + + @PostMapping("login") - public R<?> login(@RequestBody LoginBody form) - { + public R<?> login(@RequestBody LoginBody form, HttpServletRequest request) { // 用户登录 - LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword()); + LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword(), request); HashMap<String, Object> map = new HashMap<>(); map.put("token",tokenService.createToken(userInfo)); List<SysRole> roles = userInfo.getSysUser().getRoles(); @@ -62,13 +72,15 @@ sysUser.setLoginDate(new Date()); System.out.println("修改用户登录时间"+sysUser); userClient.updateSysUser(sysUser); - // 获取登录token return R.ok(map); } + + + + @DeleteMapping("logout") - public R<?> logout(HttpServletRequest request) - { + public R<?> logout(HttpServletRequest request) { String token = SecurityUtils.getToken(request); if (StringUtils.isNotEmpty(token)) { @@ -76,7 +88,7 @@ // 删除用户缓存记录 AuthUtil.logoutByToken(token); // 记录用户退出日志 - sysLoginService.logout(username); + sysLoginService.logout(username, request); } return R.ok(); } @@ -95,10 +107,10 @@ } @PostMapping("register") - public R<?> register(@RequestBody RegisterBody registerBody) + public R<?> register(@RequestBody RegisterBody registerBody, HttpServletRequest request) { // 用户注册 - sysLoginService.register(registerBody.getUsername(), registerBody.getPassword()); + sysLoginService.register(registerBody.getUsername(), registerBody.getPassword(), request); return R.ok(); } } diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java index 431c264..acfab13 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java @@ -1,5 +1,6 @@ package com.ruoyi.auth.service; +import com.ruoyi.system.domain.SysLoginLog; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.ruoyi.common.core.constant.CacheConstants; @@ -17,6 +18,9 @@ import com.ruoyi.system.api.RemoteUserService; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.model.LoginUser; + +import javax.servlet.http.HttpServletRequest; +import java.time.LocalDateTime; /** * 登录校验方法 @@ -41,42 +45,44 @@ /** * 登录 */ - public LoginUser login(String username, String password) - { + public LoginUser login(String username, String password, HttpServletRequest request) { + // 查询用户信息 + R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); + + if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) + { + recordLogService.recordLogininfor(request, null, username, Constants.LOGIN_FAIL_STATUS, "登录用户不存在"); + throw new ServiceException("登录用户:" + username + " 不存在"); + } + LoginUser userInfo = userResult.getData(); + SysUser user = userResult.getData().getSysUser(); + // 用户名或密码为空 错误 if (StringUtils.isAnyBlank(username, password)) { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户/密码必须填写"); throw new ServiceException("用户/密码必须填写"); } // 密码如果不在指定范围内 错误 if (password.length() < UserConstants.PASSWORD_MIN_LENGTH || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户密码不在指定范围"); throw new ServiceException("用户密码不在指定范围"); } // 用户名不在指定范围内 错误 if (username.length() < UserConstants.USERNAME_MIN_LENGTH || username.length() > UserConstants.USERNAME_MAX_LENGTH) { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户名不在指定范围"); throw new ServiceException("用户名不在指定范围"); } // IP黑名单校验 String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单"); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "很遗憾,访问IP已被列入系统黑名单"); throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); - } - // 查询用户信息 - R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); - - if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) - { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); - throw new ServiceException("登录用户:" + username + " 不存在"); } if (R.FAIL == userResult.getCode()) @@ -84,32 +90,31 @@ throw new ServiceException(userResult.getMsg()); } - LoginUser userInfo = userResult.getData(); - SysUser user = userResult.getData().getSysUser(); + if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "对不起,您的账号已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); } if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员"); throw new ServiceException("对不起,您的账号:" + username + " 已停用"); } - passwordService.validate(user, password); - recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); + passwordService.validate(user, password, request); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_SUCCESS_STATUS, "登录成功"); return userInfo; } - public void logout(String loginName) + public void logout(String loginName, HttpServletRequest request) { - recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功"); + recordLogService.recordLogininfor(request, null, loginName, Constants.LOGIN_SUCCESS_STATUS, "退出成功"); } /** * 注册 */ - public void register(String username, String password) + public void register(String username, String password, HttpServletRequest request) { // 用户名或密码为空 错误 if (StringUtils.isAnyBlank(username, password)) @@ -138,6 +143,6 @@ { throw new ServiceException(registerResult.getMsg()); } - recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); + recordLogService.recordLogininfor(request, sysUser.getUserId().intValue(), username, Constants.LOGIN_SUCCESS_STATUS, "注册成功"); } } diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysPasswordService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysPasswordService.java index e00b1a4..1f6a419 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysPasswordService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysPasswordService.java @@ -10,6 +10,8 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.SysUser; +import javax.servlet.http.HttpServletRequest; + /** * 登录密码方法 * @@ -39,7 +41,7 @@ return CacheConstants.PWD_ERR_CNT_KEY + username; } - public void validate(SysUser user, String password) + public void validate(SysUser user, String password, HttpServletRequest request) { String username = user.getUserName(); @@ -53,14 +55,14 @@ if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) { String errMsg = String.format("密码输入错误%s次,帐户锁定%s分钟", maxRetryCount, lockTime); - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL,errMsg); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS,errMsg); throw new ServiceException(errMsg); } if (!matches(user, password)) { retryCount = retryCount + 1; - recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, String.format("密码输入错误%s次", retryCount)); + recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, String.format("密码输入错误%s次", retryCount)); redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); throw new ServiceException("密码错误"); } diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java index 7ca0f00..c4230d8 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java @@ -1,48 +1,134 @@ package com.ruoyi.auth.service; -import org.springframework.beans.factory.annotation.Autowired; +import com.ruoyi.system.api.feignClient.SysLoginLogClient; +import com.ruoyi.system.domain.SysLoginLog; import org.springframework.stereotype.Component; -import com.ruoyi.common.core.constant.Constants; -import com.ruoyi.common.core.constant.SecurityConstants; -import com.ruoyi.common.core.utils.StringUtils; -import com.ruoyi.common.core.utils.ip.IpUtils; -import com.ruoyi.system.api.RemoteLogService; -import com.ruoyi.system.api.domain.SysLogininfor; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; /** * 记录日志方法 - * + * * @author ruoyi */ @Component -public class SysRecordLogService -{ - @Autowired - private RemoteLogService remoteLogService; - - /** - * 记录登录信息 - * - * @param username 用户名 - * @param status 状态 - * @param message 消息内容 - * @return - */ - public void recordLogininfor(String username, String status, String message) - { - SysLogininfor logininfor = new SysLogininfor(); - logininfor.setUserName(username); - logininfor.setIpaddr(IpUtils.getIpAddr()); - logininfor.setMsg(message); - // 日志状态 - if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) - { - logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS); - } - else if (Constants.LOGIN_FAIL.equals(status)) - { - logininfor.setStatus(Constants.LOGIN_FAIL_STATUS); - } - remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER); - } +public class SysRecordLogService { + @Resource + private SysLoginLogClient sysLoginLogClient; + + /** + * 记录登录信息 + * + * @param username 用户名 + * @param status 状态 + * @param message 消息内容 + * @return + */ + public void recordLogininfor(HttpServletRequest request, Integer userId, String username, String status, String message) { + Map<String, String> headerData = getHeaderData(request); + //添加登录日志 + SysLoginLog loginLog = new SysLoginLog(); + loginLog.setUserId(userId); + loginLog.setUsername(username); + loginLog.setIpAddress(headerData.get("ip")); + loginLog.setAddress("");// todo 待完善 https://www.juhe.cn/docs/api/id/1 + loginLog.setBrowserType(headerData.get("browser")); + loginLog.setOperatingSystem(headerData.get("os")); + loginLog.setLoginTime(LocalDateTime.now()); + loginLog.setLoginStatus(Integer.valueOf(status)); + loginLog.setMessage(message); + sysLoginLogClient.saveLoginLog(loginLog); + } + + + public Map<String, String> getHeaderData(HttpServletRequest request) { + //Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0 + String browserDetails = request.getHeader("User-Agent"); + String userAgent = browserDetails; + String user = userAgent.toLowerCase(); + Map<String, String> map = new HashMap<>(); + String os = ""; + String browser = ""; + if (userAgent.toLowerCase().indexOf("windows") >= 0) { + os = "Windows"; + } else if (userAgent.toLowerCase().indexOf("mac") >= 0) { + os = "Mac"; + } else if (userAgent.toLowerCase().indexOf("x11") >= 0) { + os = "Unix"; + } else if (userAgent.toLowerCase().indexOf("android") >= 0) { + os = "Android"; + } else if (userAgent.toLowerCase().indexOf("iphone") >= 0) { + os = "IPhone"; + } else { + os = "UnKnown, More-Info: " + userAgent; + } + if (user.contains("edge")) { + browser = (userAgent.substring(userAgent.indexOf("Edge")).split(" ")[0]).replace("/", "-"); + } else if (user.contains("msie")) { + String substring = userAgent.substring(userAgent.indexOf("MSIE")).split(";")[0]; + browser = substring.split(" ")[0].replace("MSIE", "IE") + "-" + substring.split(" ")[1]; + } else if (user.contains("safari") && user.contains("version")) { + browser = (userAgent.substring(userAgent.indexOf("Safari")).split(" ")[0]).split("/")[0] + + "-" + (userAgent.substring(userAgent.indexOf("Version")).split(" ")[0]).split("/")[1]; + } else if (user.contains("opr") || user.contains("opera")) { + if (user.contains("opera")) { + browser = (userAgent.substring(userAgent.indexOf("Opera")).split(" ")[0]).split("/")[0] + + "-" + (userAgent.substring(userAgent.indexOf("Version")).split(" ")[0]).split("/")[1]; + } else if (user.contains("opr")) { + browser = ((userAgent.substring(userAgent.indexOf("OPR")).split(" ")[0]).replace("/", "-")) + .replace("OPR", "Opera"); + } + + } else if (user.contains("chrome")) { + browser = (userAgent.substring(userAgent.indexOf("Chrome")).split(" ")[0]).replace("/", "-"); + } else if ((user.indexOf("mozilla/7.0") > -1) || (user.indexOf("netscape6") != -1) || + (user.indexOf("mozilla/4.7") != -1) || (user.indexOf("mozilla/4.78") != -1) || + (user.indexOf("mozilla/4.08") != -1) || (user.indexOf("mozilla/3") != -1)) { + browser = "Netscape-?"; + + } else if (user.contains("firefox")) { + browser = (userAgent.substring(userAgent.indexOf("Firefox")).split(" ")[0]).replace("/", "-"); + } else if (user.contains("rv")) { + String IEVersion = (userAgent.substring(userAgent.indexOf("rv")).split(" ")[0]).replace("rv:", "-"); + browser = "IE" + IEVersion.substring(0, IEVersion.length() - 1); + } else { + browser = "UnKnown, More-Info: " + userAgent; + } + + String ip = request.getHeader("x-forwarded-for"); + if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) { + // 多次反向代理后会有多个ip值,第一个ip才是真实ip + if (ip.indexOf(",") != -1) { + ip = ip.split(",")[0]; + } + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("X-Real-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + map.put("os", os); + map.put("browser", browser); + map.put("ip", ip); + return map; + } + + } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java index b4a5e88..9cb4b54 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java @@ -21,20 +21,10 @@ * 文件服务的serviceid */ public static final String FILE_SERVICE = "ruoyi-file"; - /** - * 后台服务的serviceid - */ - public static final String MANAGEMENT_SERVICE = "ruoyi-management"; - - /** - * 车辆服务的serviceid - */ - public static final String VEHICLE_SERVICE = "ruoyi-vehicle"; - - /** - * 车辆合同的serviceid - */ - public static final String CONTRACT_SERVICE = "ruoyi-contract"; - public static final String CONTRACT_ORDER = "ruoyi-order"; - public static final String CONTRACT_ACCOUNT = "ruoyi-account"; + public static final String ACCOUNT_SERVICE = "ruoyi-account"; + public static final String CHARGINGPILE_SERVICE = "ruoyi-chargingPile"; + public static final String OTHER_SERVICE = "ruoyi-other"; + public static final String ORDER_SERVICE = "ruoyi-order"; + public static final String INTEGRATION_SERVICE = "ruoyi-integration"; + public static final String PAYMENT_SERVICE = "ruoyi-payment"; } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java index 1b48650..d27cec0 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java @@ -16,132 +16,132 @@ /** * Entity基类 - * + * * @author ruoyi */ -public class BaseEntity implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 搜索值 */ - @JsonIgnore - @TableField(exist = false) - private String searchValue; - - /** 创建者 */ - @ApiModelProperty(value = "记录创建人,前端忽略") - @TableField(value = "create_by", fill = FieldFill.INSERT) - private String createBy; - - /** 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField("create_time") - private Date createTime; - - /** 更新者 */ - @ApiModelProperty(value = "记录修改人,前端忽略") - //@JsonIgnore - @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) - private String updateBy; - - /** 更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField("update_time") - private Date updateTime; - - /** 是否删除 1未删除 0已删除 */ - @TableLogic - @Excel(name = "是否删除 0未删除 1已删除") - @TableField(exist = false) - private Boolean disabled; - - /** 备注 */ - private String remark; - - /** 请求参数 */ - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @TableField(exist = false) - private Map<String, Object> params; - - public Boolean getDisabled() { - return disabled; - } - - public void setDisabled(Boolean disabled) { - this.disabled = disabled; - } - - public String getSearchValue() - { - return searchValue; - } - - public void setSearchValue(String searchValue) - { - this.searchValue = searchValue; - } - - public String getCreateBy() - { - return createBy; - } - - public void setCreateBy(String createBy) - { - this.createBy = createBy; - } - - public Date getCreateTime() - { - return createTime; - } - - public void setCreateTime(Date createTime) - { - this.createTime = createTime; - } - - public String getUpdateBy() - { - return updateBy; - } - - public void setUpdateBy(String updateBy) - { - this.updateBy = updateBy; - } - - public Date getUpdateTime() - { - return updateTime; - } - - public void setUpdateTime(Date updateTime) - { - this.updateTime = updateTime; - } - - public String getRemark() - { - return remark; - } - - public void setRemark(String remark) - { - this.remark = remark; - } - - public Map<String, Object> getParams() - { - if (params == null) - { - params = new HashMap<>(); - } - return params; - } - - public void setParams(Map<String, Object> params) - { - this.params = params; - } +public class BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 搜索值 + */ + @JsonIgnore + @TableField(exist = false) + private String searchValue; + + /** + * 创建者 + */ + @ApiModelProperty(value = "记录创建人,前端忽略") + @TableField(value = "create_by", fill = FieldFill.INSERT) + private String createBy; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField("create_time") + private Date createTime; + + /** + * 更新者 + */ + @ApiModelProperty(value = "记录修改人,前端忽略") + //@JsonIgnore + @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) + private String updateBy; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField("update_time") + private Date updateTime; + + /** + * 是否删除 1未删除 0已删除 + */ + @TableLogic + @Excel(name = "是否删除 0未删除 1已删除") + @TableField(exist = false) + private Boolean disabled; + + /** + * 备注 + */ + private String remark; + + /** + * 请求参数 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @TableField(exist = false) + private Map<String, Object> params; + + public Boolean getDisabled() { + return disabled; + } + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + public String getSearchValue() { + return searchValue; + } + + public void setSearchValue(String searchValue) { + this.searchValue = searchValue; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Map<String, Object> getParams() { + if (params == null) { + params = new HashMap<>(); + } + return params; + } + + public void setParams(Map<String, Object> params) { + this.params = params; + } } diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java index 83f2ef6..e44b648 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java @@ -7,23 +7,23 @@ import com.ruoyi.system.api.RemoteLogService; import com.ruoyi.system.api.domain.SysOperLog; +import javax.annotation.Resource; + /** * 异步调用日志服务 * * @author ruoyi */ @Service -public class AsyncLogService -{ - @Autowired +public class AsyncLogService { + @Resource private RemoteLogService remoteLogService; /** * 保存系统日志记录 */ @Async - public void saveSysLog(SysOperLog sysOperLog) throws Exception - { + public void saveSysLog(SysOperLog sysOperLog) throws Exception { remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); } } diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index 3c7a1b4..dd3928c 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -106,6 +106,24 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>ruoyi-api-other</artifactId> + <version>3.6.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>ruoyi-api-chargingPile</artifactId> + <version>3.6.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>io.seata</groupId> + <artifactId>seata-all</artifactId> + <version>1.6.1</version> + <scope>compile</scope> + </dependency> </dependencies> diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLoginLogController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLoginLogController.java new file mode 100644 index 0000000..208c975 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLoginLogController.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.domain.SysLoginLog; +import com.ruoyi.system.service.ISysLoginLogService; +import com.ruoyi.system.service.ISysUserService; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.time.LocalDateTime; + +/** + * @author zhibing.pu + * @Date 2024/8/12 15:48 + */ +@RestController +@RequestMapping("/sysLoginLog") +public class SysLoginLogController { + + + @Resource + private ISysLoginLogService sysLoginLogService; + + @Resource + private ISysUserService sysUserService; + + + + @GetMapping("/pageList") + @ApiOperation(value = "获取登录日志列表", tags = {"管理后台-登录日志"}) + public AjaxResult<PageInfo<SysLoginLog>> pageList(String name, BasePage basePage){ + PageInfo<SysLoginLog> pageInfo = sysLoginLogService.pageList(name, basePage); + return AjaxResult.success(pageInfo); + } + + + @PostMapping("/addLoginLog") + @ApiOperation(value = "添加登录日志", tags = {"管理后台-登录日志"}) + public AjaxResult addLoginLog(@RequestBody SysLoginLog loginLog){ + return sysLoginLogService.addLoginLog(loginLog); + } + + + /** + * 添加登陆日志 + * @param loginLog + * @return + */ + @PostMapping("/saveLoginLog") + public R saveLoginLog(@RequestBody SysLoginLog loginLog){ + loginLog.setCreateTime(LocalDateTime.now()); + loginLog.setDelFlag(0); + sysLoginLogService.save(loginLog); + return R.ok(); + } + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLogininforController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLogininforController.java deleted file mode 100644 index aa116a4..0000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLogininforController.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.ruoyi.system.controller; - -import java.util.List; -import javax.servlet.http.HttpServletResponse; - -import com.ruoyi.system.service.ISysLogininforService; -import org.springframework.beans.factory.annotation.Autowired; -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.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.core.constant.CacheConstants; -import com.ruoyi.common.core.utils.poi.ExcelUtil; -import com.ruoyi.common.core.web.controller.BaseController; -import com.ruoyi.common.core.web.domain.AjaxResult; -import com.ruoyi.common.core.web.page.TableDataInfo; -import com.ruoyi.common.log.annotation.Log; -import com.ruoyi.common.log.enums.BusinessType; -import com.ruoyi.common.redis.service.RedisService; -import com.ruoyi.common.security.annotation.InnerAuth; -import com.ruoyi.common.security.annotation.RequiresPermissions; -import com.ruoyi.system.api.domain.SysLogininfor; - -/** - * 系统访问记录 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/logininfor") -public class SysLogininforController extends BaseController -{ - @Autowired - private ISysLogininforService logininforService; - - @Autowired - private RedisService redisService; - - @RequiresPermissions("system:logininfor:list") - @GetMapping("/list") - public TableDataInfo list(SysLogininfor logininfor) - { - startPage(); - List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); - return getDataTable(list); - } - - @Log(title = "登录日志", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:logininfor:export") - @PostMapping("/export") - public void export(HttpServletResponse response, SysLogininfor logininfor) - { - List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); - ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); - util.exportExcel(response, list, "登录日志"); - } - - @RequiresPermissions("system:logininfor:remove") - @Log(title = "登录日志", businessType = BusinessType.DELETE) - @DeleteMapping("/{infoIds}") - public AjaxResult remove(@PathVariable Long[] infoIds) - { - return toAjax(logininforService.deleteLogininforByIds(infoIds)); - } - - @RequiresPermissions("system:logininfor:remove") - @Log(title = "登录日志", businessType = BusinessType.DELETE) - @DeleteMapping("/clean") - public AjaxResult clean() - { - logininforService.cleanLogininfor(); - return success(); - } - - @RequiresPermissions("system:logininfor:unlock") - @Log(title = "账户解锁", businessType = BusinessType.OTHER) - @GetMapping("/unlock/{userName}") - public AjaxResult unlock(@PathVariable("userName") String userName) - { - redisService.deleteObject(CacheConstants.PWD_ERR_CNT_KEY + userName); - return success(); - } - - @InnerAuth - @PostMapping - public AjaxResult add(@RequestBody SysLogininfor logininfor) - { - return toAjax(logininforService.insertLogininfor(logininfor)); - } -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java index 4a6ec7c..eadb678 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java @@ -1,13 +1,11 @@ package com.ruoyi.system.controller; -import java.util.Iterator; import java.util.List; -import java.util.Objects; import javax.servlet.http.HttpServletResponse; -import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.system.query.SysOperLogQuery; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -21,7 +19,6 @@ import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; -import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.security.annotation.InnerAuth; @@ -31,78 +28,65 @@ /** * 操作日志记录 - * + * * @author ruoyi */ @RestController @RequestMapping("/operlog") -public class SysOperlogController extends BaseController -{ - @Autowired - private ISysOperLogService operLogService; - -// @RequiresPermissions("system:operlog:list") -// @GetMapping("/list") -// public TableDataInfo list(SysOperLog operLog) -// { -// startPage(); -// List<SysOperLog> list = operLogService.selectOperLogList(operLog); -// return getDataTable(list); -// } - - @ApiOperation(value = "当前车辆操作日志查询") - @PostMapping("/list") - public AjaxResult list(@RequestBody SysOperLogQuery query) - { - LambdaQueryWrapper<SysOperLog> wrapper = new LambdaQueryWrapper<>(); - wrapper.like(SysOperLog::getTitle,"车辆管理"); - wrapper.ne(SysOperLog::getBusinessType,1); - List<SysOperLog> list = operLogService.list(wrapper); - Iterator<SysOperLog> iterator = list.iterator(); - while (iterator.hasNext()){ - SysOperLog sysOperLog = iterator.next(); - String operParam = sysOperLog.getOperParam(); - JSONObject jsonObject = JSONObject.parseObject(operParam); - String carId = jsonObject.getString("carId"); - if(StringUtils.isNotEmpty(carId) && Objects.nonNull(query.getCarId()) && !carId.equals(String.valueOf(query.getCarId()))){ - iterator.remove(); - } - } - return AjaxResult.success(list); - } - - - @Log(title = "操作日志", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:operlog:export") - @PostMapping("/export") - public void export(HttpServletResponse response, SysOperLog operLog) - { - List<SysOperLog> list = operLogService.selectOperLogList(operLog); - ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); - util.exportExcel(response, list, "操作日志"); - } - - @Log(title = "操作日志", businessType = BusinessType.DELETE) - @RequiresPermissions("system:operlog:remove") - @DeleteMapping("/{operIds}") - public AjaxResult remove(@PathVariable Long[] operIds) - { - return toAjax(operLogService.deleteOperLogByIds(operIds)); - } - - @RequiresPermissions("system:operlog:remove") - @Log(title = "操作日志", businessType = BusinessType.CLEAN) - @DeleteMapping("/clean") - public AjaxResult clean() - { - operLogService.cleanOperLog(); - return success(); - } - - @InnerAuth - @PostMapping - public AjaxResult add(@RequestBody SysOperLog operLog) - { - return toAjax(operLogService.insertOperlog(operLog)); - } +public class SysOperlogController extends BaseController { + @Autowired + private ISysOperLogService operLogService; + + + @GetMapping("/list") + @ApiOperation(value = "获取操作日志列表", tags = {"管理后台-操作日志"}) + public AjaxResult<PageInfo<SysOperLog>> list(SysOperLogQuery query) { + PageInfo<SysOperLog> pageInfo = new PageInfo(query.getPageCurr(), query.getPageSize()); + LambdaQueryWrapper<SysOperLog> wrapper = new LambdaQueryWrapper<>(); + if(StringUtils.isNotEmpty(query.getOperName())){ + wrapper.like(SysOperLog::getOperName, query.getOperName()); + } + if(StringUtils.isNotEmpty(query.getTitle())){ + wrapper.like(SysOperLog::getTitle, query.getTitle()); + } + if(null != query.getStatus()){ + wrapper.eq(SysOperLog::getStatus, query.getStatus()); + } + if(null != query.getStartTime() && null != query.getEndTime()){ + wrapper.between(SysOperLog::getOperTime, query.getStartTime(), query.getEndTime()); + } + PageInfo<SysOperLog> page = operLogService.page(pageInfo, wrapper); + return AjaxResult.success(page); + } + + + @Log(title = "操作日志", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:operlog:export") + @PostMapping("/export") + public void export(HttpServletResponse response, SysOperLog operLog) { + List<SysOperLog> list = operLogService.selectOperLogList(operLog); + ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); + util.exportExcel(response, list, "操作日志"); + } + + @Log(title = "操作日志", businessType = BusinessType.DELETE) + @RequiresPermissions("system:operlog:remove") + @DeleteMapping("/{operIds}") + public AjaxResult remove(@PathVariable Long[] operIds) { + return toAjax(operLogService.deleteOperLogByIds(operIds)); + } + + @RequiresPermissions("system:operlog:remove") + @Log(title = "操作日志", businessType = BusinessType.CLEAN) + @DeleteMapping("/clean") + public AjaxResult clean() { + operLogService.cleanOperLog(); + return success(); + } + + @InnerAuth + @PostMapping + public AjaxResult add(@RequestBody SysOperLog operLog) { + return toAjax(operLogService.insertOperlog(operLog)); + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java index 59337ac..b22299a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java @@ -12,8 +12,14 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.chargingPile.api.feignClient.SiteClient; +import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.web.page.BasePage; import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TRoleSite; +import com.ruoyi.other.api.feignClient.RoleSiteClient; import com.ruoyi.system.api.model.GetSysRoleByIds; import com.ruoyi.system.domain.SysMenus; import com.ruoyi.system.domain.SysRoleMenu; @@ -27,6 +33,7 @@ import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserRoleService; import com.ruoyi.system.service.ISysUserService; +import io.seata.spring.annotation.GlobalTransactional; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -55,72 +62,75 @@ @Api(tags = "角色模块") public class SysRoleController extends BaseController { - @Autowired + @Resource private ISysRoleService roleService; - @Autowired + @Resource private ISysUserService userService; - @Autowired + @Resource private ISysDeptService deptService; @Resource private SysRoleMenuMapper sysRoleMenuMapper; - @Autowired + @Resource private ISysUserRoleService sysUserRoleService; - @Resource private SysMenuMapper menuMapper; - - @ApiOperation("获取所有角色信息根据公司id") + + @Resource + private RoleSiteClient roleSiteClient; + + @Resource + private SiteClient siteClient; + + + + + @ApiOperation(value = "获取角色列表", tags = {"管理后台-系统用户管理"}) @GetMapping("/list") - public AjaxResult list(Integer companyId) - { - SysRole role = new SysRole(); - role.setCompanyId(companyId); - List<SysRole> list = roleService.selectRoleList(role); + public AjaxResult list() { + List<SysRole> list = roleService.list(new LambdaQueryWrapper<SysRole>().eq(SysRole::getDelFlag, 0).eq(SysRole::getStatus, 0)); return AjaxResult.success(list); } - - - - @ApiOperation("获取所有角色信息根据公司id--分页") + + + + @ResponseBody @GetMapping("/listPage") - public AjaxResult listPage(Integer companyId,int pageNumber,int pageSize) - { - PageInfo<SysRole> pageInfo = new PageInfo<>(pageNumber, pageSize); - - PageInfo<SysRole> page = roleService.page(pageInfo, new LambdaQueryWrapper<SysRole>().eq(SysRole::getCompanyId, companyId).ne(SysRole::getRoleId,20)); + @ApiOperation(value = "获取角色列表", tags = {"管理后台-角色管理"}) + public AjaxResult listPage(String name, BasePage basePage) { + PageInfo<SysRole> pageInfo = new PageInfo<>(basePage.getPageCurr(), basePage.getPageSize()); + LambdaQueryWrapper<SysRole> wrapper = new LambdaQueryWrapper<SysRole>().eq(SysRole::getStatus, 0).eq(SysRole::getDelFlag, 0); + if(StringUtils.isNotEmpty(name)){ + wrapper.like(SysRole::getRoleName, name); + } + + PageInfo<SysRole> page = roleService.page(pageInfo, wrapper.orderByDesc(SysRole::getCreateTime)); + for (SysRole record : page.getRecords()) { + List<Integer> data = roleSiteClient.getSiteIds(record.getRoleId()).getData(); + List<Site> sites = siteClient.getSiteByIds(data).getData(); + List<String> collect = sites.stream().map(Site::getName).collect(Collectors.toList()); + record.setSiteNames(collect); + } return AjaxResult.success(page); } - - - @ApiOperation("角色启用停用") - @GetMapping("/roleStart") - public AjaxResult roleStart(Long roleId) - { - SysRole role = roleService.selectRoleById(roleId); - if(role.getStatus().equals("1")){ - role.setStatus("0"); - }else { - role.setStatus("1"); - } - return AjaxResult.success(roleService.updateRole(role)); - } - - - - @ApiOperation("添加角色") + + + + + @ResponseBody @PostMapping("/roleAdd") + @ApiOperation(value = "添加角色", tags = {"管理后台-角色管理"}) + @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto) { SysRole role = new SysRole(); role.setRoleName(dto.getRoleName()); long count = roleService.count(Wrappers.lambdaQuery(SysRole.class) - .eq(SysRole::getRoleName,dto.getRoleName()) - .eq(SysRole::getCompanyId,dto.getCompanyId())); + .eq(SysRole::getRoleName,dto.getRoleName())); if(count>0){ return AjaxResult.error("角色已存在,请重新输入"); } @@ -130,36 +140,29 @@ } role.setMenuIds(dto.getMenuIds().toArray((new Long[dto.getMenuIds().size()]))); // 添加角色 - role.setCompanyId(dto.getCompanyId()); - role.setCarDataAuth(dto.getCarDataAuth()); - role.setCarTrainOperAuth(dto.getCarTrainOperAuth()); - role.setContractDataAuth(dto.getContractDataAuth()); + role.setRemark(dto.getRemark()); role.setCreateBy(SecurityUtils.getUsername()); role.setCreateTime(new Date()); roleService.insertRole(role); -// ArrayList<SysRoleMenu> sysRoleMenus = new ArrayList<>(); -// List<Long> menuIds = dto.getMenuIds(); -// for (Long menuId : menuIds) { -// SysRoleMenu sysRoleMenu = new SysRoleMenu(); -// sysRoleMenu.setMenuId(menuId); -// sysRoleMenu.setRoleId(role.getRoleId()); -// sysRoleMenus.add(sysRoleMenu); -// } -// sysRoleMenuMapper.batchRoleMenu(sysRoleMenus); + //添加站点权限 + List<TRoleSite> roleSites = new ArrayList<>(); + for (Integer siteId : dto.getSiteIds()) { + TRoleSite roleSite = new TRoleSite(); + roleSite.setRoleId(role.getRoleId().intValue()); + roleSite.setSiteId(siteId); + roleSites.add(roleSite); + } + roleSiteClient.addRoleSite(roleSites); return AjaxResult.success(); } - @ApiOperation("角色详情") @GetMapping("/roleInfo") - public AjaxResult roleInfo( @RequestParam Long id) - { + @ApiOperation(value = "角色详情", tags = {"管理后台-角色管理"}) + public AjaxResult roleInfo( @RequestParam Long id) { SysRole role = roleService.selectRoleById(id); RoleInfoVo roleInfoVo = new RoleInfoVo(); roleInfoVo.setRoleId(role.getRoleId()); - roleInfoVo.setCarDataAuth(role.getCarDataAuth()); - roleInfoVo.setCarTrainOperAuth(role.getCarTrainOperAuth()); - roleInfoVo.setContractDataAuth(role.getContractDataAuth()); roleInfoVo.setRoleName(role.getRoleName()); // 获取当前角色的菜单id List<Long> menusId = sysRoleMenuMapper.selectList(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, id)).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()); @@ -184,66 +187,29 @@ List<SysMenus> collect = s2.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); menus.setChildren(collect); } - roleInfoVo.setMenus(menusId); + roleInfoVo.setRemark(role.getRemark()); + List<Integer> siteIds = roleSiteClient.getSiteIds(role.getRoleId()).getData(); + List<Site> sites = siteClient.getSiteByIds(siteIds).getData(); + List<String> siteNames = sites.stream().map(Site::getName).collect(Collectors.toList()); + roleInfoVo.setSiteNames(siteNames); + roleInfoVo.setSiteIds(siteIds); return AjaxResult.success(roleInfoVo); } - @ApiOperation("用户获取权限菜单") - @GetMapping("/roleInfoFromUserId") - public AjaxResult roleInfoFromUserId( @RequestParam Long userId) - { - SysUserRole one = sysUserRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId)); - Long id =one.getRoleId(); - // 获取当前角色的菜单id - List<Long> menusId = sysRoleMenuMapper.selectList(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, id)).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()); - if(menusId.size()==0){ - return AjaxResult.success(new ArrayList<>()); - } - if(id!=1){ - menusId = menusId.stream().filter(e->e!=1074 && e!=1075 && e!=1193 && e!=1194).collect(Collectors.toList()); - } - //获取当前的权限菜单 - List<SysMenus> all = menuMapper.getAllInIds(menusId); - // 第三级 - List<SysMenus> s3 = all.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); - // 第二级 - List<SysMenus> s2 = all.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); - // 第一级 - List<SysMenus> s1 = all.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); - for (SysMenus menus : s2) { - List<SysMenus> collect = s3.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); - menus.setChildren(collect); - } - - for (SysMenus menus : s1) { - List<SysMenus> collect = s2.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); - menus.setChildren(collect); - } - - return AjaxResult.success(s1); - } - - - - - @ApiOperation("编辑角色") @PostMapping("/roleUpdate") - public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto) - { + @ApiOperation(value = "编辑角色", tags = {"管理后台-角色管理"}) + @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 + public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto) { SysRole role = new SysRole(); role.setRoleName(dto.getRoleName()); - SysRole one = roleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleId, dto.getRoleId())); - List<SysRole> sysRoles = roleService.isExitUpdate(dto.getRoleName(),dto.getRoleId(),one.getCompanyId()); - if(sysRoles.size()>0){ + SysRole one = roleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleName, dto.getRoleName())); + if(null != one && !one.getRoleId().equals(dto.getRoleId())){ return AjaxResult.error("角色已存在,请重新输入"); } - // 编辑角色 - role.setCarDataAuth(dto.getCarDataAuth()); - role.setCarTrainOperAuth(dto.getCarTrainOperAuth()); - role.setContractDataAuth(dto.getContractDataAuth()); + role.setRemark(dto.getRemark()); role.setUpdateBy(SecurityUtils.getUsername()); role.setUpdateTime(new Date()); role.setRoleId(dto.getRoleId()); @@ -272,110 +238,21 @@ sysRoleMenus.add(sysRoleMenu); } sysRoleMenuMapper.batchRoleMenu(sysRoleMenus); + //删除旧站点数据 + roleSiteClient.delRoleSite(dto.getRoleId()); + //添加站点权限 + List<TRoleSite> roleSites = new ArrayList<>(); + for (Integer siteId : dto.getSiteIds()) { + TRoleSite roleSite = new TRoleSite(); + roleSite.setRoleId(role.getRoleId().intValue()); + roleSite.setSiteId(siteId); + roleSites.add(roleSite); + } + roleSiteClient.addRoleSite(roleSites); return AjaxResult.success(); } - - - - - - - - - - - @Log(title = "角色管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:role:export") - @PostMapping("/export") - public void export(HttpServletResponse response, SysRole role) - { - List<SysRole> list = roleService.selectRoleList(role); - ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); - util.exportExcel(response, list, "角色数据"); - } - - /** - * 根据角色编号获取详细信息 - */ - @RequiresPermissions("system:role:query") - @GetMapping(value = "/{roleId}") - public AjaxResult getInfo(@PathVariable Long roleId) - { - roleService.checkRoleDataScope(roleId); - return success(roleService.selectRoleById(roleId)); - } - - /** - * 新增角色 - */ - @RequiresPermissions("system:role:add") - @Log(title = "角色管理", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@Validated @RequestBody SysRole role) - { - if (!roleService.checkRoleNameUnique(role)) - { - return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); - } - else if (!roleService.checkRoleKeyUnique(role)) - { - return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); - } - role.setCreateBy(SecurityUtils.getUsername()); - return toAjax(roleService.insertRole(role)); - - } - - /** - * 修改保存角色 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@Validated @RequestBody SysRole role) - { - roleService.checkRoleAllowed(role); - roleService.checkRoleDataScope(role.getRoleId()); - if (!roleService.checkRoleNameUnique(role)) - { - return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); - } - else if (!roleService.checkRoleKeyUnique(role)) - { - return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); - } - role.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(roleService.updateRole(role)); - } - - /** - * 修改保存数据权限 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PutMapping("/dataScope") - public AjaxResult dataScope(@RequestBody SysRole role) - { - roleService.checkRoleAllowed(role); - roleService.checkRoleDataScope(role.getRoleId()); - return toAjax(roleService.authDataScope(role)); - } - - /** - * 状态修改 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysRole role) - { - roleService.checkRoleAllowed(role); - roleService.checkRoleDataScope(role.getRoleId()); - role.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(roleService.updateRoleStatus(role)); - } /** * 删除角色 @@ -383,39 +260,14 @@ @RequiresPermissions("system:role:remove") @Log(title = "角色管理", businessType = BusinessType.DELETE) @DeleteMapping("/{roleIds}") - public AjaxResult remove(@PathVariable Long[] roleIds) - { + @ApiOperation(value = "删除角色", tags = {"管理后台-角色管理"}) + public AjaxResult remove(@PathVariable Long[] roleIds) { return toAjax(roleService.deleteRoleByIds(roleIds)); } + - /** - * 停用角色 - */ - @RequiresPermissions("system:role:stop") - @Log(title = "角色管理", businessType = BusinessType.STOP) - @PutMapping("/stop") - public AjaxResult stop(@RequestBody Long roleId) - { - SysRole sysRole = roleService.selectRoleById(roleId); - if(sysRole.getStatus().equals("0")){ - sysRole.setStatus("1"); - }else { - sysRole.setStatus("0"); - } - return toAjax(roleService.updateRole(sysRole)); - } - - /** - * 获取角色选择框列表 - */ - @RequiresPermissions("system:role:query") - @GetMapping("/optionselect") - public AjaxResult optionselect() - { - return success(roleService.selectRoleAll()); - } /** * 查询已分配用户角色列表 */ @@ -440,39 +292,7 @@ return getDataTable(list); } - /** - * 取消授权用户 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.GRANT) - @PutMapping("/authUser/cancel") - public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) - { - return toAjax(roleService.deleteAuthUser(userRole)); - } - - /** - * 批量取消授权用户 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.GRANT) - @PutMapping("/authUser/cancelAll") - public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) - { - return toAjax(roleService.deleteAuthUsers(roleId, userIds)); - } - - /** - * 批量选择用户授权 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.GRANT) - @PutMapping("/authUser/selectAll") - public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) - { - roleService.checkRoleDataScope(roleId); - return toAjax(roleService.insertAuthUsers(roleId, userIds)); - } + /** * 获取对应角色部门树列表 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index dac579f..20f1847 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -9,8 +9,13 @@ import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.chargingPile.api.feignClient.SiteClient; +import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TUserSite; +import com.ruoyi.other.api.feignClient.RoleSiteClient; +import com.ruoyi.other.api.feignClient.UserSiteClient; import com.ruoyi.system.domain.dto.IndexDto; import com.ruoyi.system.domain.vo.UserRoleVO; import com.ruoyi.system.api.model.*; @@ -18,8 +23,12 @@ import com.ruoyi.system.domain.dto.AddCompanyUserDto; import com.ruoyi.system.domain.vo.CompanyUserVo; import com.ruoyi.system.domain.vo.TCompanyToUserVo; +import com.ruoyi.system.query.GetSysUserList; import com.ruoyi.system.service.*; +import io.seata.spring.annotation.GlobalTransactional; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.BeanUtils; @@ -52,37 +61,51 @@ @RequestMapping("/user") @Api(tags = "用户信息") public class SysUserController extends BaseController { - @Autowired + @Resource private ISysUserService userService; - @Autowired + @Resource private ISysRoleService roleService; - @Autowired + @Resource private ISysDeptService deptService; - @Autowired + @Resource private ISysPostService postService; - @Autowired + @Resource private ISysPermissionService permissionService; - @Autowired + @Resource private ISysConfigService configService; - @Autowired + @Resource private ISysUserRoleService userRoleService; - @Autowired + @Resource private ISysUserRoleService sysUserRoleService; + + @Resource + private UserSiteClient userSiteClient; + + @Resource + private RoleSiteClient roleSiteClient; + + @Resource + private SiteClient siteClient; + + + + + /** * 获取用户列表 */ @GetMapping("/list") - @ApiOperation("管理员列表") - public AjaxResult list(String phonenumber, int pageNumber, int pageSize) { - PageInfo<SysUser> pageInfo = new PageInfo<>(pageNumber, pageSize); - PageInfo<SysUser> page = userService.getList(pageInfo, phonenumber); + @ApiOperation(value = "获取系统用户列表", tags = {"管理后台-系统用户管理", "管理后台-角色管理"}) + public AjaxResult list(GetSysUserList getSysUserList) { + PageInfo<SysUser> pageInfo = new PageInfo<>(getSysUserList.getPageCurr(), getSysUserList.getPageSize()); + PageInfo<SysUser> page = userService.getList(pageInfo, getSysUserList); return AjaxResult.success(page); } @@ -91,8 +114,9 @@ */ @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping("/add") - @ApiOperation("添加管理员") - public AjaxResult add(@Validated @RequestBody SysUser user) { + @ApiOperation(value = "添加系统用户", tags = {"管理后台-系统用户管理"}) + @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 + public AjaxResult add(@RequestBody SysUser user) { user.setUserName(user.getPhonenumber()); if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ user.setNickName(user.getPhonenumber()); @@ -100,24 +124,59 @@ if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { return error("手机号已开通账号"); } + if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkUserNameUnique(user)) { + return error("登录账号重复"); + } user.setCreateBy(SecurityUtils.getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setRoleType(1); - int i = userService.insertUser(user); + userService.insertUser(user); SysUserRole sysUserRole = new SysUserRole(); sysUserRole.setRoleId(user.getRoleId()); sysUserRole.setUserId(user.getUserId()); - int i1 = userRoleService.insertSysUserRole(sysUserRole); - return AjaxResult.success(i1); + userRoleService.insertSysUserRole(sysUserRole); + List<Integer> siteIds = user.getSiteIds(); + List<TUserSite> userSites = new ArrayList<>(); + for (Integer siteId : siteIds) { + TUserSite userSite = new TUserSite(); + userSite.setUserId(user.getUserId().intValue()); + userSite.setSiteId(siteId); + userSites.add(userSite); + } + userSiteClient.addUserSite(userSites); + return AjaxResult.success(); } - - + + + @GetMapping("/verifyUserNameRepeat/{username}") + @ApiOperation(value = "校验账号是否重复", tags = {"管理后台-系统用户管理"}) + public AjaxResult verifyUserNameRepeat(@PathVariable String username){ + SysUser user = new SysUser(); + user.setUserName(username); + if (StringUtils.isNotEmpty(username) && !userService.checkUserNameUnique(user)) { + return error("账号不可重复"); + } + return success(); + } + + @GetMapping("/getRoleSiteName/{roleId}") + @ApiOperation(value = "获取角色对应的站点名称", tags = {"管理后台-系统用户管理"}) + public AjaxResult<List<String>> getRoleSiteName(@PathVariable Integer roleId){ + List<Integer> ids = roleSiteClient.getSiteIds(roleId.longValue()).getData(); + List<Site> data = siteClient.getSiteByIds(ids).getData(); + List<String> siteNames = data.stream().map(Site::getName).collect(Collectors.toList()); + return AjaxResult.success(siteNames); + } + + + + /** * 根据用户编号获取详细信息 */ - @ApiOperation("管理员详情") - @GetMapping(value = {"/", "/{userId}"}) - public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { + @ApiOperation(value = "获取用户详情", tags = {"管理后台-系统用户管理"}) + @GetMapping("/getInfo/{userId}") + public AjaxResult getInfo(@PathVariable Long userId) { userService.checkUserDataScope(userId); AjaxResult ajax = AjaxResult.success(); List<SysRole> roles = roleService.selectRoleAll(); @@ -125,6 +184,11 @@ ajax.put("posts", postService.selectPostAll()); if (StringUtils.isNotNull(userId)) { SysUser sysUser = userService.selectUserById(userId); + List<Integer> siteIds = userSiteClient.getSiteIds(userId).getData(); + sysUser.setSiteIds(siteIds); + List<Site> data = siteClient.getSiteByIds(siteIds).getData(); + List<String> siteNames = data.stream().map(Site::getName).collect(Collectors.toList()); + sysUser.setSiteNames(siteNames); ajax.put(AjaxResult.DATA_TAG, sysUser); ajax.put("postIds", postService.selectPostListByUserId(userId)); ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); @@ -138,9 +202,9 @@ */ @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/update") - @ApiOperation("编辑管理员") + @ApiOperation(value = "编辑系统用户", tags = {"管理后台-系统用户管理"}) + @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 public AjaxResult edit(@Validated @RequestBody SysUser user) { - user.setUserName(user.getPhonenumber()); if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ user.setNickName(user.getPhonenumber()); @@ -162,6 +226,13 @@ if (StringUtils.isNotEmpty(user.getPhonenumber()) && (Objects.nonNull(sysUser) && !user.getUserId().equals(sysUser.getUserId()) )) { return error("手机号已开通账号"); } + sysUser = userService.getOne(Wrappers.lambdaQuery(SysUser.class) + .eq(SysUser::getUserName, user.getUserName()) + .eq(SysUser::getDelFlag,0) + .last("LIMIT 1")); + if (StringUtils.isNotEmpty(user.getUserName()) && (Objects.nonNull(sysUser) && !user.getUserId().equals(sysUser.getUserId()) )) { + return error("登录账号重复"); + } user.setUpdateBy(SecurityUtils.getUsername()); if (user.getPassword() != null && !"".equals(user.getPassword())) { user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); @@ -173,7 +244,20 @@ user.setPassword(null); user.setUpdateBy(SecurityUtils.getUsername()); user.setUpdateTime(new Date()); - return toAjax(userService.updateUser(user)); + userService.updateUser(user); + + //删除旧的站点数据后添加新的 + userSiteClient.delUserSite(user.getUserId()); + List<Integer> siteIds = user.getSiteIds(); + List<TUserSite> userSites = new ArrayList<>(); + for (Integer siteId : siteIds) { + TUserSite userSite = new TUserSite(); + userSite.setUserId(user.getUserId().intValue()); + userSite.setSiteId(siteId); + userSites.add(userSite); + } + userSiteClient.addUserSite(userSites); + return success(); } @@ -182,7 +266,7 @@ */ @Log(title = "用户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{userIds}") - @ApiOperation("删除管理员") + @ApiOperation(value = "删除系统用户", tags = {"管理后台-系统用户管理"}) public AjaxResult remove(@PathVariable Long[] userIds) { if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) { return error("当前用户不能删除"); @@ -190,98 +274,25 @@ return toAjax(userService.deleteUserByIds(userIds)); } - - @Log(title = "账号管理", businessType = BusinessType.INSERT) - @PostMapping("/addCompanyUser") - @ApiOperation("账号管理--添加账号") - @Transactional(propagation = Propagation.REQUIRES_NEW) - public AjaxResult addCompanyUser(@Validated @RequestBody AddCompanyUserDto dto) { - SysUser user = dto.getSysUser(); - if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { - return error("手机号已存在,请重新输入"); - } - user.setCreateBy(SecurityUtils.getUsername()); - user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - user.setRoleType(3); - user.setUserName(user.getPhonenumber()); - if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ - user.setNickName(user.getPhonenumber()); - } - int i = userService.insertUser(user); - if (i > 0) { - // 添加role - SysUserRole sysUserRole = new SysUserRole(); - sysUserRole.setRoleId(dto.getRoleId()); - sysUserRole.setUserId(dto.getSysUser().getUserId()); - userRoleService.insertSysUserRole(sysUserRole); - } - return AjaxResult.success(); - } - - - @Log(title = "账号管理", businessType = BusinessType.INSERT) - @PostMapping("/companyUserInfo") - @ApiOperation("账号管理--账号详情") - @Transactional(propagation = Propagation.REQUIRES_NEW) - public AjaxResult companyUserInfo(@RequestParam Long userId) { - SysUser sysUser = userService.selectUserById(userId); - SysUserRole sysUserRole = userRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId)); - CompanyUserVo companyUserVo = new CompanyUserVo(); - companyUserVo.setRoleId(sysUserRole.getRoleId()); - companyUserVo.setSysUser(sysUser); - return AjaxResult.success(companyUserVo); - } - - @Log(title = "账号管理", businessType = BusinessType.INSERT) - @PostMapping("/updateCompanyUser") - @ApiOperation("账号管理--修改账号") - @Transactional(propagation = Propagation.REQUIRES_NEW) - public AjaxResult updateCompanyUser(@Validated @RequestBody AddCompanyUserDto dto) { - SysUser user = dto.getSysUser(); - - if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { - return error("手机号已存在,请重新输入"); - } - user.setUserName(user.getPhonenumber()); - if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ - user.setNickName(user.getPhonenumber()); - } - if (user.getPassword() != null && !"".equals(user.getPassword())) { - user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - } - user.setRoleType(1); - user.setUpdateBy(SecurityUtils.getUsername()); - user.setUpdateTime(new Date()); - int i = userService.updateUser(user); -// if (i > 0) { - // 原来的role - SysUserRole one = userRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, dto.getSysUser().getUserId())); - one.setRoleId(dto.getRoleId()); - //更新新的role - userRoleService.updateSysUserRole(one); -// } - return AjaxResult.success(); - } + @PostMapping("/shopUserStart") - @ApiOperation("账号管理--停用/启用") - public AjaxResult shopUserStart(Long userId) { + @ApiOperation(value = "账号管理--禁用/启用", tags = {"管理后台-系统用户管理"}) + public AjaxResult shopUserStart(@RequestParam("userId") Long userId, @RequestParam("remark") String remark) { if (userId == null) { return AjaxResult.error("userId不能为空"); } SysUser sysUser = userService.selectUserById(userId); if (sysUser.getStatus().equals("0")) { sysUser.setStatus("1"); + sysUser.setRemark(remark); } else { sysUser.setStatus("0"); + sysUser.setRemark(""); } return toAjax(userService.updateUser(sysUser)); } - - - @Autowired - private ISysUserRoleService iSysUserRoleService; @PostMapping("/getUserList") @@ -454,32 +465,6 @@ } - @Log(title = "用户管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:user:export") - @PostMapping("/export") - public void export(HttpServletResponse response, SysUser user) { - List<SysUser> list = userService.selectUserList(user); - ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); - util.exportExcel(response, list, "用户数据"); - } - - @PostMapping("/importTemplate") - public void importTemplate(HttpServletResponse response) throws IOException { - ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); - util.importTemplateExcel(response, "用户数据"); - } - - @Log(title = "用户管理", businessType = BusinessType.IMPORT) - @RequiresPermissions("system:user:import") - @PostMapping("/importData") - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { - ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); - List<SysUser> userList = util.importExcel(file.getInputStream()); - String operName = SecurityUtils.getUsername(); - String message = userService.importUser(userList, updateSupport, operName); - return success(message); - } - /** * 获取当前用户信息 */ @@ -505,7 +490,6 @@ /** * 注册用户信息 */ - @InnerAuth @PostMapping("/register") public R<Boolean> register(@RequestBody SysUser sysUser) { String username = sysUser.getUserName(); @@ -544,6 +528,7 @@ @RequiresPermissions("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/resetPwd") + @ApiOperation(value = "重置密码", tags = {"管理后台-系统用户管理"}) public AjaxResult resetPwd(@RequestBody SysUser user) { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLoginLog.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLoginLog.java new file mode 100644 index 0000000..df7119c --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLoginLog.java @@ -0,0 +1,91 @@ +package com.ruoyi.system.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 com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * @author zhibing.pu + * @Date 2024/8/12 15:38 + */ +@Data +@TableName("sys_login_log") +@ApiModel +public class SysLoginLog { + /** + * 主键 + */ + @ApiModelProperty(value = "数据id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 用户id + */ + @TableField("user_id") + private Integer userId; + /** + * 登录账号 + */ + @TableField("username") + @ApiModelProperty(value = "用户账号") + private String username; + /** + * 登录IP地址 + */ + @TableField("ip_address") + @ApiModelProperty(value = "登录IP地址") + private String ipAddress; + /** + * 登录地址 + */ + @TableField("address") + @ApiModelProperty(value = "登录地址") + private String address; + /** + * 浏览器类型 + */ + @TableField("browser_type") + @ApiModelProperty(value = "浏览器类型") + private String browserType; + /** + * 操作系统 + */ + @TableField("operating_system") + @ApiModelProperty(value = "操作系统") + private String operatingSystem; + /** + * 登录时间 + */ + @TableField("login_time") + @ApiModelProperty(value = "登录时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime loginTime; + /** + * 登录状态(1=成功,2=失败) + */ + @TableField("login_status") + private Integer loginStatus; + /** + * 提示消息 + */ + @TableField("message") + private String message; + /** + * 添加时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + /** + * 删除状态(0=否,1=是) + */ + @TableField("del_flag") + private Integer delFlag; +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java index 3ed8f21..ce244bc 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java @@ -9,19 +9,14 @@ @Data public class RoleAddDto { - @ApiModelProperty("角色名称") + @ApiModelProperty(value = "角色名称", required = true) @NotBlank(message = "角色名称不能为空") private String roleName; - @ApiModelProperty("车辆数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限") - private Integer carDataAuth; - @ApiModelProperty("车务数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限") - private Integer carTrainOperAuth; - @ApiModelProperty("合同数据权限:1=所有数据 2=仅自己负责的合同 3=无数据权限") - private Integer contractDataAuth; - @ApiModelProperty("公司id") - @NotNull(message = "公司id不能为空") - private Integer companyId; - @ApiModelProperty("菜单id") + @ApiModelProperty(value = "站点id", required = true) + private List<Integer> siteIds; + @ApiModelProperty(value = "备注") + private String remark; + @ApiModelProperty(value = "菜单id", required = true) @NotNull(message = "菜单id不能为空") private List<Long> menuIds; } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java index c0374c4..3515054 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java @@ -10,15 +10,13 @@ public class RoleUpdateDto { @ApiModelProperty("角色id") private Long roleId; - @ApiModelProperty("角色名称") + @ApiModelProperty(value = "角色名称",required = true) @NotBlank(message = "角色名称不能为空") private String roleName; - @ApiModelProperty("车辆数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限") - private Integer carDataAuth; - @ApiModelProperty("车务数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限") - private Integer carTrainOperAuth; - @ApiModelProperty("合同数据权限:1=所有数据 2=仅自己负责的合同 3=无数据权限") - private Integer contractDataAuth; - @ApiModelProperty("菜单id") + @ApiModelProperty(value = "站点id", required = true) + private List<Integer> siteIds; + @ApiModelProperty(value = "备注") + private String remark; + @ApiModelProperty(value = "菜单id", required = true) private List<Long> menuIds; } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RoleInfoVo.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RoleInfoVo.java index cfd6915..a935fd0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RoleInfoVo.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RoleInfoVo.java @@ -13,13 +13,13 @@ private String roleName; - @ApiModelProperty("车辆数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限") - private Integer carDataAuth; - @ApiModelProperty("车务数据权限:1=所有数据 2=已租 3=未租 4=已租(仅自己负责的合同) 5=无数据权限") - private Integer carTrainOperAuth; - @ApiModelProperty("合同数据权限:1=所有数据 2=仅自己负责的合同 3=无数据权限") - private Integer contractDataAuth; - @ApiModelProperty("菜单id") private List<Long> menus; + + @ApiModelProperty(value = "备注") + private String remark; + @ApiModelProperty("站点id") + private List<Integer> siteIds; + @ApiModelProperty(value = "站点名称") + private List<String> siteNames; } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLoginLogMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLoginLogMapper.java new file mode 100644 index 0000000..e3be84b --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLoginLogMapper.java @@ -0,0 +1,24 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.system.domain.SysLoginLog; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/8/12 15:44 + */ +public interface SysLoginLogMapper extends BaseMapper<SysLoginLog> { + + /** + * 获取列表数据 + * @param pageInfo + * @param name + * @return + */ + List<SysLoginLog> pageList(PageInfo<SysLoginLog> pageInfo, @Param("name") String name); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java deleted file mode 100644 index 19671f3..0000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.api.domain.SysLogininfor; - -/** - * 系统访问日志情况信息 数据层 - * - * @author ruoyi - */ -public interface SysLogininforMapper -{ - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - public int insertLogininfor(SysLogininfor logininfor); - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor); - - /** - * 批量删除系统登录日志 - * - * @param infoIds 需要删除的登录日志ID - * @return 结果 - */ - public int deleteLogininforByIds(Long[] infoIds); - - /** - * 清空系统登录日志 - * - * @return 结果 - */ - public int cleanLogininfor(); -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 9d9cc62..74b10ed 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.system.query.GetSysUserList; import org.apache.ibatis.annotations.Param; import com.ruoyi.system.api.domain.SysUser; @@ -131,7 +132,7 @@ */ public SysUser checkEmailUnique(String email); - PageInfo<SysUser> getList(@Param("pageInfo") PageInfo<SysUser> pageInfo, @Param("phonenumber") String phonenumber); + List<SysUser> getList(@Param("pageInfo") PageInfo<SysUser> pageInfo, @Param("req") GetSysUserList getSysUserList); PageInfo<SysUser> getAllList(@Param("pageInfo") PageInfo<SysUser> pageInfo, @Param("ids") List<Integer> collect); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java new file mode 100644 index 0000000..05c7100 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java @@ -0,0 +1,25 @@ +package com.ruoyi.system.query; + +import com.ruoyi.common.core.web.page.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/8/10 14:10 + */ +@Data +@ApiModel +public class GetSysUserList extends BasePage { + @ApiModelProperty(value = "人员搜索") + private String search; + @ApiModelProperty(value = "充电站id") + private Integer siteId; + @ApiModelProperty(value = "角色id") + private List<Integer> roleIds; + @ApiModelProperty(value = "账户状态(0=正常,1=禁用)") + private Integer status; +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/SysOperLogQuery.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/SysOperLogQuery.java index 84d75e4..fcb7a5b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/SysOperLogQuery.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/SysOperLogQuery.java @@ -1,16 +1,27 @@ package com.ruoyi.system.query; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.web.page.BasePage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.time.LocalDateTime; + @Data -@ApiModel(value = "当前车辆查询操作日志") +@ApiModel() public class SysOperLogQuery extends BasePage { - - - @ApiModelProperty(value = "车辆id") - private Integer carId; + @ApiModelProperty(value = "操作人员") + private String operName; + @ApiModelProperty(value = "操作标题") + private String title; + @ApiModelProperty(value = "状态(0=正常,1=异常)") + private Integer status; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "操作开始时间", notes = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime startTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "操作结束时间", notes = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLoginLogService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLoginLogService.java new file mode 100644 index 0000000..e99400e --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLoginLogService.java @@ -0,0 +1,32 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.system.domain.SysLoginLog; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author zhibing.pu + * @Date 2024/8/12 15:47 + */ +public interface ISysLoginLogService extends IService<SysLoginLog> { + + + /** + * 获取列表数据 + * @param name + * @param basePage + * @return + */ + PageInfo<SysLoginLog> pageList(String name, BasePage basePage); + + + /** + * 添加登录日志 + * @param loginLog + * @return + */ + AjaxResult addLoginLog(SysLoginLog loginLog); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java deleted file mode 100644 index 509cc54..0000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.api.domain.SysLogininfor; - -/** - * 系统访问日志情况信息 服务层 - * - * @author ruoyi - */ -public interface ISysLogininforService -{ - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - public int insertLogininfor(SysLogininfor logininfor); - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor); - - /** - * 批量删除系统登录日志 - * - * @param infoIds 需要删除的登录日志ID - * @return 结果 - */ - public int deleteLogininforByIds(Long[] infoIds); - - /** - * 清空系统登录日志 - */ - public void cleanLogininfor(); -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java index 46a31f7..66bbc1d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java @@ -7,45 +7,44 @@ /** * 操作日志 服务层 - * + * * @author ruoyi */ -public interface ISysOperLogService extends IService<SysOperLog> -{ - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - * @return 结果 - */ - public int insertOperlog(SysOperLog operLog); - - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - public List<SysOperLog> selectOperLogList(SysOperLog operLog); - - /** - * 批量删除系统操作日志 - * - * @param operIds 需要删除的操作日志ID - * @return 结果 - */ - public int deleteOperLogByIds(Long[] operIds); - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - public SysOperLog selectOperLogById(Long operId); - - /** - * 清空操作日志 - */ - public void cleanOperLog(); +public interface ISysOperLogService extends IService<SysOperLog> { + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + * @return 结果 + */ + public int insertOperlog(SysOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List<SysOperLog> selectOperLogList(SysOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + public int deleteOperLogByIds(Long[] operIds); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public SysOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 3f08d28..c215705 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.query.GetSysUserList; /** * 用户 业务层 @@ -208,7 +209,7 @@ */ public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); - PageInfo<SysUser> getList(PageInfo<SysUser> pageInfo, String phonenumber); + PageInfo<SysUser> getList(PageInfo<SysUser> pageInfo, GetSysUserList getSysUserList); PageInfo<SysUser> getAllList(PageInfo<SysUser> pageInfo, List<Integer> collect); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLoginLogServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLoginLogServiceImpl.java new file mode 100644 index 0000000..69d7b95 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLoginLogServiceImpl.java @@ -0,0 +1,66 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.domain.SysLoginLog; +import com.ruoyi.system.mapper.SysLoginLogMapper; +import com.ruoyi.system.service.ISysLoginLogService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/8/12 15:47 + */ +@Service +public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLoginLog> implements ISysLoginLogService { + + @Resource + private ISysUserService sysUserService; + + + + + + /** + * 获取列表数据 + * @param name + * @param basePage + * @return + */ + @Override + public PageInfo<SysLoginLog> pageList(String name, BasePage basePage) { + PageInfo<SysLoginLog> pageInfo = new PageInfo<>(basePage.getPageCurr(), basePage.getPageSize()); + List<SysLoginLog> list = this.baseMapper.pageList(pageInfo, name); + return pageInfo.setRecords(list); + } + + + /** + * 添加登录日志 + * @param loginLog + * @return + */ + @Override + public AjaxResult addLoginLog(SysLoginLog loginLog) { + String username = loginLog.getUsername(); + SysUser sysUser = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username).eq(SysUser::getDelFlag, 0)); + if(null == sysUser){ + return AjaxResult.error("用户账号无效"); + } + loginLog.setUserId(sysUser.getUserId().intValue()); + loginLog.setCreateTime(LocalDateTime.now()); + loginLog.setDelFlag(0); + this.save(loginLog); + return AjaxResult.success(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java deleted file mode 100644 index 525d9d7..0000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; - -import com.ruoyi.system.mapper.SysLogininforMapper; -import com.ruoyi.system.service.ISysLogininforService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.system.api.domain.SysLogininfor; - -/** - * 系统访问日志情况信息 服务层处理 - * - * @author ruoyi - */ -@Service -public class SysLogininforServiceImpl implements ISysLogininforService -{ - - @Autowired - private SysLogininforMapper logininforMapper; - - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - @Override - public int insertLogininfor(SysLogininfor logininfor) - { - return logininforMapper.insertLogininfor(logininfor); - } - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - @Override - public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) - { - return logininforMapper.selectLogininforList(logininfor); - } - - /** - * 批量删除系统登录日志 - * - * @param infoIds 需要删除的登录日志ID - * @return 结果 - */ - @Override - public int deleteLogininforByIds(Long[] infoIds) - { - return logininforMapper.deleteLogininforByIds(infoIds); - } - - /** - * 清空系统登录日志 - */ - @Override - public void cleanLogininfor() - { - logininforMapper.cleanLogininfor(); - } -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java index 7ca5d1b..5174654 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java @@ -15,114 +15,108 @@ /** * 操作日志 服务层处理 - * + * * @author ruoyi */ @Service -public class SysOperLogServiceImpl implements ISysOperLogService -{ - @Autowired - private SysOperLogMapper operLogMapper; - - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - * @return 结果 - */ - @Override - public int insertOperlog(SysOperLog operLog) - { - return operLogMapper.insertOperlog(operLog); - } - - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - @Override - public List<SysOperLog> selectOperLogList(SysOperLog operLog) - { - return operLogMapper.selectOperLogList(operLog); - } - - /** - * 批量删除系统操作日志 - * - * @param operIds 需要删除的操作日志ID - * @return 结果 - */ - @Override - public int deleteOperLogByIds(Long[] operIds) - { - return operLogMapper.deleteOperLogByIds(operIds); - } - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - @Override - public SysOperLog selectOperLogById(Long operId) - { - return operLogMapper.selectOperLogById(operId); - } - - /** - * 清空操作日志 - */ - @Override - public void cleanOperLog() - { - operLogMapper.cleanOperLog(); - } - - @Override - public boolean saveBatch(Collection<SysOperLog> entityList, int batchSize) { - return false; - } - - @Override - public boolean saveOrUpdateBatch(Collection<SysOperLog> entityList, int batchSize) { - return false; - } - - @Override - public boolean updateBatchById(Collection<SysOperLog> entityList, int batchSize) { - return false; - } - - @Override - public boolean saveOrUpdate(SysOperLog entity) { - return false; - } - - @Override - public SysOperLog getOne(Wrapper<SysOperLog> queryWrapper, boolean throwEx) { - return null; - } - - @Override - public Map<String, Object> getMap(Wrapper<SysOperLog> queryWrapper) { - return null; - } - - @Override - public <V> V getObj(Wrapper<SysOperLog> queryWrapper, Function<? super Object, V> mapper) { - return null; - } - - @Override - public BaseMapper<SysOperLog> getBaseMapper() { - return null; - } - - @Override - public Class<SysOperLog> getEntityClass() { - return null; - } +public class SysOperLogServiceImpl implements ISysOperLogService { + @Autowired + private SysOperLogMapper operLogMapper; + + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + * @return 结果 + */ + @Override + public int insertOperlog(SysOperLog operLog) { + return operLogMapper.insertOperlog(operLog); + } + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + @Override + public List<SysOperLog> selectOperLogList(SysOperLog operLog) { + return operLogMapper.selectOperLogList(operLog); + } + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + @Override + public int deleteOperLogByIds(Long[] operIds) { + return operLogMapper.deleteOperLogByIds(operIds); + } + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + @Override + public SysOperLog selectOperLogById(Long operId) { + return operLogMapper.selectOperLogById(operId); + } + + /** + * 清空操作日志 + */ + @Override + public void cleanOperLog() { + operLogMapper.cleanOperLog(); + } + + @Override + public boolean saveBatch(Collection<SysOperLog> entityList, int batchSize) { + return false; + } + + @Override + public boolean saveOrUpdateBatch(Collection<SysOperLog> entityList, int batchSize) { + return false; + } + + @Override + public boolean updateBatchById(Collection<SysOperLog> entityList, int batchSize) { + return false; + } + + @Override + public boolean saveOrUpdate(SysOperLog entity) { + return false; + } + + @Override + public SysOperLog getOne(Wrapper<SysOperLog> queryWrapper, boolean throwEx) { + return null; + } + + @Override + public Map<String, Object> getMap(Wrapper<SysOperLog> queryWrapper) { + return null; + } + + @Override + public <V> V getObj(Wrapper<SysOperLog> queryWrapper, Function<? super Object, V> mapper) { + return null; + } + + @Override + public BaseMapper<SysOperLog> getBaseMapper() { + return null; + } + + @Override + public Class<SysOperLog> getEntityClass() { + return null; + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index fea5840..e5cc275 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -373,8 +373,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleByIds(Long[] roleIds) - { + public int deleteRoleByIds(Long[] roleIds) { for (Long roleId : roleIds) { checkRoleAllowed(new SysRole(roleId)); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 50b929f..6b7e40e 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -1,16 +1,26 @@ package com.ruoyi.system.service.impl; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; +import javax.annotation.Resource; import javax.validation.Validator; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.chargingPile.api.feignClient.SiteClient; +import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.feignClient.RoleSiteClient; +import com.ruoyi.other.api.feignClient.UserSiteClient; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysUserPost; import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.query.GetSysUserList; import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysUserRoleService; import com.ruoyi.system.service.ISysUserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,26 +53,41 @@ { private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); - @Autowired + @Resource private SysUserMapper userMapper; - @Autowired + @Resource private SysRoleMapper roleMapper; - @Autowired + @Resource private SysPostMapper postMapper; - @Autowired + @Resource private SysUserRoleMapper userRoleMapper; - @Autowired + @Resource private SysUserPostMapper userPostMapper; - @Autowired + @Resource private ISysConfigService configService; - @Autowired + @Resource protected Validator validator; + + @Resource + private ISysUserRoleService sysUserRoleService; + + @Resource + private RoleSiteClient roleSiteClient; + + @Resource + private UserSiteClient userSiteClient; + + @Resource + private SiteClient siteClient; + + + /** * 根据条件分页查询用户列表 @@ -547,8 +572,26 @@ } @Override - public PageInfo<SysUser> getList(PageInfo<SysUser> pageInfo, String phonenumber) { - return this.baseMapper.getList(pageInfo,phonenumber); + public PageInfo<SysUser> getList(PageInfo<SysUser> pageInfo, GetSysUserList getSysUserList) { + List<SysUser> list = this.baseMapper.getList(pageInfo, getSysUserList); + for (SysUser sysUser : list) { + List<SysUserRole> list1 = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId())); + List<Integer> data1 = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); + for (SysUserRole sysUserRole : list1) { + List<Integer> data = roleSiteClient.getSiteIds(sysUserRole.getRoleId()).getData(); + data1.addAll(data); + } + Set<Integer> siteIds = new HashSet<>(data1); + List<Site> data = siteClient.getSiteByIds(siteIds.stream().collect(Collectors.toList())).getData(); + List<String> siteNames = data.stream().map(Site::getName).collect(Collectors.toList()); + sysUser.setSiteNames(siteNames); + + Set<Long> collect = list1.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet()); + List<SysRole> sysRoles = roleMapper.selectBatchIds(collect); + List<String> roleNames = sysRoles.stream().map(SysRole::getRoleName).collect(Collectors.toList()); + sysUser.setRoleNames(roleNames); + } + return pageInfo.setRecords(list); } @Override diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLoginLogMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLoginLogMapper.xml new file mode 100644 index 0000000..87f8136 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLoginLogMapper.xml @@ -0,0 +1,35 @@ +<?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.ruoyi.system.mapper.SysLoginLogMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.SysLoginLog"> + <id column="id" property="id" /> + <result column="user_id" property="userId" /> + <result column="user_name" property="username" /> + <result column="ip_address" property="ipAddress"/> + <result column="address" property="address"/> + <result column="browser_type" property="browserType"/> + <result column="operating_system" property="operatingSystem"/> + <result column="login_time" property="loginTime"/> + <result column="login_status" property="loginStatus"/> + <result column="message" property="message"/> + <result column="create_time" property="createTime"/> + <result column="del_flag" property="delFlag"/> + </resultMap> + + + + <select id="pageList" resultMap="BaseResultMap"> + select + a.*, + b.user_name + from sys_login_log a + left join sys_user b on (a.user_id = b.user_id) + where a.del_flag = 0 + <if test="null != name and '' != name"> + and b.user_name like CONCAT('%', #{name}, '%') + </if> + order by a.create_time desc + </select> +</mapper> \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml deleted file mode 100644 index 8c5a10e..0000000 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?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.ruoyi.system.mapper.SysLogininforMapper"> - - <resultMap type="com.ruoyi.system.api.domain.SysLogininfor" id="SysLogininforResult"> - <id property="infoId" column="info_id" /> - <result property="userName" column="user_name" /> - <result property="status" column="status" /> - <result property="ipaddr" column="ipaddr" /> - <result property="msg" column="msg" /> - <result property="accessTime" column="access_time" /> - </resultMap> - - <insert id="insertLogininfor" parameterType="com.ruoyi.system.api.domain.SysLogininfor"> - insert into sys_logininfor (user_name, status, ipaddr, msg, access_time) - values (#{userName}, #{status}, #{ipaddr}, #{msg}, sysdate()) - </insert> - - <select id="selectLogininforList" parameterType="com.ruoyi.system.api.domain.SysLogininfor" resultMap="SysLogininforResult"> - select info_id, user_name, ipaddr, status, msg, access_time from sys_logininfor - <where> - <if test="ipaddr != null and ipaddr != ''"> - AND ipaddr like concat('%', #{ipaddr}, '%') - </if> - <if test="status != null and status != ''"> - AND status = #{status} - </if> - <if test="userName != null and userName != ''"> - AND user_name like concat('%', #{userName}, '%') - </if> - <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> - AND access_time >= #{params.beginTime} - </if> - <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> - AND access_time <= #{params.endTime} - </if> - </where> - order by info_id desc - </select> - - <delete id="deleteLogininforByIds" parameterType="Long"> - delete from sys_logininfor where info_id in - <foreach collection="array" item="infoId" open="(" separator="," close=")"> - #{infoId} - </foreach> - </delete> - - <update id="cleanLogininfor"> - truncate table sys_logininfor - </update> - -</mapper> \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index e7df625..2b11d94 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -125,10 +125,24 @@ </select> <select id="getList" resultType="com.ruoyi.system.api.domain.SysUser"> select *,nick_name nickName,login_date loginDate,create_time createTime,user_id userId from sys_user where 1=1 - <if test="phonenumber !=null and phonenumber !=''"> - and phonenumber like concat("%", #{phonenumber},"%") + <if test="req.search !=null and req.search !=''"> + and (phonenumber like concat("%", #{phonenumber},"%") or nick_name like concat("%", #{phonenumber},"%")) </if> - and del_flag = '0' and roleType =1 + <if test="null != req.siteId"> + and user_id in (select user_id from t_user_site where site_id = #{req.siteId}) + and user_id in (select user_id from sys_user_role where role_id in (select role_id from t_role_site where site_id = #{req.siteId})) + </if> + <if test="null != req.roleIds and req.roleIds.size() > 0"> + and user_id in (select user_id from sys_user_role where role_id in + <foreach collection="req.roleIds" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> + ) + </if> + <if test="null != req.status"> + and status = #{req.status} + </if> + and del_flag = '0' and roleType =1 order by create_time desc </select> <select id="getAllList" resultType="com.ruoyi.system.api.domain.SysUser"> diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java index 063741b..7a4479f 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java @@ -1,8 +1,17 @@ package com.ruoyi.account.controller; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.account.api.model.TAppUserCar; +import com.ruoyi.account.service.TAppUserCarService; +import com.ruoyi.common.core.domain.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + +import java.util.List; /** * <p> @@ -16,5 +25,18 @@ @RequestMapping("/t-app-user-car") public class TAppUserCarController { + @Autowired + private TAppUserCarService appUserCarService; + + /** + * 根据用户车辆id查询车辆信息 + * @param carIds + * @return + */ + @PostMapping(value = "/t-app-user-car/getCarByIds") + public R<List<TAppUserCar>> getCarByIds(@RequestBody List<Integer> carIds){ + return R.ok(appUserCarService.list(Wrappers.lambdaQuery(TAppUserCar.class).in(TAppUserCar::getId,carIds))); + } + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java index a58cc4b..839c64a 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.dto.*; import com.ruoyi.account.api.model.*; @@ -337,5 +338,27 @@ return R.ok(); } + + /** + * 根据用户id查询用户信息 + * @param appUserIds 用户id + * @return + */ + @PostMapping(value = "/user/getUserByIds") + public R<List<TAppUser>> getUserByIds(@RequestBody List<Long> appUserIds){ + return R.ok(appUserService.list(Wrappers.<TAppUser>lambdaQuery().in(TAppUser::getId,appUserIds))); + } + + + /** + * 根据用户id获取用户 + * @param id + * @return + */ + @GetMapping(value = "/user/getUserById/{id}") + public R<TAppUser> getUserById(@PathVariable Long id){ + TAppUser appUser = appUserService.getById(id); + return R.ok(appUser); + } } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/PartnerController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/PartnerController.java index 159f1f6..3346720 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/PartnerController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/PartnerController.java @@ -43,7 +43,7 @@ @ResponseBody @GetMapping("/getPartnerList") @ApiOperation(value = "获取合作商列表", tags = {"管理后台-合作商管理"}) - public AjaxResult<PageInfo<PartnerListDTO>> getPartnerList(@RequestBody GetPartnerList partnerList){ + public AjaxResult<PageInfo<PartnerListDTO>> getPartnerList(GetPartnerList partnerList){ PageInfo<PartnerListDTO> list = partnerService.getPartnerList(partnerList); return AjaxResult.success(list); } @@ -86,7 +86,7 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "合作商id", name = "id", dataTypeClass = Integer.class, required = true) }) - public AjaxResult delPartner(@PathVariable("id") Integer id){ + public AjaxResult delPartner(@PathVariable("id") Integer[] id){ return partnerService.delPartner(id); } @@ -119,7 +119,7 @@ @ResponseBody @GetMapping("/getPermissionConfiguration/{siteId}") @ApiOperation(value = "获取合作商权限设置", tags = {"管理后台-站点管理"}) - public AjaxResult<GetPermissionConfigurationDTO> getPermissionConfiguration(@PathVariable("siteId") Integer siteId, @RequestParam("partnerId") Integer partnerId){ + public AjaxResult<GetPermissionConfigurationDTO> getPermissionConfiguration(@PathVariable("siteId") Integer siteId, Integer partnerId){ GetPermissionConfigurationDTO permissionConfiguration = partnerService.getPermissionConfiguration(siteId, partnerId); return AjaxResult.success(permissionConfiguration); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java index 2e6c5f6..6209a9a 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java @@ -3,9 +3,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; +import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient; import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.chargingPile.api.model.TChargingGun; import com.ruoyi.chargingPile.api.model.TChargingPile; +import com.ruoyi.chargingPile.api.model.TParkingLot; import com.ruoyi.chargingPile.api.query.GetSiteList; import com.ruoyi.chargingPile.api.query.SiteDetailQuery; import com.ruoyi.chargingPile.api.query.SiteQuery; @@ -18,6 +20,7 @@ import com.ruoyi.chargingPile.service.ISiteService; import com.ruoyi.chargingPile.service.TChargingGunService; import com.ruoyi.chargingPile.service.TChargingPileService; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.GeodesyUtil; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageInfo; @@ -35,10 +38,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Map; +import java.util.*; /** * @author zhibing.pu @@ -62,21 +62,21 @@ @Resource private RoleSiteClient roleSiteClient; - - - - - - - @Autowired + @Resource + private ParkingLotClient parkingLotClient; + @Resource private TChargingPileService chargingPileService; - @Autowired + @Resource private TChargingGunService chargingGunService; + + + + @ResponseBody @GetMapping("/getSiteList") @ApiOperation(value = "获取站点列表", tags = {"管理后台-站点管理"}) - public AjaxResult<PageInfo<GetSiteListDTO>> getSiteList(@RequestBody GetSiteList siteList){ + public AjaxResult<PageInfo<GetSiteListDTO>> getSiteList(GetSiteList siteList){ PageInfo<GetSiteListDTO> list = siteService.getSiteList(siteList); return AjaxResult.success(list); } @@ -99,7 +99,11 @@ // 计算距离 Map<String, Double> distance = GeodesyUtil.getDistance(query.getLat() + "," + query.getLon(), siteDetailVO.getLat() + "," + siteDetailVO.getLon()); siteDetailVO.setDistance(distance.get("WGS84")); - // TODO 查询绑定车牌提示文案 + // 查询绑定车牌提示文案 + TParkingLot parkingLot = parkingLotClient.getLotBySiteId(query.getSiteId()).getData(); + if(Objects.nonNull(parkingLot)){ + siteDetailVO.setRemark(parkingLot.getRemark()); + } return AjaxResult.success(siteDetailVO); } @@ -107,7 +111,7 @@ @GetMapping("/getChargingGunList") public AjaxResult<List<TChargingPileVO>> getChargingGunList(@RequestParam(value = "siteId")@ApiParam(value = "站点id", required = true)Integer siteId, @RequestParam(value = "siteId",required = false)@ApiParam(value = "类型 1=超充,2=快充,3=慢充")Integer type){ - return AjaxResult.success(chargingPileService.getChargingGunList(siteId)); + return AjaxResult.success(chargingPileService.getChargingGunList(siteId,type)); } @ApiOperation(value = "获取站点下充电枪数量统计", tags = {"小程序-站点管理-站点详情"}) @@ -137,7 +141,7 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "站点id", name = "id", dataTypeClass = Integer.class, required = true) }) - public AjaxResult delSite(@PathVariable Integer id){ + public AjaxResult delSite(@PathVariable Integer[] id){ return siteService.delSite(id); } @@ -157,7 +161,7 @@ @ResponseBody @GetMapping("/getAllSiteList") - @ApiOperation(value = "获取所有站点数据", tags = {"管理后台-充电桩信息"}) + @ApiOperation(value = "获取所有站点数据", tags = {"管理后台-充电桩信息", "管理后台-系统用户管理", "管理后台-角色管理", "管理后台-系统通知", "管理后台-充电评价"}) public AjaxResult<List<Site>> getAllSiteList(){ //校验当前账户站点权限 SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); @@ -180,4 +184,17 @@ List<Site> list = siteService.list(wrapper.orderByDesc(Site::getCreateTime)); return AjaxResult.success(list); } + + + /** + * 获取站点数据集合 + * @param ids + * @return + */ + @ResponseBody + @PostMapping("/getSiteByIds") + public R<List<Site>> getSiteByIds(@RequestBody List<Integer> ids){ + List<Site> sites = siteService.listByIds(ids); + return R.ok(sites); + } } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java index c58f62a..b917562 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.chargingPile.api.model.TAccountingStrategy; +import com.ruoyi.chargingPile.api.vo.StrategyPriceVO; import com.ruoyi.chargingPile.api.vo.TAccountingStrategyDetailVO; import com.ruoyi.chargingPile.service.TAccountingStrategyDetailService; import com.ruoyi.chargingPile.service.TAccountingStrategyService; @@ -16,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalTime; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -44,7 +47,7 @@ /** * 通过电站id查询计费策略明细列表 */ - @ApiOperation(tags = {"小程序-计费策略"},value = "通过站点id查询计费策略明细列表") + @ApiOperation(tags = {"小程序-站点管理-站点详情"},value = "通过站点id查询计费策略明细列表") @GetMapping(value = "/queryAccountingStrategyDetailBySiteId") public AjaxResult<List<TAccountingStrategyDetailVO>> queryAccountingStrategyDetailBySiteId(@RequestParam Integer siteId) { TAccountingStrategy accountingStrategy = accountingStrategyService.getOne(Wrappers.lambdaQuery(TAccountingStrategy.class) @@ -53,12 +56,25 @@ if(Objects.isNull(accountingStrategy)){ throw new ServiceException("未查询到计费策略"); } - // TODO 修改 - List<TAccountingStrategyDetailVO> list = accountingStrategyDetailService.queryAccountingStrategyDetailByStrategyId(accountingStrategy.getId()); - list.forEach(detail -> { - detail.setTotalPrice(detail.getElectrovalence().add(detail.getElectrovalence())); - }); - return AjaxResult.ok(list); + return AjaxResult.ok(accountingStrategyDetailService.queryAccountingStrategyDetailByStrategyId(accountingStrategy.getId())); + } + + /** + * 通过站点id查询当前时间段计费策略展示 + */ + @ApiOperation(tags = {"小程序-站点管理-站点详情"},value = "通过站点id查询当前时间段计费策略展示") + @GetMapping(value = "/queryStrategyBySiteIdAndTime") + public AjaxResult<List<TAccountingStrategyDetailVO>> queryStrategyBySiteIdAndTime(@RequestParam Integer siteId) { + return AjaxResult.ok(accountingStrategyDetailService.queryStrategyBySiteIdAndTime(siteId)); + } + + /** + * 价格说明金额返回,会员开通金额说明 + */ + @ApiOperation(tags = {"小程序-站点管理-站点详情"},value = "价格说明金额返回,会员开通金额说明") + @GetMapping(value = "/queryPrice") + public AjaxResult<StrategyPriceVO> queryPrice(@RequestParam Integer siteId) { + return AjaxResult.ok(accountingStrategyDetailService.queryPrice(siteId)); } } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java index 2c8f9da..0b68161 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java @@ -120,7 +120,7 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "充电桩id", name = "id", dataTypeClass = Integer.class, required = true) }) - public AjaxResult delChargingPile(@PathVariable Integer id){ + public AjaxResult delChargingPile(@PathVariable Integer[] id){ return chargingPileService.delChargingPile(id); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileNotificationController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileNotificationController.java index 1827a95..9f7c8cd 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileNotificationController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileNotificationController.java @@ -1,8 +1,15 @@ package com.ruoyi.chargingPile.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.chargingPile.api.model.TChargingPileNotification; +import com.ruoyi.chargingPile.service.TChargingPileNotificationService; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; /** * <p> @@ -15,6 +22,32 @@ @RestController @RequestMapping("/t-charging-pile-notification") public class TChargingPileNotificationController { + + @Resource + private TChargingPileNotificationService chargingPileNotificationService; + + + + + @ResponseBody + @GetMapping("/chargingPileNotificationPageList") + @ApiOperation(value = "获取系统通知列表数据", tags = {"管理后台-系统通知"}) + public AjaxResult<PageInfo<TChargingPileNotification>> chargingPileNotificationPageList(Integer siteId, BasePage basePage){ + PageInfo<TChargingPileNotification> pageInfo = chargingPileNotificationService.chargingPileNotificationPageList(siteId, basePage); + return AjaxResult.success(pageInfo); + } + + + @ResponseBody + @DeleteMapping("/delChargingPileNotification/{id}") + @ApiOperation(value = "删除系统通知", tags = {"管理后台-系统通知"}) + public AjaxResult delChargingPileNotification(@PathVariable Long id){ + TChargingPileNotification chargingPileNotification = chargingPileNotificationService.getById(id); + chargingPileNotification.setDelFlag(1); + chargingPileNotificationService.updateById(chargingPileNotification); + return AjaxResult.success(); + } + } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java index 3945b5c..be3a1ba 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java @@ -11,6 +11,7 @@ import com.ruoyi.chargingPile.service.TCarportService; import com.ruoyi.chargingPile.service.TParkingLotService; import com.ruoyi.chargingPile.service.TVehicleRampService; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.log.annotation.Log; @@ -126,6 +127,14 @@ .in(TCarport::getParkingLotId, ids)); return AjaxResult.ok(parkingLotService.removeByIds(ids)); } - + + /** + * 通过站点id查询停车场信息 + */ + @GetMapping(value = "/getLotBySiteId") + public R<TParkingLot> getLotBySiteId(@RequestParam("siteId") Integer siteId){ + return R.ok(parkingLotService.getOne(Wrappers.lambdaQuery(TParkingLot.class) + .eq(TParkingLot::getSiteId, siteId))); + } } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TChargingPileNotificationMapper.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TChargingPileNotificationMapper.java index 5cbc4f4..d093e4c 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TChargingPileNotificationMapper.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TChargingPileNotificationMapper.java @@ -2,6 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.chargingPile.api.model.TChargingPileNotification; +import com.ruoyi.common.core.web.page.PageInfo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Set; /** * <p> @@ -12,5 +17,14 @@ * @since 2024-08-08 */ public interface TChargingPileNotificationMapper extends BaseMapper<TChargingPileNotification> { + + + /** + * 获取系统通知列表数据 + * @param pageInfo + * @param siteIds + * @return + */ + List<TChargingPileNotification> chargingPileNotificationPageList(PageInfo<TChargingPileNotification> pageInfo, @Param("siteIds") Set<Integer> siteIds); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/IPartnerService.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/IPartnerService.java index 4821f5d..bab0bb9 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/IPartnerService.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/IPartnerService.java @@ -58,7 +58,7 @@ * 删除合作商 * @param id */ - AjaxResult delPartner(Integer id); + AjaxResult delPartner(Integer[] id); /** * 重置密码 diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/ISiteService.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/ISiteService.java index 857b0c5..4a8dd0e 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/ISiteService.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/ISiteService.java @@ -49,7 +49,7 @@ * @param id * @return */ - AjaxResult delSite(Integer id); + AjaxResult delSite(Integer[] id); /** diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TAccountingStrategyDetailService.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TAccountingStrategyDetailService.java index 292134b..178d0cf 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TAccountingStrategyDetailService.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TAccountingStrategyDetailService.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail; +import com.ruoyi.chargingPile.api.vo.StrategyPriceVO; import com.ruoyi.chargingPile.api.vo.TAccountingStrategyDetailVO; import java.util.List; @@ -22,4 +23,19 @@ * @return */ List<TAccountingStrategyDetailVO> queryAccountingStrategyDetailByStrategyId(Integer strategyId); + + + /** + * 通过站点id查询当前时间段计费策略展示 + * @param siteId + * @return + */ + List<TAccountingStrategyDetailVO> queryStrategyBySiteIdAndTime(Integer siteId); + + /** + * 价格说明金额返回,会员开通金额说明 + * @param siteId + * @return + */ + StrategyPriceVO queryPrice(Integer siteId); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileNotificationService.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileNotificationService.java index 077787b..28287dd 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileNotificationService.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileNotificationService.java @@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.chargingPile.api.model.TChargingPileNotification; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; /** * <p> @@ -12,5 +14,13 @@ * @since 2024-08-08 */ public interface TChargingPileNotificationService extends IService<TChargingPileNotification> { - + + + /** + * 获取系统通知列表数据 + * @param siteId + * @param basePage + * @return + */ + PageInfo<TChargingPileNotification> chargingPileNotificationPageList(Integer siteId, BasePage basePage); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java index 7ca7a8d..beb89c2 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java @@ -61,7 +61,7 @@ * @param id * @return */ - AjaxResult delChargingPile(Integer id); + AjaxResult delChargingPile(Integer[] id); /** @@ -73,8 +73,9 @@ /** * 获取站点下充电桩及充电枪列表 * @param siteId + * @param type * @return */ - List<TChargingPileVO> getChargingGunList(Integer siteId); + List<TChargingPileVO> getChargingGunList(Integer siteId,Integer type); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/PartnerServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/PartnerServiceImpl.java index b3fceeb..8c79e0e 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/PartnerServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/PartnerServiceImpl.java @@ -268,32 +268,33 @@ /** * 删除合作商 - * @param id 合作商id + * @param ids 合作商id */ @Override @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 - public AjaxResult delPartner(Integer id) { + public AjaxResult delPartner(Integer[] ids) { //查询有无关联数据 //站点 - long count = siteService.count(new LambdaQueryWrapper<Site>().eq(Site::getPartnerId, id).eq(Site::getDelFlag, 0)); + long count = siteService.count(new LambdaQueryWrapper<Site>().in(Site::getPartnerId, Arrays.asList(ids)).eq(Site::getDelFlag, 0)); if(count > 0){ return AjaxResult.error("当前合作商有关联站点,删除失败!"); } //充电桩 - long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getPartnerId, id).eq(TChargingPile::getDelFlag, 0)); + long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getPartnerId, Arrays.asList(ids)).eq(TChargingPile::getDelFlag, 0)); if(count1 > 0){ return AjaxResult.error("当前合作商有关联充电桩,删除失败!"); } - - Partner partner = this.getById(id); - if(null == partner){ - return AjaxResult.error("删除失败"); + for (Integer id : ids) { + Partner partner = this.getById(id); + if(null == partner){ + return AjaxResult.error("删除失败"); + } + partner.setDelFlag(true); + this.updateById(partner); + SysUser user = sysUserClient.queryUserByUserName(partner.getAccount()).getData(); + user.setDelFlag("2"); + sysUserClient.updateUser(user); } - partner.setDelFlag(true); - this.updateById(partner); - SysUser user = sysUserClient.queryUserByUserName(partner.getAccount()).getData(); - user.setDelFlag("2"); - sysUserClient.updateUser(user); return AjaxResult.success(); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java index 5e6ae0e..fe3d696 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java @@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -196,20 +197,22 @@ /** * 删除站点 - * @param id 站点id + * @param ids 站点id * @return */ @Override - public AjaxResult delSite(Integer id) { + public AjaxResult delSite(Integer[] ids) { //查询是否有关联数据 //充电桩 - long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getSiteId, id).eq(TChargingPile::getDelFlag, 0)); + long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getSiteId, Arrays.asList(ids)).eq(TChargingPile::getDelFlag, 0)); if(count1 > 0){ return AjaxResult.error("该站点有关联充电桩,删除失败!"); } - Site site = this.getById(id); - site.setDelFlag(true); - this.updateById(site); + for (Integer id : ids) { + Site site = this.getById(id); + site.setDelFlag(true); + this.updateById(site); + } return AjaxResult.success(); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java index 741455f..8011eb8 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java @@ -1,13 +1,25 @@ package com.ruoyi.chargingPile.service.impl; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.chargingPile.api.model.TAccountingStrategy; import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail; +import com.ruoyi.chargingPile.api.vo.StrategyPriceVO; import com.ruoyi.chargingPile.api.vo.TAccountingStrategyDetailVO; import com.ruoyi.chargingPile.mapper.TAccountingStrategyDetailMapper; +import com.ruoyi.chargingPile.mapper.TAccountingStrategyMapper; import com.ruoyi.chargingPile.service.TAccountingStrategyDetailService; +import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.other.api.domain.TVip; +import com.ruoyi.other.api.feignClient.VipClient; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.time.LocalTime; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * <p> @@ -20,8 +32,65 @@ @Service public class TAccountingStrategyDetailServiceImpl extends ServiceImpl<TAccountingStrategyDetailMapper, TAccountingStrategyDetail> implements TAccountingStrategyDetailService { + @Autowired + private TAccountingStrategyMapper accountingStrategyMapper; + @Autowired + private VipClient vipClient; + @Override public List<TAccountingStrategyDetailVO> queryAccountingStrategyDetailByStrategyId(Integer strategyId) { return this.baseMapper.queryAccountingStrategyDetailByStrategyId(strategyId); } + + @Override + public List<TAccountingStrategyDetailVO> queryStrategyBySiteIdAndTime(Integer siteId) { + TAccountingStrategy accountingStrategy = accountingStrategyMapper.selectOne(Wrappers.lambdaQuery(TAccountingStrategy.class) + .eq(TAccountingStrategy::getSiteId, siteId) + .last("limit 1")); + if(Objects.isNull(accountingStrategy)){ + throw new ServiceException("未查询到计费策略"); + } + List<TAccountingStrategyDetailVO> list = this.queryAccountingStrategyDetailByStrategyId(accountingStrategy.getId()); + // 获取当前时间段的计费策略明细 + TAccountingStrategyDetailVO accountingStrategyDetailVO = list.stream().filter(detail -> detail.getStartTime().compareTo(LocalTime.now().toString()) <= 0 && detail.getEndTime().compareTo(LocalTime.now().toString()) >= 0) + .findFirst().orElseThrow(() -> new ServiceException("当前时间段未查询到计费策略明细")); + accountingStrategyDetailVO.setDiscount(accountingStrategy.getDiscount()); + // 获取后一次的计费策略明细 + TAccountingStrategyDetailVO accountingStrategyDetailNext = list.stream().filter(detail -> detail.getStartTime().compareTo(accountingStrategyDetailVO.getEndTime()) == 0) + .findFirst().orElseThrow(() -> new ServiceException("未查询到下一时间段的计费策略明细")); + accountingStrategyDetailNext.setDiscount(accountingStrategy.getDiscount()); + list = new ArrayList<>(); + list.add(accountingStrategyDetailVO); + list.add(accountingStrategyDetailNext); + return list; + } + + @Override + public StrategyPriceVO queryPrice(Integer siteId) { + TAccountingStrategy accountingStrategy = accountingStrategyMapper.selectOne(Wrappers.lambdaQuery(TAccountingStrategy.class) + .eq(TAccountingStrategy::getSiteId, siteId) + .last("limit 1")); + if(Objects.isNull(accountingStrategy)){ + throw new ServiceException("未查询到计费策略"); + } + + StrategyPriceVO strategyPriceVO = new StrategyPriceVO(); + + List<TAccountingStrategyDetailVO> list = this.queryAccountingStrategyDetailByStrategyId(accountingStrategy.getId()); + // 获取当前时间段的计费策略明细 + TAccountingStrategyDetailVO accountingStrategyDetailVO = list.stream().filter(detail -> detail.getStartTime().compareTo(LocalTime.now().toString()) <= 0 && detail.getEndTime().compareTo(LocalTime.now().toString()) >= 0) + .findFirst().orElseThrow(() -> new ServiceException("当前时间段未查询到计费策略明细")); + strategyPriceVO.setDiscountAmount(accountingStrategyDetailVO.getElectrovalence().add(accountingStrategyDetailVO.getServiceCharge()) + .subtract(accountingStrategyDetailVO.getServiceCharge().multiply(accountingStrategy.getDiscount())).setScale(2, BigDecimal.ROUND_HALF_UP)); + // 查询最高抵扣的会员 + TVip maximumDeduction = vipClient.getVipInfoByType(1).getData(); + strategyPriceVO.setMaxDiscountAmount(maximumDeduction.getMaximumDeduction()); + // 查询最低起步价会员 + TVip monthlyCard = vipClient.getVipInfoByType(2).getData(); + strategyPriceVO.setVipStartPrice(monthlyCard.getMonthlyCard()); + // 查询最高折扣的会员 + TVip monthlyCardDiscount = vipClient.getVipInfoByType(3).getData(); + strategyPriceVO.setServiceFeeDiscount(monthlyCardDiscount.getMonthlyCardDiscount()); + return strategyPriceVO; + } } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java index 9d88276..e88f663 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java @@ -105,7 +105,8 @@ if(ajaxResult.isError()){ return ajaxResult; } - long count = this.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()).eq(TChargingGun::getDelFlag, 0)); + long count = this.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()) + .eq(TChargingGun::getDelFlag, 0)); if(count > 0){ return AjaxResult.error("接口编码已存在"); } @@ -129,7 +130,8 @@ if(ajaxResult.isError()){ return ajaxResult; } - TChargingGun one = this.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()).eq(TChargingGun::getDelFlag, 0)); + TChargingGun one = this.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()) + .eq(TChargingGun::getDelFlag, 0)); if(null != one && !dto.getId().equals(one.getId())){ return AjaxResult.error("接口编码已存在"); } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileNotificationServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileNotificationServiceImpl.java index f29d988..b38a11d 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileNotificationServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileNotificationServiceImpl.java @@ -1,10 +1,26 @@ package com.ruoyi.chargingPile.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.chargingPile.api.model.TChargingPileNotification; +import com.ruoyi.chargingPile.domain.SiteMenu; import com.ruoyi.chargingPile.mapper.TChargingPileNotificationMapper; +import com.ruoyi.chargingPile.service.IPartnerService; import com.ruoyi.chargingPile.service.TChargingPileNotificationService; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.other.api.feignClient.RoleSiteClient; +import com.ruoyi.other.api.feignClient.UserSiteClient; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.feignClient.SysUserClient; import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * <p> @@ -16,5 +32,56 @@ */ @Service public class TChargingPileNotificationServiceImpl extends ServiceImpl<TChargingPileNotificationMapper, TChargingPileNotification> implements TChargingPileNotificationService { - + + @Resource + private SysUserClient sysUserClient; + + @Resource + private IPartnerService partnerService; + + @Resource + private UserSiteClient userSiteClient; + + @Resource + private RoleSiteClient roleSiteClient; + + + + + + + /** + * 获取系统通知列表数据 + * @param siteId + * @param basePage + * @return + */ + @Override + public PageInfo<TChargingPileNotification> chargingPileNotificationPageList(Integer siteId, BasePage basePage) { + //校验当前账户站点权限 + Set<Integer> siteIds = null; + if(null == siteId){ + SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); + Integer roleType = sysUser.getRoleType(); + Integer objectId = sysUser.getObjectId(); + LambdaQueryWrapper<Site> wrapper = new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0); + if(2 == roleType){ + siteIds = partnerService.authSite(objectId, SiteMenu.SITE_LIST); + }else{ + //非管理员需要根据角色和用户配置查询允许的站点数据 + if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ + List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); + List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); + data.addAll(data1); + siteIds = new HashSet<>(data); + } + } + }else{ + siteIds = new HashSet<>(siteId); + } + PageInfo<TChargingPileNotification> pageInfo = new PageInfo<>(basePage.getPageCurr(), basePage.getPageSize()); + List<TChargingPileNotification> list = this.baseMapper.chargingPileNotificationPageList(pageInfo, siteIds); + pageInfo.setRecords(list); + return pageInfo; + } } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java index ea3e370..6d771f5 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java @@ -26,6 +26,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -183,20 +184,22 @@ /** * 删除充电桩 - * @param id + * @param ids * @return */ @Override - public AjaxResult delChargingPile(Integer id) { + public AjaxResult delChargingPile(Integer[] ids) { //检查是否有关联数据 //接口 - long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, id).eq(TChargingGun::getDelFlag, 0)); + long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, Arrays.asList(ids)).eq(TChargingGun::getDelFlag, 0)); if(count > 0){ return AjaxResult.error("该充电桩有关联的接口数据,删除失败!"); } - TChargingPile chargingPile = this.getById(id); - chargingPile.setDelFlag(true); - this.updateById(chargingPile); + for (Integer id : ids) { + TChargingPile chargingPile = this.getById(id); + chargingPile.setDelFlag(true); + this.updateById(chargingPile); + } return AjaxResult.success(); } @@ -215,14 +218,14 @@ } @Override - public List<TChargingPileVO> getChargingGunList(Integer siteId) { + public List<TChargingPileVO> getChargingGunList(Integer siteId,Integer type) { List<TChargingPileVO> chargingPileVOS = this.baseMapper.getChargingGunList(siteId); List<TChargingGun> chargingGuns = chargingGunService.list(Wrappers.lambdaQuery(TChargingGun.class) - .eq(TChargingGun::getSiteId, siteId)); + .eq(TChargingGun::getSiteId, siteId) + .eq(TChargingGun::getChargeMode, type)); // 查询充电枪信息 chargingPileVOS.forEach(item -> { - List<TChargingGun> gunList = chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList()); - item.setChargingGunList(gunList); + item.setChargingGunList(chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList())); }); return chargingPileVOS; } diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/PartnerMapper.xml b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/PartnerMapper.xml index 4efbd05..87bd1c9 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/PartnerMapper.xml +++ b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/PartnerMapper.xml @@ -38,6 +38,6 @@ <if test="null != item.roleId and '' != item.name"> and role_id = #{item.roleId} </if> - order by create_time desc limit #{item.pageCurr}, #{item.pageSize} + order by create_time desc </select> </mapper> \ No newline at end of file diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/SiteMapper.xml b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/SiteMapper.xml index 855a4cd..79ce0b7 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/SiteMapper.xml +++ b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/SiteMapper.xml @@ -100,7 +100,7 @@ #{itemm} </foreach> </if> - order by a.sort desc, a.create_time desc limit #{item.pageCurr}, #{item.pageSize} + order by a.sort desc, a.create_time desc </select> <select id="pageList" resultType="com.ruoyi.chargingPile.api.vo.SiteVO"> diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileMapper.xml b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileMapper.xml index 2cab472..0029319 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileMapper.xml +++ b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileMapper.xml @@ -62,7 +62,7 @@ #{itemm} </foreach> </if> - order by a.create_time desc limit #{item.pageCurr}, #{item.pageSize} + order by a.create_time desc </select> diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileNotificationMapper.xml b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileNotificationMapper.xml index 031175c..e35a362 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileNotificationMapper.xml +++ b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingPileNotificationMapper.xml @@ -7,6 +7,7 @@ <id column="id" property="id" /> <result column="site_id" property="siteId" /> <result column="charging_pile_id" property="chargingPileId" /> + <result column="phone" property="phone"/> <result column="content" property="content" /> <result column="create_time" property="createTime" /> <result column="del_flag" property="delFlag" /> @@ -17,4 +18,24 @@ id, site_id, charging_pile_id, content, create_time, del_flag </sql> + + + <select id="chargingPileNotificationPageList" resultType="com.ruoyi.chargingPile.api.model.TChargingPileNotification"> + select + a.id, + b.`name` as siteName, + a.phone, + a.content, + a.create_time as createTime + from t_charging_pile_notification a + left join t_site b on (a.site_id = b.id) + where a.del_flag = 0 + <if test="null != siteIds"> + and a.site_id in + <foreach collection="siteIds" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> + </if> + order by a.create_time desc + </select> </mapper> diff --git a/ruoyi-service/ruoyi-order/pom.xml b/ruoyi-service/ruoyi-order/pom.xml index 9058e31..3488348 100644 --- a/ruoyi-service/ruoyi-order/pom.xml +++ b/ruoyi-service/ruoyi-order/pom.xml @@ -15,6 +15,13 @@ </description> <dependencies> + <!-- ruoyi-modules-other-api --> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>ruoyi-api-other</artifactId> + <version>3.6.2</version> + <scope>compile</scope> + </dependency> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-api-account</artifactId> diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderEvaluateController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderEvaluateController.java index 9b8a2d1..844f56e 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderEvaluateController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderEvaluateController.java @@ -1,9 +1,24 @@ package com.ruoyi.order.controller; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.order.api.model.TOrderEvaluate; +import com.ruoyi.order.api.query.TOrderEvaluateQuery; +import com.ruoyi.order.api.vo.SiteDetailEvaluateVO; +import com.ruoyi.order.api.vo.TOrderEvaluateVO; +import com.ruoyi.order.dto.GetOrderEvaluatePageList; +import com.ruoyi.order.dto.GetOrderEvaluatePageListDTO; +import com.ruoyi.order.service.TOrderEvaluateService; +import com.ruoyi.other.api.vo.TEvaluationTagVO; import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.List; /** * <p> @@ -18,5 +33,84 @@ @RequestMapping("/t-order-evaluate") public class TOrderEvaluateController { + @Autowired + private TOrderEvaluateService orderEvaluateService; + + + @ApiOperation(tags = {"小程序-订单评价"},value = "充电订单评价标签及数量查询") + @PostMapping(value = "/getTagCount") + public AjaxResult<List<TEvaluationTagVO>> getTagCount() { + return AjaxResult.ok(orderEvaluateService.getTagCount()); + } + + @ApiOperation(tags = {"小程序-订单评价"},value = "充电订单评价分页列表查询") + @PostMapping(value = "/pageList") + public AjaxResult<PageInfo<TOrderEvaluateVO>> pageList(@RequestBody TOrderEvaluateQuery query) { + return AjaxResult.ok(orderEvaluateService.getTagList(query)); + } + + + + + + + + @GetMapping(value = "/getPageList") + @ApiOperation(value = "获取充电评价列表", tags = {"管理后台-充电评价"}) + public AjaxResult<PageInfo<GetOrderEvaluatePageListDTO>> getPageList(@RequestBody GetOrderEvaluatePageList pageList){ + PageInfo<GetOrderEvaluatePageListDTO> list = orderEvaluateService.getPageList(pageList); + return AjaxResult.success(list); + } + + + + @DeleteMapping(value = "/delOrderEvaluate") + @ApiOperation(value = "删除充电评价", tags = {"管理后台-充电评价"}) + public AjaxResult delOrderEvaluate(@PathVariable Long id){ + TOrderEvaluate orderEvaluate = orderEvaluateService.getById(id); + orderEvaluate.setDelFlag(true); + orderEvaluateService.updateById(orderEvaluate); + return AjaxResult.success(); + } + + + + + @PostMapping(value = "/replyEvaluation") + @ApiOperation(value = "充电评价回复", tags = {"管理后台-充电评价"}) + public AjaxResult replyEvaluation(@PathVariable("id") Long id, @RequestParam("reply") String reply){ + TOrderEvaluate orderEvaluate = orderEvaluateService.getById(id); + reply = reply.replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #39;", "'") + .replaceAll("& lt;", "<") + .replaceAll("& gt;", ">"); + orderEvaluate.setEvaluationResponse(reply); + orderEvaluate.setResponseTime(LocalDateTime.now()); + orderEvaluateService.updateById(orderEvaluate); + return AjaxResult.success(); + } + + + + + @DeleteMapping(value = "/delOrderEvaluateReply") + @ApiOperation(value = "删除充电评价回复", tags = {"管理后台-充电评价"}) + public AjaxResult delOrderEvaluateReply(@PathVariable Long id){ + TOrderEvaluate orderEvaluate = orderEvaluateService.getById(id); + orderEvaluate.setEvaluationResponse(""); + orderEvaluateService.updateById(orderEvaluate); + return AjaxResult.success(); + } + + + @ApiOperation(tags = {"小程序-订单评价"},value = "电站详情中评价列表查询") + @GetMapping(value = "/getSiteDetailEveList") + public AjaxResult<SiteDetailEvaluateVO> getSiteDetailEveList(@RequestParam(value = "siteId")@ApiParam(value = "站点id")Integer siteId) { + return AjaxResult.ok(orderEvaluateService.getSiteDetailEveList(siteId)); + } + } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageList.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageList.java new file mode 100644 index 0000000..c195f20 --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageList.java @@ -0,0 +1,23 @@ +package com.ruoyi.order.dto; + +import com.ruoyi.common.core.web.page.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author zhibing.pu + * @Date 2024/8/12 19:07 + */ +@Data +@ApiModel +public class GetOrderEvaluatePageList extends BasePage { + @ApiModelProperty(value = "订单编号") + private String code; + @ApiModelProperty(value = "评价内容") + private String content; + @ApiModelProperty(value = "评价类型(1=好评,2=中评,3=差评)") + private Integer evaluateType; + @ApiModelProperty(value = "归属电站id") + private Integer siteId; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageListDTO.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageListDTO.java new file mode 100644 index 0000000..37ac8db --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/GetOrderEvaluatePageListDTO.java @@ -0,0 +1,40 @@ +package com.ruoyi.order.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/8/12 19:09 + */ +@Data +@ApiModel +public class GetOrderEvaluatePageListDTO { + @ApiModelProperty("订单id") + private String id; + @ApiModelProperty("订单编号") + private String code; + private Long appUserId; + @ApiModelProperty("用户头像") + private String avatar; + @ApiModelProperty("用户电话") + private String phone; + @ApiModelProperty("评分") + private Integer mark; + @ApiModelProperty("归属电站名称") + private String siteName; + private Integer siteId; + @ApiModelProperty("评价内容") + private String content; + @ApiModelProperty("评价图片") + private String imgUrl; + @ApiModelProperty("评价时间") + private String createTime; + @ApiModelProperty("评价标签") + private List<String> tags; + @ApiModelProperty("回复内容") + private String recover; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateMapper.java index 8cb9c1b..e428668 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateMapper.java @@ -1,8 +1,18 @@ package com.ruoyi.order.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.api.model.TOrderEvaluate; +import com.ruoyi.order.api.query.TOrderEvaluateQuery; +import com.ruoyi.order.api.vo.TOrderEvaluateVO; +import com.ruoyi.order.dto.GetOrderEvaluatePageList; +import com.ruoyi.order.dto.GetOrderEvaluatePageListDTO; +import com.ruoyi.other.api.vo.TEvaluationTagVO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * <p> @@ -15,4 +25,28 @@ @Mapper public interface TOrderEvaluateMapper extends BaseMapper<TOrderEvaluate> { + /** + * 订单评价分页列表查询 + * @param query + * @param pageInfo + * @return + */ + List<TOrderEvaluateVO> pageList(@Param("query") TOrderEvaluateQuery query,@Param("pageInfo")PageInfo<TOrderEvaluateVO> pageInfo); + + + /** + * 获取充电评价列表数据 + * @param pageList + * @param pageInfo + * @return + */ + List<GetOrderEvaluatePageListDTO> getPageList(@Param("query") GetOrderEvaluatePageList pageList, @Param("evaluationTagIds") List<Integer> evaluationTagIds, + PageInfo<GetOrderEvaluatePageListDTO> pageInfo); + + /** + * 查询站点下的所有订单评价 + * @param siteId + * @return + */ + List<TOrderEvaluateVO> getOrderEvaluateBySiteId(@Param("siteId")Integer siteId); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateTagMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateTagMapper.java index 2d365fc..80d3c73 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateTagMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateTagMapper.java @@ -2,7 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.order.api.model.TOrderEvaluateTag; +import com.ruoyi.other.api.vo.TEvaluationTagVO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -15,4 +19,10 @@ @Mapper public interface TOrderEvaluateTagMapper extends BaseMapper<TOrderEvaluateTag> { + /** + * 获取标签评价数量 + * @param tagIds + * @return + */ + List<TEvaluationTagVO> getCountByTagIds(@Param("tagIds") List<Integer> tagIds); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TOrderEvaluateService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TOrderEvaluateService.java index 0acd943..534d681 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TOrderEvaluateService.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TOrderEvaluateService.java @@ -1,7 +1,17 @@ package com.ruoyi.order.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.api.model.TOrderEvaluate; +import com.ruoyi.order.api.query.TOrderEvaluateQuery; +import com.ruoyi.order.api.vo.SiteDetailEvaluateVO; +import com.ruoyi.order.api.vo.TOrderEvaluateVO; +import com.ruoyi.order.dto.GetOrderEvaluatePageList; +import com.ruoyi.order.dto.GetOrderEvaluatePageListDTO; +import com.ruoyi.other.api.vo.TEvaluationTagVO; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; /** * <p> @@ -13,4 +23,31 @@ */ public interface TOrderEvaluateService extends IService<TOrderEvaluate> { + /** + * 获取评价标签 + * @return + */ + List<TEvaluationTagVO> getTagCount(); + + /** + * 充电订单评价分页列表查询 + * @param query + * @return + */ + PageInfo<TOrderEvaluateVO> getTagList(TOrderEvaluateQuery query); + + /** + * 电站详情中评价列表查询 + * @param siteId + * @return + */ + SiteDetailEvaluateVO getSiteDetailEveList(Integer siteId); + + + /** + * 获取充电评价列表 + * @param pageList + * @return + */ + PageInfo<GetOrderEvaluatePageListDTO> getPageList(GetOrderEvaluatePageList pageList); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java index c636186..44f75a0 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java @@ -1,10 +1,46 @@ package com.ruoyi.order.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.feignClient.AppUserCarClient; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.TAppUser; +import com.ruoyi.account.api.model.TAppUserCar; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.TAppUser; +import com.ruoyi.chargingPile.api.feignClient.SiteClient; +import com.ruoyi.chargingPile.api.model.Site; +import com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.order.api.model.TChargingOrder; import com.ruoyi.order.api.model.TOrderEvaluate; +import com.ruoyi.order.api.model.TOrderEvaluateTag; +import com.ruoyi.order.api.query.TOrderEvaluateQuery; +import com.ruoyi.order.api.vo.SiteDetailEvaluateVO; +import com.ruoyi.order.api.vo.TOrderEvaluateVO; +import com.ruoyi.order.dto.GetOrderEvaluatePageList; +import com.ruoyi.order.dto.GetOrderEvaluatePageListDTO; +import com.ruoyi.order.mapper.TChargingOrderMapper; import com.ruoyi.order.mapper.TOrderEvaluateMapper; +import com.ruoyi.order.mapper.TOrderEvaluateTagMapper; import com.ruoyi.order.service.TOrderEvaluateService; +import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.feignClient.TEvaluationTagClient; +import com.ruoyi.other.api.vo.TEvaluationTagVO; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; /** * <p> @@ -17,4 +53,153 @@ @Service public class TOrderEvaluateServiceImpl extends ServiceImpl<TOrderEvaluateMapper, TOrderEvaluate> implements TOrderEvaluateService { + @Resource + private TEvaluationTagClient evaluationTagClient; + @Resource + private AppUserClient appUserClient; + @Autowired + private AppUserCarClient appUserCarClient; + @Autowired + private TOrderEvaluateTagMapper orderEvaluateTagMapper; + @Resource + private TChargingOrderMapper chargingOrderMapper; + + @Resource + private SiteClient siteClient; + + + + + + + + + + + + + @Autowired + private TOrderEvaluateMapper orderEvaluateMapper; + @Override + public List<TEvaluationTagVO> getTagCount() { + // 查询标签列表 + R<List<TEvaluationTagVO>> r = evaluationTagClient.getTagList(null); + List<TEvaluationTagVO> tagList = r.getData(); + List<Integer> tagIds = tagList.stream().map(TEvaluationTagVO::getId).collect(Collectors.toList()); + // 统计标签使用数量 + List<TEvaluationTagVO> counts = orderEvaluateTagMapper.getCountByTagIds(tagIds); + tagList.forEach(tag -> { + counts.forEach(count -> { + if (tag.getId().equals(count.getId())) { + tag.setTagCount(count.getTagCount()); + } + }); + }); + tagList = tagList.stream().sorted(Comparator.comparing(TEvaluationTagVO::getTagCount).reversed()).collect(Collectors.toList()); + // 统计有图,好评,中差评数量 + long imgUrlCount = this.count(Wrappers.lambdaQuery(TOrderEvaluate.class) + .isNotNull(TOrderEvaluate::getImgUrl)); + packageTagCount(imgUrlCount,"有图",tagList); + long goodCount = this.count(Wrappers.lambdaQuery(TOrderEvaluate.class) + .ge(TOrderEvaluate::getMark,4)); + packageTagCount(goodCount,"好评",tagList); + long badCount = this.count(Wrappers.lambdaQuery(TOrderEvaluate.class) + .le(TOrderEvaluate::getMark,3)); + packageTagCount(badCount,"中差评",tagList); + return tagList; + } + + @Override + public PageInfo<TOrderEvaluateVO> getTagList(TOrderEvaluateQuery query) { + PageInfo<TOrderEvaluateVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize()); + // 查询站点下的所有订单 + List<TChargingOrder> tChargingOrders = chargingOrderMapper.selectList(Wrappers.lambdaQuery(TChargingOrder.class) + .eq(TChargingOrder::getSiteId, query.getSiteId())); + if(CollectionUtils.isEmpty(tChargingOrders)){ + return new PageInfo<>(); + } + List<Long> orderIds = tChargingOrders.stream().map(TChargingOrder::getId).collect(Collectors.toList()); + query.setOrderIds(orderIds); + List<TOrderEvaluateVO> list = this.baseMapper.pageList(query,pageInfo); + // 查询用户信息 + List<TAppUser> appUsers = appUserClient.getUserByIds(list.stream().map(TOrderEvaluateVO::getAppUserId).collect(Collectors.toList())).getData(); + // 查询用户绑定车辆品牌 + List<TAppUserCar> appUserCars = appUserCarClient.getCarByIds(list.stream().map(TOrderEvaluateVO::getAppUserCarId).collect(Collectors.toList())).getData(); + list.forEach(orderEvaluateVO -> { + TAppUser appUser = appUsers.stream().filter(user -> user.getId().equals(orderEvaluateVO.getAppUserId())).findFirst().orElse(null); + if(Objects.nonNull(appUser)){ + orderEvaluateVO.setName(appUser.getName()); + orderEvaluateVO.setAvatar(appUser.getAvatar()); + } + TAppUserCar appUserCar = appUserCars.stream().filter(car -> car.getId().equals(Long.parseLong(String.valueOf(orderEvaluateVO.getAppUserCarId())))).findFirst().orElse(null); + if(Objects.nonNull(appUserCar)){ + orderEvaluateVO.setCarName(appUserCar.getVehicleBrand()); + } + }); + pageInfo.setRecords(list); + return pageInfo; + } + + @Override + public SiteDetailEvaluateVO getSiteDetailEveList(Integer siteId) { + SiteDetailEvaluateVO siteDetailEvaluateVO = new SiteDetailEvaluateVO(); + // 查询站点下的所有订单评价 + List<TOrderEvaluateVO> tChargingOrders = orderEvaluateMapper.getOrderEvaluateBySiteId(siteId); + if(!CollectionUtils.isEmpty(tChargingOrders)){ + siteDetailEvaluateVO.setOrderEvaluateVOS(tChargingOrders); + // 统计好评率 + long goodCount = tChargingOrders.stream().filter(orderEvaluateVO -> orderEvaluateVO.getMark()>=4).count(); + BigDecimal reviewRate = new BigDecimal(goodCount).divide(new BigDecimal(tChargingOrders.size())).setScale(2, BigDecimal.ROUND_HALF_UP); + siteDetailEvaluateVO.setReviewRate(reviewRate); + siteDetailEvaluateVO.setEvaluateCount(tChargingOrders.size()); + siteDetailEvaluateVO.setOrderEvaluateVOS(tChargingOrders.stream().limit(3).collect(Collectors.toList())); + } + return siteDetailEvaluateVO; + } + + /** + * 统计有图,好评,中差评数量 + * @param count + * @param name + * @param tagList + */ + private void packageTagCount(Long count,String name,List<TEvaluationTagVO> tagList){ + if(count>0){ + TEvaluationTagVO evaluationTagVO = new TEvaluationTagVO(); + evaluationTagVO.setName(name); + evaluationTagVO.setTagCount(Integer.parseInt(String.valueOf(count))); + tagList.add(evaluationTagVO); + } + } + + + /** + * 获取充电评价列表 + * @param pageList + * @return + */ + @Override + public PageInfo<GetOrderEvaluatePageListDTO> getPageList(GetOrderEvaluatePageList pageList) { + PageInfo<GetOrderEvaluatePageListDTO> pageInfo = new PageInfo<>(pageList.getPageCurr(), pageList.getPageSize()); + List<Integer> evaluationTagIds = null; + if(null != pageList.getEvaluateType()){ + List<TEvaluationTagVO> data = evaluationTagClient.getTagList(pageList.getEvaluateType()).getData(); + evaluationTagIds = data.stream().map(TEvaluationTagVO::getId).collect(Collectors.toList()); + } + List<GetOrderEvaluatePageListDTO> list = this.baseMapper.getPageList(pageList, evaluationTagIds, pageInfo); + for (GetOrderEvaluatePageListDTO dto : list) { + TAppUser appUser = appUserClient.getUserById(dto.getAppUserId()).getData(); + dto.setAvatar(appUser.getAvatar()); + String phone = appUser.getPhone(); + dto.setPhone(phone.substring(0, 3) + "****" + phone.substring(6)); + Site site = siteClient.getSiteByIds(Arrays.asList(dto.getSiteId())).getData().get(0); + dto.setSiteName(site.getName()); + List<TOrderEvaluateTag> tOrderEvaluateTags = orderEvaluateTagMapper.selectList(new LambdaQueryWrapper<TOrderEvaluateTag>().eq(TOrderEvaluateTag::getOrderEvaluateId, dto.getId())); + List<Integer> tagIds = tOrderEvaluateTags.stream().map(TOrderEvaluateTag::getEvaluationTagId).collect(Collectors.toList()); + List<TEvaluationTag> data = evaluationTagClient.getListByIds(tagIds).getData(); + List<String> collect = data.stream().map(TEvaluationTag::getName).collect(Collectors.toList()); + dto.setTags(collect); + } + return pageInfo.setRecords(list); + } } diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml index 5d95538..210207a 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml @@ -10,6 +10,7 @@ <result column="order_classification" property="orderClassification" /> <result column="app_user_id" property="appUserId" /> <result column="app_user_car_id" property="appUserCarId" /> + <result column="site_id" property="siteId" /> <result column="parking_lot_id" property="parkingLotId" /> <result column="charging_pile_id" property="chargingPileId" /> <result column="charging_gun_id" property="chargingGunId" /> @@ -37,7 +38,7 @@ <!-- 通用查询结果列 --> <sql id="Base_Column_List"> - id, code, order_type, order_classification, app_user_id, app_user_car_id, parking_lot_id, charging_pile_id, charging_gun_id, start_time, end_time, status, recharge_amount, recharge_payment_type, recharge_payment_status, recharge_serial_number, order_amount, app_coupon_id, coupon_discount_amount, vip_discount, vip_discount_amount, payment_amount, refund_code, refund_amount, refund_status, refund_serial_number, refund_time, create_time, del_flag + id, code, order_type, order_classification, app_user_id, app_user_car_id,site_id, parking_lot_id, charging_pile_id, charging_gun_id, start_time, end_time, status, recharge_amount, recharge_payment_type, recharge_payment_status, recharge_serial_number, order_amount, app_coupon_id, coupon_discount_amount, vip_discount, vip_discount_amount, payment_amount, refund_code, refund_amount, refund_status, refund_serial_number, refund_time, create_time, del_flag </sql> </mapper> diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml index 8b88832..f086241 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml @@ -8,6 +8,7 @@ <result column="order_type" property="orderType" /> <result column="order_id" property="orderId" /> <result column="app_user_id" property="appUserId" /> + <result column="app_user_car_id" property="appUserCarId" /> <result column="mark" property="mark" /> <result column="content" property="content" /> <result column="img_url" property="imgUrl" /> @@ -19,7 +20,108 @@ <!-- 通用查询结果列 --> <sql id="Base_Column_List"> - id, order_type, order_id, app_user_id, mark, content, img_url, evaluation_response, create_time, response_time, del_flag + id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response, create_time, response_time, del_flag </sql> + <select id="pageList" resultType="com.ruoyi.order.api.vo.TOrderEvaluateVO"> + select id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response, + create_time, response_time, del_flag + from t_order_evaluate where id in + (select toe.id + from t_order_evaluate toe + left join t_order_evaluate_tag toet on toe.id = toet.order_evaluate_id + <where> + <if test="query.orderIds != null and query.orderIds.size()>0"> + and toe.order_id in + <foreach collection="query.orderIds" item="orderId" open="(" separator="," close=")"> + #{orderId} + </foreach> + </if> + <if test="query.tagType != null"> + <choose> + <when test="query.tagType == 2"> + AND toe.img_url IS NOT NULL + </when> + <when test="query.tagType == 3"> + AND toe.mark >= 4 + </when> + <when test="query.tagType == 4"> + AND toe.mark <= 3 + </when> + <when test="query.tagType == 5"> + AND toet.evaluation_tag_id = #{query.tagId} + </when> + </choose> + </if> + AND toe.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} + </where> + GROUP BY toe.id) + <if test="query.tagType != null"> + <choose> + <when test="query.tagType == 1"> + ORDER BY create_time DESC + </when> + <otherwise> + ORDER BY + CASE + WHEN img_url IS NOT NULL THEN 0 + ELSE 1 + END ASC, + create_time DESC; + </otherwise> + </choose> + </if> + <if test="query.tagType == null"> + ORDER BY + CASE + WHEN img_url IS NOT NULL THEN 0 + ELSE 1 + END ASC, + create_time DESC; + </if> + </select> + <select id="getOrderEvaluateBySiteId" resultType="com.ruoyi.order.api.vo.TOrderEvaluateVO"> + select id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response, + create_time, response_time, del_flag + from t_order_evaluate toe + where toe.order_id in + (select toc.order_id + from t_charging_order toc + where toc.site_id = #{siteId} + and toc.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}) + </select> + + + <select id="getPageList" resultType="com.ruoyi.order.dto.GetOrderEvaluatePageListDTO"> + select + CAST(a.id AS CHAR) as id, + b.`code`, + a.mark, + b.site_id as siteId, + b.app_user_id as appUserId, + a.content, + a.img_url as imgUrl, + DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as createTime, + a.evaluation_response as `recover` + from t_order_evaluate a + left join t_charging_order b on (a.order_id = b.id) + where a.order_type = 1 and a.del_flag = 0 + <if test="null != query.code and '' != query.code"> + and b.`code` like CONCAT('%', #{query.code}, '%') + </if> + <if test="null != query.content and '' != query.content"> + and a.content like CONCAT('%', #{query.content}, '%') + </if> + <if test="null != query.evaluateType"> + and a.id in (select order_evaluate_id from t_order_evaluate_tag where evaluation_tag_id in + <foreach collection="evaluationTagIds" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> + ) + </if> + <if test="null != query.siteId"> + and b.site_id = #{query.siteId} + </if> + order by a.create_time desc + </select> </mapper> diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateTagMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateTagMapper.xml index d48e938..d1ee724 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateTagMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateTagMapper.xml @@ -13,5 +13,17 @@ <sql id="Base_Column_List"> id, order_evaluate_id, evaluation_tag_id </sql> + <select id="getCountByTagIds" resultType="com.ruoyi.other.api.vo.TEvaluationTagVO"> + SELECT evaluation_tag_id,count(id) AS tagCount FROM t_order_evaluate_tag + <where> + <if test="tagIds != null and tagIds.size() > 0"> + AND evaluation_tag_id IN + <foreach collection="tagIds" item="tagId" open="(" separator="," close=")"> + #{tagId} + </foreach> + </if> + </where> + GROUP BY evaluation_tag_id + </select> </mapper> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TEvaluationTagController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TEvaluationTagController.java index 1193555..6b55808 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TEvaluationTagController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TEvaluationTagController.java @@ -1,9 +1,21 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.domain.TInvoiceType; +import com.ruoyi.other.api.vo.TEvaluationTagVO; +import com.ruoyi.other.query.InvoiceTypePageList; +import com.ruoyi.other.service.TEvaluationTagService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; +import java.util.Arrays; +import java.util.List; /** * <p> @@ -17,5 +29,77 @@ @RequestMapping("/t-evaluation-tag") public class TEvaluationTagController { + private final TEvaluationTagService evaluationTagService; + + @Autowired + public TEvaluationTagController(TEvaluationTagService evaluationTagService) { + this.evaluationTagService = evaluationTagService; + } + + @PostMapping("/getTagList") + public R<List<TEvaluationTagVO>> getTagList() { + return R.ok(evaluationTagService.getTagList()); + } + + + + @ResponseBody + @GetMapping("/pageList") + @ApiOperation(value = "获取评价标签列表", tags = {"管理后台-评价标签设置"}) + public AjaxResult<PageInfo<TEvaluationTag>> pageList(String name, BasePage basePage){ + PageInfo<TEvaluationTag> pageInfo = evaluationTagService.pageList(name, basePage); + return AjaxResult.success(pageInfo); + } + + + @ResponseBody + @PostMapping("/addEvaluationTag") + @ApiOperation(value = "添加评价标签", tags = {"管理后台-评价标签设置"}) + public AjaxResult addEvaluationTag(@RequestBody TEvaluationTag evaluationTag){ + evaluationTagService.save(evaluationTag); + return AjaxResult.success(); + } + + @ResponseBody + @GetMapping("/getEvaluationTagInfo/{id}") + @ApiOperation(value = "获取评价标签详情", tags = {"管理后台-评价标签设置"}) + public AjaxResult<TEvaluationTag> getEvaluationTagInfo(@PathVariable Integer id){ + TEvaluationTag evaluationTag = evaluationTagService.getById(id); + return AjaxResult.success(evaluationTag); + } + + + @ResponseBody + @PostMapping("/editEvaluationTag") + @ApiOperation(value = "编辑评价标签", tags = {"管理后台-评价标签设置"}) + public AjaxResult editEvaluationTag(@RequestBody TEvaluationTag evaluationTag){ + evaluationTagService.updateById(evaluationTag); + return AjaxResult.success(); + } + + + @ResponseBody + @DeleteMapping("/delEvaluationTag/{id}") + @ApiOperation(value = "删除评价标签", tags = {"管理后台-评价标签设置"}) + public AjaxResult<TInvoiceType> delEvaluationTag(@PathVariable Integer[] id){ + List<TEvaluationTag> tEvaluationTags = evaluationTagService.listByIds(Arrays.asList(id)); + for (TEvaluationTag evaluationTag : tEvaluationTags) { + evaluationTag.setDelFlag(true); + evaluationTagService.updateById(evaluationTag); + } + return AjaxResult.success(); + } + + + /** + * 根据id集合获取数据 + * @param tagIds + * @return + */ + @GetMapping("/getListByIds") + public R<List<TEvaluationTag>> getListByIds(List<Integer> tagIds){ + List<TEvaluationTag> tEvaluationTags = evaluationTagService.listByIds(tagIds); + return R.ok(tEvaluationTags); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TInvoiceTypeController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TInvoiceTypeController.java index bb00ff7..6c55b54 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TInvoiceTypeController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TInvoiceTypeController.java @@ -1,9 +1,17 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.other.api.domain.TInvoiceType; +import com.ruoyi.other.query.InvoiceTypePageList; +import com.ruoyi.other.service.TInvoiceTypeService; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.List; /** * <p> @@ -16,6 +24,56 @@ @RestController @RequestMapping("/t-invoice-type") public class TInvoiceTypeController { - + + @Resource + private TInvoiceTypeService invoiceTypeService; + + + @ResponseBody + @GetMapping("/pageList") + @ApiOperation(value = "获取发票类型列表", tags = {"管理后台-发票类型管理"}) + public AjaxResult<PageInfo<TInvoiceType>> pageList(InvoiceTypePageList pageList){ + PageInfo<TInvoiceType> pageInfo = invoiceTypeService.pageList(pageList); + return AjaxResult.success(pageInfo); + } + + + @ResponseBody + @PostMapping("/addInvoiceType") + @ApiOperation(value = "添加发票类型", tags = {"管理后台-发票类型管理"}) + public AjaxResult addInvoiceType(@RequestBody TInvoiceType invoiceType){ + invoiceTypeService.save(invoiceType); + return AjaxResult.success(); + } + + @ResponseBody + @GetMapping("/getInvoiceTypeInfo/{id}") + @ApiOperation(value = "获取发票类型详情", tags = {"管理后台-发票类型管理"}) + public AjaxResult<TInvoiceType> getInvoiceTypeInfo(@PathVariable Integer id){ + TInvoiceType invoiceType = invoiceTypeService.getById(id); + return AjaxResult.success(invoiceType); + } + + + @ResponseBody + @PostMapping("/editInvoiceType") + @ApiOperation(value = "编辑发票类型", tags = {"管理后台-发票类型管理"}) + public AjaxResult editInvoiceType(@RequestBody TInvoiceType invoiceType){ + invoiceTypeService.updateById(invoiceType); + return AjaxResult.success(); + } + + + @ResponseBody + @DeleteMapping("/delInvoiceType/{id}") + @ApiOperation(value = "删除发票类型", tags = {"管理后台-发票类型管理"}) + public AjaxResult<TInvoiceType> delInvoiceType(@PathVariable Integer[] id){ + List<TInvoiceType> tInvoiceTypes = invoiceTypeService.listByIds(Arrays.asList(id)); + for (TInvoiceType invoiceType : tInvoiceTypes) { + invoiceType.setDelFlag(true); + invoiceTypeService.updateById(invoiceType); + } + return AjaxResult.success(); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TRoleSiteController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TRoleSiteController.java index 9be842e..043a2cd 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TRoleSiteController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TRoleSiteController.java @@ -26,15 +26,41 @@ @Resource private TRoleSiteService roleSiteService; - + /** + * 查询角色站点数据 + * @param roleId + * @return + */ @ResponseBody @GetMapping("/getSiteIds") - public R<List<Integer>> getSiteIds(@RequestParam("roleId") Long roleId){ + public R<List<Integer>> getSiteIds(Long roleId){ List<TRoleSite> list = roleSiteService.list(new LambdaQueryWrapper<TRoleSite>().eq(TRoleSite::getRoleId, roleId)); List<Integer> collect = list.stream().map(TRoleSite::getSiteId).collect(Collectors.toList()); return R.ok(collect); } + /** + * 添加角色站点数据 + * @param roleSites + * @return + */ + @ResponseBody + @PostMapping("/getSiteIds") + public R addRoleSite(@RequestBody List<TRoleSite> roleSites){ + roleSiteService.saveBatch(roleSites); + return R.ok(); + } + /** + * 删除角色站点数据 + * @param roleId + * @return + */ + @ResponseBody + @DeleteMapping("/delRoleSite/{roleId}") + public R delRoleSite(@PathVariable("roleId") Long roleId){ + roleSiteService.remove(new LambdaQueryWrapper<TRoleSite>().eq(TRoleSite::getRoleId, roleId)); + return R.ok(); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TUserSiteController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TUserSiteController.java index 2c9b26b..686f3b9 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TUserSiteController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TUserSiteController.java @@ -34,12 +34,35 @@ */ @ResponseBody @GetMapping("/getSiteIds") - public R<List<Integer>> getSiteIds(@RequestParam("userId") Long userId){ + public R<List<Integer>> getSiteIds(Long userId){ List<TUserSite> list = userSiteService.list(new LambdaQueryWrapper<TUserSite>().eq(TUserSite::getUserId, userId)); List<Integer> collect = list.stream().map(TUserSite::getSiteId).collect(Collectors.toList()); return R.ok(collect); } + /** + * 添加用户站点数据 + * @param userSite + * @return + */ + @ResponseBody + @PostMapping("/addUserSite") + public R addUserSite(@RequestBody List<TUserSite> userSite){ + userSiteService.saveBatch(userSite); + return R.ok(); + } + + /** + * 删除用户对应的站点数据 + * @param userId + * @return + */ + @ResponseBody + @DeleteMapping("/delUserSite/{userId}") + public R delUserSite(@PathVariable Long userId){ + userSiteService.remove(new LambdaQueryWrapper<TUserSite>().eq(TUserSite::getUserId, userId)); + return R.ok(); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java index b2f94b8..6942f7e 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java @@ -1,6 +1,7 @@ package com.ruoyi.other.controller; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageInfo; @@ -78,5 +79,31 @@ return R.ok(idNameMap); } + /** + * 获取最高抵扣、最低起步价,最高折扣的会员 + * @param type 1=最高抵扣、2=最低起步价,3=最高折扣 + * @return + */ + @PostMapping(value = "/getVipInfoByType") + public R<TVip> getVipInfoByType(@RequestParam Integer type){ + switch (type){ + case 1: + return R.ok(vipService.getOne(Wrappers.lambdaQuery(TVip.class) + .eq(TVip::getReveal,1) + .orderByDesc(TVip::getMaximumDeduction) + .last("LIMIT 1"))); + case 2: + return R.ok(vipService.getOne(Wrappers.lambdaQuery(TVip.class) + .eq(TVip::getReveal,1) + .orderByAsc(TVip::getMonthlyCard) + .last("LIMIT 1"))); + default: + return R.ok(vipService.getOne(Wrappers.lambdaQuery(TVip.class) + .eq(TVip::getReveal,1) + .orderByDesc(TVip::getMonthlyCardDiscount) + .last("LIMIT 1"))); + } + } + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TEvaluationTagMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TEvaluationTagMapper.java index 986b666..4376dbf 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TEvaluationTagMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TEvaluationTagMapper.java @@ -1,7 +1,12 @@ package com.ruoyi.other.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.vo.TEvaluationTagVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -13,4 +18,18 @@ */ public interface TEvaluationTagMapper extends BaseMapper<TEvaluationTag> { + /** + * 获取评价标签列表 + * @return + */ + List<TEvaluationTagVO> getTagList(); + + + /** + * 获取列表数据 + * @param pageInfo + * @param name + * @return + */ + List<TEvaluationTag> pageList(PageInfo<TEvaluationTag> pageInfo, @Param("name") String name); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TInvoiceTypeMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TInvoiceTypeMapper.java index 5b284f1..fac2361 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TInvoiceTypeMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TInvoiceTypeMapper.java @@ -1,7 +1,12 @@ package com.ruoyi.other.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TInvoiceType; +import com.ruoyi.other.query.InvoiceTypePageList; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -12,5 +17,7 @@ * @since 2024-08-06 */ public interface TInvoiceTypeMapper extends BaseMapper<TInvoiceType> { - + + + List<TInvoiceType> pageList(PageInfo<TInvoiceType> pageInfo, @Param("req") InvoiceTypePageList pageList); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/query/InvoiceTypePageList.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/query/InvoiceTypePageList.java new file mode 100644 index 0000000..ab62966 --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/query/InvoiceTypePageList.java @@ -0,0 +1,21 @@ +package com.ruoyi.other.query; + +import com.ruoyi.common.core.web.page.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author zhibing.pu + * @Date 2024/8/12 18:07 + */ +@Data +@ApiModel +public class InvoiceTypePageList extends BasePage { + @ApiModelProperty(value = "类型名称") + private String name; + @ApiModelProperty(value = "公司名称") + private String company; + @ApiModelProperty(value = "开票方式(1=人工,2=自动)") + private Integer method; +} diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TEvaluationTagService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TEvaluationTagService.java index 074149f..7b0cb82 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TEvaluationTagService.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TEvaluationTagService.java @@ -1,7 +1,12 @@ package com.ruoyi.other.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.vo.TEvaluationTagVO; + +import java.util.List; /** * <p> @@ -13,4 +18,18 @@ */ public interface TEvaluationTagService extends IService<TEvaluationTag> { + /** + * 查询标签列表 + * @return + */ + List<TEvaluationTagVO> getTagList(); + + + /** + * 获取列表页数据 + * @param name + * @param basePage + * @return + */ + PageInfo<TEvaluationTag> pageList(String name, BasePage basePage); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TInvoiceTypeService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TInvoiceTypeService.java index 2f3502e..057ef7b 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TInvoiceTypeService.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TInvoiceTypeService.java @@ -1,7 +1,9 @@ package com.ruoyi.other.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TInvoiceType; +import com.ruoyi.other.query.InvoiceTypePageList; /** * <p> @@ -12,5 +14,11 @@ * @since 2024-08-06 */ public interface TInvoiceTypeService extends IService<TInvoiceType> { - + + /** + * 获取发票类型列表数据 + * @param pageList + * @return + */ + PageInfo<TInvoiceType> pageList(InvoiceTypePageList pageList); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TEvaluationTagServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TEvaluationTagServiceImpl.java index 459f90b..f6448d9 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TEvaluationTagServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TEvaluationTagServiceImpl.java @@ -1,10 +1,15 @@ package com.ruoyi.other.service.impl; +import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TEvaluationTag; +import com.ruoyi.other.api.vo.TEvaluationTagVO; import com.ruoyi.other.mapper.TEvaluationTagMapper; import com.ruoyi.other.service.TEvaluationTagService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; + +import java.util.List; /** * <p> @@ -17,4 +22,22 @@ @Service public class TEvaluationTagServiceImpl extends ServiceImpl<TEvaluationTagMapper, TEvaluationTag> implements TEvaluationTagService { + @Override + public List<TEvaluationTagVO> getTagList() { + return this.baseMapper.getTagList(); + } + + + /** + * 获取列表数据 + * @param name + * @param basePage + * @return + */ + @Override + public PageInfo<TEvaluationTag> pageList(String name, BasePage basePage) { + PageInfo<TEvaluationTag> pageInfo = new PageInfo<>(basePage.getPageCurr(), basePage.getPageSize()); + List<TEvaluationTag> list = this.baseMapper.pageList(pageInfo, name); + return pageInfo.setRecords(list); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TInvoiceTypeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TInvoiceTypeServiceImpl.java index f96a0aa..d519cff 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TInvoiceTypeServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TInvoiceTypeServiceImpl.java @@ -1,10 +1,14 @@ package com.ruoyi.other.service.impl; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TInvoiceType; import com.ruoyi.other.mapper.TInvoiceTypeMapper; +import com.ruoyi.other.query.InvoiceTypePageList; import com.ruoyi.other.service.TInvoiceTypeService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; + +import java.util.List; /** * <p> @@ -16,5 +20,18 @@ */ @Service public class TInvoiceTypeServiceImpl extends ServiceImpl<TInvoiceTypeMapper, TInvoiceType> implements TInvoiceTypeService { - + + + /** + * 获取发票类型列表数据 + * @param pageList + * @return + */ + @Override + public PageInfo<TInvoiceType> pageList(InvoiceTypePageList pageList) { + PageInfo<TInvoiceType> pageInfo = new PageInfo<>(pageList.getPageCurr(), pageList.getPageSize()); + List<TInvoiceType> list = this.baseMapper.pageList(pageInfo, pageList); + pageInfo.setRecords(list); + return pageInfo; + } } diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TEvaluationTagMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TEvaluationTagMapper.xml index c39aee9..ec534eb 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TEvaluationTagMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TEvaluationTagMapper.xml @@ -5,15 +5,28 @@ <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.ruoyi.other.api.domain.TEvaluationTag"> <id column="id" property="id" /> - <result column="name" property="name" /> - <result column="type" property="type" /> + <result column="`name`" property="name" /> + <result column="`type`" property="type" /> <result column="create_time" property="createTime" /> <result column="del_flag" property="delFlag" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> - id, name, type, create_time, del_flag + id, `name`, `type`, create_time, del_flag </sql> + <select id="getTagList" resultType="com.ruoyi.other.api.vo.TEvaluationTagVO"> + select <include refid="Base_Column_List"></include> + from t_evaluation_tag where del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} ORDER BY `type` + </select> + + + <select id="pageList" resultMap="BaseResultMap"> + select * from t_evaluation_tag where del_flag = 0 + <if test="null != name and '' != name"> + and name like CONCAT('%', #{name}, '%') + </if> + order by create_time desc + </select> </mapper> diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TInvoiceTypeMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TInvoiceTypeMapper.xml index 2688cdd..c7e7c76 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/TInvoiceTypeMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/TInvoiceTypeMapper.xml @@ -20,4 +20,18 @@ id, name, invoicing_company, invoicing_method, electricity_tariff, service_tariff, added_service_tariff, del_flag, create_time </sql> + + <select id="pageList" resultMap="BaseResultMap"> + select * from t_invoice_type where del_flag = 0 + <if test="null != req.name and '' != req.name"> + and name like CONCAT('%', #{req.name}, '%') + </if> + <if test="null != req.company and '' != req.company"> + and invoicing_company like CONCAT('%', #{req.company}, '%') + </if> + <if test="null != req.method"> + and invoicing_method = #{req.method} + </if> + order by create_time desc + </select> </mapper> -- Gitblit v1.7.1