diff --git a/README.md b/README.md index 230f570..e7b3d76 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,12 @@ 这是一个基于Jdk21,框架是SpringCloud + Springboot3 + Mybatis-plus的脚手架。 -- 主框架基于:Spring Cloud、Spring Boot、Mybatis-plus +- 主框架基于:Spring Cloud、Spring Boot +- 数据ORM基于:Mybatis-plus - 注册中心基于:Eureka - 监控中心基于:Spring Admin -- 登陆安全基于:Spring Security、jjwt、redisson -- 接口文档基于:Swagger-knife4j -- 限流基于:Google-guava -- 分布式定时任务基于:Elastic-job -- 推送聊天基于:Netty +- 登陆安全基于:Spring Security、jjwt +- 接口文档基于:knife4j - 分库分表读写分离基于:Sharding-jdbc diff --git a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/auth/AuthenticationController.java b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/auth/AuthenticationController.java index 140461e..9f68453 100644 --- a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/auth/AuthenticationController.java +++ b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/auth/AuthenticationController.java @@ -34,7 +34,7 @@ * @version 1.0.0 * @date 2024/5/9 15:10 */ -@Tag(name = "员工信息") +@Tag(name = "鉴权相关") @ApiResponses(value = { @ApiResponse(responseCode = "0", description = "成功"), @ApiResponse(responseCode = "1", description = "失败") diff --git a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/staff/StaffInfoController.java b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/staff/StaffInfoController.java index 2de8bab..284423d 100644 --- a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/staff/StaffInfoController.java +++ b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/controller/staff/StaffInfoController.java @@ -1,21 +1,24 @@ package com.liyz.cloud.api.staff.controller.staff; -import com.liyz.cloud.api.staff.vo.staff.StaffInfoVO; +import com.liyz.cloud.api.staff.vo.staff.StaffInfoApiVO; import com.liyz.cloud.common.api.context.AuthContext; import com.liyz.cloud.common.base.util.BeanUtil; -import com.liyz.cloud.common.exception.CommonExceptionCodeEnum; import com.liyz.cloud.common.feign.bo.RemotePage; import com.liyz.cloud.common.feign.bo.auth.AuthUserBO; import com.liyz.cloud.common.feign.dto.PageDTO; import com.liyz.cloud.common.feign.result.PageResult; import com.liyz.cloud.common.feign.result.Result; -import com.liyz.cloud.service.staff.bo.info.StaffInfoBO; +import com.liyz.cloud.service.staff.dto.log.StaffLogPageDTO; import com.liyz.cloud.service.staff.feign.StaffInfoFeignService; +import com.liyz.cloud.service.staff.vo.info.StaffInfoVO; +import com.liyz.cloud.service.staff.vo.log.StaffLoginLogVO; +import com.liyz.cloud.service.staff.vo.log.StaffLogoutLogVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -43,19 +46,36 @@ public class StaffInfoController { @Operation(summary = "查询当前登录员工信息") @GetMapping("/current") - public Result userInfo() { + public Result userInfo() { AuthUserBO authUser = AuthContext.getAuthUser(); - Result result = staffInfoFeignService.getByStaffId(authUser.getAuthId()); - return Result.success(BeanUtil.copyProperties(result.getData(), StaffInfoVO::new)); + Result result = staffInfoFeignService.getByStaffId(authUser.getAuthId()); + return Result.result(result, BeanUtil.copyProperties(result.getData(), StaffInfoApiVO::new)); } @Operation(summary = "分页查询员工信息") @GetMapping("/page") - public PageResult page(PageDTO page) { - Result> pageResult = staffInfoFeignService.page(page); - if (CommonExceptionCodeEnum.SUCCESS.getCode().equals(pageResult.getCode())) { - return PageResult.success(BeanUtil.copyRemotePage(pageResult.getData(), StaffInfoVO::new)); - } - return PageResult.error(pageResult.getCode(), pageResult.getMessage()); + public PageResult page(PageDTO page) { + Result> pageResult = staffInfoFeignService.page(page); + return PageResult.result(pageResult, BeanUtil.copyRemotePage(pageResult.getData(), StaffInfoApiVO::new)); + } + + @Operation(summary = "分页查询员工登录信息") + @GetMapping("/login/page") + public PageResult loginPage(@Valid PageDTO page) { + StaffLogPageDTO pageDTO = BeanUtil.copyProperties(page, StaffLogPageDTO::new, (s, t) -> { + t.setStaffId(AuthContext.getAuthUser().getAuthId()); + }); + Result> pageResult = staffInfoFeignService.loginPage(pageDTO); + return PageResult.result(pageResult, pageResult.getData()); + } + + @Operation(summary = "分页查询员工登出信息") + @GetMapping("/logout/page") + public PageResult logoutPage(@Valid PageDTO page) { + StaffLogPageDTO pageDTO = BeanUtil.copyProperties(page, StaffLogPageDTO::new, (s, t) -> { + t.setStaffId(AuthContext.getAuthUser().getAuthId()); + }); + Result> pageResult = staffInfoFeignService.logoutPage(pageDTO); + return PageResult.result(pageResult, pageResult.getData()); } } diff --git a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffInfoVO.java b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffInfoApiVO.java similarity index 95% rename from cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffInfoVO.java rename to cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffInfoApiVO.java index 21af51b..f93f401 100644 --- a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffInfoVO.java +++ b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffInfoApiVO.java @@ -20,7 +20,7 @@ */ @Getter @Setter -public class StaffInfoVO implements Serializable { +public class StaffInfoApiVO implements Serializable { @Serial private static final long serialVersionUID = 3401036150852744531L; diff --git a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLoginLogVO.java b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLoginLogApiVO.java similarity index 93% rename from cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLoginLogVO.java rename to cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLoginLogApiVO.java index 2f53436..c01848d 100644 --- a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLoginLogVO.java +++ b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLoginLogApiVO.java @@ -18,7 +18,7 @@ */ @Getter @Setter -public class StaffLoginLogVO implements Serializable { +public class StaffLoginLogApiVO implements Serializable { @Serial private static final long serialVersionUID = 378737454967076747L; diff --git a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLogoutLogVO.java b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLogoutLogApiVO.java similarity index 93% rename from cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLogoutLogVO.java rename to cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLogoutLogApiVO.java index 1201087..3587601 100644 --- a/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLogoutLogVO.java +++ b/cloud-api/cloud-api-staff/src/main/java/com/liyz/cloud/api/staff/vo/staff/StaffLogoutLogApiVO.java @@ -18,7 +18,7 @@ */ @Getter @Setter -public class StaffLogoutLogVO implements Serializable { +public class StaffLogoutLogApiVO implements Serializable { @Serial private static final long serialVersionUID = 787994069214271291L; diff --git a/cloud-api/cloud-api-staff/src/main/resources/static/favicon.ico b/cloud-api/cloud-api-staff/src/main/resources/static/favicon.ico new file mode 100644 index 0000000..6fd5bd6 Binary files /dev/null and b/cloud-api/cloud-api-staff/src/main/resources/static/favicon.ico differ diff --git a/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/bo/RemotePage.java b/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/bo/RemotePage.java index 0cc4f40..514be6c 100644 --- a/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/bo/RemotePage.java +++ b/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/bo/RemotePage.java @@ -15,6 +15,7 @@ * @version 1.0.0 * @date 2023/11/13 10:30 */ +@Getter public class RemotePage implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -29,21 +30,17 @@ public RemotePage(List list, long total, long pageNum, long pageSize) { this.pageSize = pageSize; } - @Getter @Setter @Schema(description = "结果集") private List list; - @Getter @Setter @Schema(description = "总记录数") private long total; - @Getter @Schema(description = "当前页") private long pageNum; - @Getter @Schema(description = "每页的数量") private long pageSize; diff --git a/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/PageResult.java b/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/PageResult.java index b308d55..8847119 100644 --- a/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/PageResult.java +++ b/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/PageResult.java @@ -75,6 +75,13 @@ public static PageResult error(IExceptionService codeEnum) { return new PageResult<>(codeEnum); } + public static PageResult result(Result> result, RemotePage data) { + if (CommonExceptionCodeEnum.SUCCESS.getCode().equals(result.getCode())) { + return success(data); + } + return error(result.getCode(), result.getMessage()); + } + public void setPageNum(long pageNum) { this.pageNum = Math.max(1L, pageNum); } diff --git a/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/Result.java b/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/Result.java index 78db713..0772d9b 100644 --- a/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/Result.java +++ b/cloud-common/cloud-common-feign/src/main/java/com/liyz/cloud/common/feign/result/Result.java @@ -61,4 +61,11 @@ public static Result error(IExceptionService codeEnum) { public static Result error(String code, String message) { return new Result<>(code, message); } + + public static Result result(Result result, E data) { + if (CommonExceptionCodeEnum.SUCCESS.getCode().equals(result.getCode())) { + return success(data); + } + return error(result.getCode(), result.getMessage()); + } } diff --git a/cloud-service/cloud-service-staff/staff-biz/src/main/java/com/liyz/cloud/service/staff/runner/HikariPoolInitRunner.java b/cloud-service/cloud-service-staff/staff-biz/src/main/java/com/liyz/cloud/service/staff/runner/HikariPoolInitRunner.java new file mode 100644 index 0000000..e76dd2a --- /dev/null +++ b/cloud-service/cloud-service-staff/staff-biz/src/main/java/com/liyz/cloud/service/staff/runner/HikariPoolInitRunner.java @@ -0,0 +1,32 @@ +package com.liyz.cloud.service.staff.runner; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.liyz.cloud.service.staff.model.StaffLoginLogDO; +import com.liyz.cloud.service.staff.service.StaffLoginLogService; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +/** + * Desc:数据库连接池初始化 + * + * @author lyz + * @version 1.0.0 + * @date 2023/3/14 9:19 + */ +@Slf4j +@Component +public class HikariPoolInitRunner implements ApplicationRunner { + + @Resource + private StaffLoginLogService staffLoginLogService; + + @Override + public void run(ApplicationArguments args) throws Exception { + StaffLoginLogDO staffLoginLogDO = staffLoginLogService.getOne( + Wrappers.lambdaQuery(StaffLoginLogDO.builder().staffId(1L).build()), false); + log.info("hikari pool init success"); + } +} diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/dto/log/StaffLogPageDTO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/dto/log/StaffLogPageDTO.java new file mode 100644 index 0000000..bfe57e5 --- /dev/null +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/dto/log/StaffLogPageDTO.java @@ -0,0 +1,23 @@ +package com.liyz.cloud.service.staff.dto.log; + +import com.liyz.cloud.common.feign.dto.PageDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Desc: + * + * @author lyz + * @version 1.0.0 + * @date 2024/10/30 15:23 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class StaffLogPageDTO extends PageDTO { + + @Schema(description = "用户ID") + @NotNull(message = "用户ID不能为空") + private Long staffId; +} diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/feign/StaffInfoFeignService.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/feign/StaffInfoFeignService.java index 96fe5c7..3e026a6 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/feign/StaffInfoFeignService.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/feign/StaffInfoFeignService.java @@ -3,9 +3,13 @@ import com.liyz.cloud.common.feign.bo.RemotePage; import com.liyz.cloud.common.feign.dto.PageDTO; import com.liyz.cloud.common.feign.result.Result; -import com.liyz.cloud.service.staff.bo.info.StaffInfoBO; import com.liyz.cloud.service.staff.constants.StaffConstants; +import com.liyz.cloud.service.staff.dto.log.StaffLogPageDTO; +import com.liyz.cloud.service.staff.vo.info.StaffInfoVO; +import com.liyz.cloud.service.staff.vo.log.StaffLoginLogVO; +import com.liyz.cloud.service.staff.vo.log.StaffLogoutLogVO; import io.swagger.v3.oas.annotations.Operation; +import jakarta.validation.Valid; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -25,9 +29,17 @@ public interface StaffInfoFeignService { @Operation(summary = "根据staffId获取用户信息") @GetMapping( "/getByStaffId") - Result getByStaffId(@RequestParam("staffId") Long staffId); + Result getByStaffId(@RequestParam("staffId") Long staffId); @Operation(summary = "分页查询员工信息") @PostMapping("/page") - Result> page(@RequestBody PageDTO pageDTO); + Result> page(@RequestBody PageDTO pageDTO); + + @Operation(summary = "分页查询员工登录信息") + @PostMapping("/login/page") + Result> loginPage(@Valid @RequestBody StaffLogPageDTO pageDTO); + + @Operation(summary = "分页查询员工登出信息") + @PostMapping("/logout/page") + Result> logoutPage(@Valid @RequestBody StaffLogPageDTO pageDTO); } diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/info/StaffInfoBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/info/StaffInfoVO.java similarity index 91% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/info/StaffInfoBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/info/StaffInfoVO.java index 4534ee2..89b0726 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/info/StaffInfoBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/info/StaffInfoVO.java @@ -1,4 +1,4 @@ -package com.liyz.cloud.service.staff.bo.info; +package com.liyz.cloud.service.staff.vo.info; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; @@ -18,7 +18,7 @@ */ @Getter @Setter -public class StaffInfoBO implements Serializable { +public class StaffInfoVO implements Serializable { @Serial private static final long serialVersionUID = 477985923412638468L; diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/log/StaffLoginLogBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/log/StaffLoginLogVO.java similarity index 76% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/log/StaffLoginLogBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/log/StaffLoginLogVO.java index 27dbce8..35add38 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/log/StaffLoginLogBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/log/StaffLoginLogVO.java @@ -1,5 +1,6 @@ -package com.liyz.cloud.service.staff.bo.log; +package com.liyz.cloud.service.staff.vo.log; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; @@ -17,7 +18,7 @@ */ @Getter @Setter -public class StaffLoginLogBO implements Serializable { +public class StaffLoginLogVO implements Serializable { @Serial private static final long serialVersionUID = -8978119199629210583L; @@ -30,6 +31,7 @@ public class StaffLoginLogBO implements Serializable { @Schema(description = "用户设备") private Integer device; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @Schema(description = "用户登录时间") private Date loginTime; diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/log/StaffLogoutLogBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/log/StaffLogoutLogVO.java similarity index 76% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/log/StaffLogoutLogBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/log/StaffLogoutLogVO.java index 02e9318..d6ce363 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/log/StaffLogoutLogBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/log/StaffLogoutLogVO.java @@ -1,5 +1,6 @@ -package com.liyz.cloud.service.staff.bo.log; +package com.liyz.cloud.service.staff.vo.log; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; @@ -17,7 +18,7 @@ */ @Getter @Setter -public class StaffLogoutLogBO implements Serializable { +public class StaffLogoutLogVO implements Serializable { @Serial private static final long serialVersionUID = 3070437801653890936L; @@ -30,6 +31,7 @@ public class StaffLogoutLogBO implements Serializable { @Schema(description = "用户设备") private Integer device; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @Schema(description = "用户登录时间") private Date logoutTime; diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/StaffRoleBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/StaffRoleVO.java similarity index 82% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/StaffRoleBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/StaffRoleVO.java index ef0baaf..ecb7cb9 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/StaffRoleBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/StaffRoleVO.java @@ -1,4 +1,4 @@ -package com.liyz.cloud.service.staff.bo.role; +package com.liyz.cloud.service.staff.vo.role; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; @@ -16,7 +16,7 @@ */ @Getter @Setter -public class StaffRoleBO implements Serializable { +public class StaffRoleVO implements Serializable { @Serial private static final long serialVersionUID = -5019855188001537438L; diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemAuthorityBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemAuthorityVO.java similarity index 87% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemAuthorityBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemAuthorityVO.java index f3ad14d..6505fe0 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemAuthorityBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemAuthorityVO.java @@ -1,4 +1,4 @@ -package com.liyz.cloud.service.staff.bo.role; +package com.liyz.cloud.service.staff.vo.role; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; @@ -16,7 +16,7 @@ */ @Getter @Setter -public class SystemAuthorityBO implements Serializable { +public class SystemAuthorityVO implements Serializable { @Serial private static final long serialVersionUID = -6116744036977982899L; diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemRoleAuthorityBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemRoleAuthorityVO.java similarity index 81% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemRoleAuthorityBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemRoleAuthorityVO.java index e8af059..e0825fc 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemRoleAuthorityBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemRoleAuthorityVO.java @@ -1,4 +1,4 @@ -package com.liyz.cloud.service.staff.bo.role; +package com.liyz.cloud.service.staff.vo.role; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; @@ -16,7 +16,7 @@ */ @Getter @Setter -public class SystemRoleAuthorityBO implements Serializable { +public class SystemRoleAuthorityVO implements Serializable { @Serial private static final long serialVersionUID = 8328113920009535585L; diff --git a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemRoleBO.java b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemRoleVO.java similarity index 84% rename from cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemRoleBO.java rename to cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemRoleVO.java index 8bce957..988fd87 100644 --- a/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/bo/role/SystemRoleBO.java +++ b/cloud-service/cloud-service-staff/staff-feign/src/main/java/com/liyz/cloud/service/staff/vo/role/SystemRoleVO.java @@ -1,4 +1,4 @@ -package com.liyz.cloud.service.staff.bo.role; +package com.liyz.cloud.service.staff.vo.role; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; @@ -16,7 +16,7 @@ */ @Getter @Setter -public class SystemRoleBO implements Serializable { +public class SystemRoleVO implements Serializable { @Serial private static final long serialVersionUID = 2197798732348814224L; diff --git a/cloud-service/cloud-service-staff/staff-web/src/main/java/com/liyz/cloud/service/staff/controller/info/StaffInfoController.java b/cloud-service/cloud-service-staff/staff-web/src/main/java/com/liyz/cloud/service/staff/controller/info/StaffInfoController.java index 3bb1f75..0bd7388 100644 --- a/cloud-service/cloud-service-staff/staff-web/src/main/java/com/liyz/cloud/service/staff/controller/info/StaffInfoController.java +++ b/cloud-service/cloud-service-staff/staff-web/src/main/java/com/liyz/cloud/service/staff/controller/info/StaffInfoController.java @@ -1,17 +1,26 @@ package com.liyz.cloud.service.staff.controller.info; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.liyz.cloud.common.base.util.BeanUtil; import com.liyz.cloud.common.feign.bo.RemotePage; import com.liyz.cloud.common.feign.dto.PageDTO; import com.liyz.cloud.common.feign.result.Result; -import com.liyz.cloud.service.staff.bo.info.StaffInfoBO; import com.liyz.cloud.service.staff.constants.StaffConstants; +import com.liyz.cloud.service.staff.dto.log.StaffLogPageDTO; import com.liyz.cloud.service.staff.model.StaffInfoDO; +import com.liyz.cloud.service.staff.model.StaffLoginLogDO; +import com.liyz.cloud.service.staff.model.StaffLogoutLogDO; import com.liyz.cloud.service.staff.service.StaffInfoService; +import com.liyz.cloud.service.staff.service.StaffLoginLogService; +import com.liyz.cloud.service.staff.service.StaffLogoutLogService; +import com.liyz.cloud.service.staff.vo.info.StaffInfoVO; +import com.liyz.cloud.service.staff.vo.log.StaffLoginLogVO; +import com.liyz.cloud.service.staff.vo.log.StaffLogoutLogVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.validation.Valid; import org.springframework.web.bind.annotation.*; /** @@ -28,19 +37,53 @@ public class StaffInfoController { @Resource private StaffInfoService staffInfoService; + @Resource + private StaffLoginLogService staffLoginLogService; + @Resource + private StaffLogoutLogService staffLogoutLogService; @Operation(summary = "根据staffId获取用户信息") @GetMapping("/getByStaffId") - public Result getByStaffId(@RequestParam("staffId") Long staffId) { - return Result.success(BeanUtil.copyProperties(staffInfoService.getById(staffId), StaffInfoBO::new)); + public Result getByStaffId(@RequestParam("staffId") Long staffId) { + return Result.success(BeanUtil.copyProperties(staffInfoService.getById(staffId), StaffInfoVO::new)); } @Operation(summary = "分页查询员工信息") @PostMapping("/page") - public Result> page(@RequestBody PageDTO pageDTO) { + public Result> page(@RequestBody PageDTO pageDTO) { Page page = staffInfoService.page(Page.of(pageDTO.getPageNum(), pageDTO.getPageSize())); - RemotePage remotePage = RemotePage.of( - BeanUtil.copyList(page.getRecords(), StaffInfoBO::new), + RemotePage remotePage = RemotePage.of( + BeanUtil.copyList(page.getRecords(), StaffInfoVO::new), + page.getTotal(), + pageDTO.getPageNum(), + pageDTO.getPageSize() + ); + return Result.success(remotePage); + } + + @Operation(summary = "分页查询员工登录信息") + @PostMapping("/login/page") + public Result> loginPage(@Valid @RequestBody StaffLogPageDTO pageDTO) { + Page page = staffLoginLogService.page(Page.of(pageDTO.getPageNum(), pageDTO.getPageSize()), + Wrappers.lambdaQuery(StaffLoginLogDO.builder().staffId(pageDTO.getStaffId()).build()) + .orderByDesc(StaffLoginLogDO::getId)); + RemotePage remotePage = RemotePage.of( + BeanUtil.copyList(page.getRecords(), StaffLoginLogVO::new), + page.getTotal(), + pageDTO.getPageNum(), + pageDTO.getPageSize() + ); + return Result.success(remotePage); + } + + @Operation(summary = "分页查询员工登出信息") + @PostMapping("/logout/page") + public Result> logoutPage(@Valid @RequestBody StaffLogPageDTO pageDTO) { + Page page = staffLogoutLogService.page(Page.of(pageDTO.getPageNum(), pageDTO.getPageSize()), + Wrappers.lambdaQuery(StaffLogoutLogDO.builder().staffId(pageDTO.getStaffId()).build()) + .orderByDesc(StaffLogoutLogDO::getId)); + RemotePage remotePage = RemotePage.of( + BeanUtil.copyList(page.getRecords(), StaffLogoutLogVO::new), page.getTotal(), pageDTO.getPageNum(), pageDTO.getPageSize()