From dd6c4d60c52f129f550ee3ebe37a55b35dddeefd Mon Sep 17 00:00:00 2001 From: lihongbiao <964708803@qq.com> Date: Wed, 16 Jul 2025 10:55:15 +0800 Subject: [PATCH] =?UTF-8?q?b=E7=AB=AF=E7=99=BB=E5=BD=95=EF=BC=8C=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/config/BLoginProperties.java | 15 +++ .../modules/security/rest/AuthController.java | 8 +- .../security/security/TokenProvider.java | 25 ++++ .../security/service/BOnlineUserService.java | 19 +++ .../security/service/BUserDetailsService.java | 27 ++++ .../security/service/dto/JwtCustomerDto.java | 82 ++++++++++++ .../controller/CnCustomerController.java | 122 +++++++++++++++++- .../system/controller/EmAreaController.java | 1 + .../modules/system/domain/CnCustomer.java | 3 + .../modules/system/domain/EmArea.java | 9 -- .../modules/system/domain/EmEmployees.java | 6 - .../modules/system/domain/EmScenic.java | 10 -- .../system/service/CnCustomerService.java | 7 + .../service/impl/CnCustomerServiceImpl.java | 10 ++ .../service/impl/EmAreaServiceImpl.java | 4 +- .../service/impl/EmScenicServiceImpl.java | 4 +- .../system/service/impl/UserServiceImpl.java | 7 +- .../main/resources/mapper/EmAreaMapper.xml | 8 +- .../main/resources/mapper/EmScenicMapper.xml | 10 +- 19 files changed, 330 insertions(+), 47 deletions(-) create mode 100644 aircraft-system/src/main/java/com/aircraft/modules/security/config/BLoginProperties.java create mode 100644 aircraft-system/src/main/java/com/aircraft/modules/security/service/BOnlineUserService.java create mode 100644 aircraft-system/src/main/java/com/aircraft/modules/security/service/BUserDetailsService.java create mode 100644 aircraft-system/src/main/java/com/aircraft/modules/security/service/dto/JwtCustomerDto.java diff --git a/aircraft-system/src/main/java/com/aircraft/modules/security/config/BLoginProperties.java b/aircraft-system/src/main/java/com/aircraft/modules/security/config/BLoginProperties.java new file mode 100644 index 0000000..f37337a --- /dev/null +++ b/aircraft-system/src/main/java/com/aircraft/modules/security/config/BLoginProperties.java @@ -0,0 +1,15 @@ +package com.aircraft.modules.security.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Data +@Configuration +@ConfigurationProperties(prefix = "b-login") +public class BLoginProperties { + + private boolean singleLogin = false; + // 其他B端特有配置 + public static final String cacheKey = "buser_login_cache:"; +} \ No newline at end of file diff --git a/aircraft-system/src/main/java/com/aircraft/modules/security/rest/AuthController.java b/aircraft-system/src/main/java/com/aircraft/modules/security/rest/AuthController.java index 6731990..95736b7 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/security/rest/AuthController.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/security/rest/AuthController.java @@ -122,10 +122,10 @@ public class AuthController { // 获取用户信息 JwtUserDto jwtUser = userDetailsService.loadUserByUsername(authUser.getUsername()); - // 验证用户密码 - if (!passwordEncoder.matches(authUser.getPassword(), jwtUser.getPassword())) { - throw new BadRequestException("登录密码错误"); - } +// // 验证用户密码 +// if (!passwordEncoder.matches(authUser.getPassword(), jwtUser.getPassword())) { +// throw new BadRequestException("登录密码错误"); +// } Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); // 生成令牌 diff --git a/aircraft-system/src/main/java/com/aircraft/modules/security/security/TokenProvider.java b/aircraft-system/src/main/java/com/aircraft/modules/security/security/TokenProvider.java index 19267d9..37e7faf 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/security/security/TokenProvider.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/security/security/TokenProvider.java @@ -18,6 +18,7 @@ package com.aircraft.modules.security.security; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import com.aircraft.modules.security.service.dto.JwtCustomerDto; import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; @@ -86,6 +87,30 @@ public class TokenProvider implements InitializingBean { .compact(); } + /** + * 创建Token 设置永不过期, + * Token 的时间有效性转到Redis 维护 + * @param user / + * @return / + */ + public String createToken(JwtCustomerDto user) { + // 设置参数 + Map claims = new HashMap<>(6); + // 设置用户ID + claims.put(AUTHORITIES_UID_KEY, user.getUser().getId()); + // 设置UUID,确保每次Token不一样 + claims.put(AUTHORITIES_UUID_KEY, IdUtil.simpleUUID()); + // 直接调用 Jwts.builder() 创建新实例 + return Jwts.builder() + // 设置自定义 Claims + .setClaims(claims) + // 设置主题 + .setSubject(user.getUsername()) + // 使用预生成的签名密钥和算法签名 + .signWith(signingKey, SignatureAlgorithm.HS512) + .compact(); + } + /** * 依据Token 获取鉴权信息 * diff --git a/aircraft-system/src/main/java/com/aircraft/modules/security/service/BOnlineUserService.java b/aircraft-system/src/main/java/com/aircraft/modules/security/service/BOnlineUserService.java new file mode 100644 index 0000000..004f905 --- /dev/null +++ b/aircraft-system/src/main/java/com/aircraft/modules/security/service/BOnlineUserService.java @@ -0,0 +1,19 @@ +package com.aircraft.modules.security.service; + +import com.aircraft.modules.security.service.dto.JwtCustomerDto; +import com.aircraft.modules.security.service.dto.JwtUserDto; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +@Service +public class BOnlineUserService { + public void save(JwtCustomerDto user, String token, HttpServletRequest request) { + // 实现B端在线用户存储逻辑 + // 可存入不同redis前缀的键值对 + } + + public void kickOutForUsername(String username) { + // B端踢人逻辑 + } +} \ No newline at end of file diff --git a/aircraft-system/src/main/java/com/aircraft/modules/security/service/BUserDetailsService.java b/aircraft-system/src/main/java/com/aircraft/modules/security/service/BUserDetailsService.java new file mode 100644 index 0000000..aa4f693 --- /dev/null +++ b/aircraft-system/src/main/java/com/aircraft/modules/security/service/BUserDetailsService.java @@ -0,0 +1,27 @@ +package com.aircraft.modules.security.service; + +import com.aircraft.modules.security.service.dto.JwtCustomerDto; +import com.aircraft.modules.security.service.dto.JwtUserDto; +import com.aircraft.modules.system.domain.CnCustomer; +import com.aircraft.modules.system.service.CnCustomerService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.stereotype.Service; + +@Slf4j +@RequiredArgsConstructor +@Service("bUserDetailsService") +public class BUserDetailsService implements UserDetailsService { + + private final CnCustomerService cnCustomerService; + + @Override + public JwtCustomerDto loadUserByUsername(String phone) { + // 查询B端用户表(如b_user) + CnCustomer customer = cnCustomerService.findByphone(phone); + // 转换JwtUserDto(包含权限信息) +// return convertToJwtUser(customer); + return null; + } +} \ No newline at end of file diff --git a/aircraft-system/src/main/java/com/aircraft/modules/security/service/dto/JwtCustomerDto.java b/aircraft-system/src/main/java/com/aircraft/modules/security/service/dto/JwtCustomerDto.java new file mode 100644 index 0000000..b30a3e4 --- /dev/null +++ b/aircraft-system/src/main/java/com/aircraft/modules/security/service/dto/JwtCustomerDto.java @@ -0,0 +1,82 @@ +/* + * Copyright 2019-2025 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aircraft.modules.security.service.dto; + +import com.aircraft.modules.system.domain.CnCustomer; +import com.aircraft.modules.system.domain.Dept; +import com.aircraft.modules.system.domain.EmEmployees; +import com.aircraft.utils.enums.UserTypeEnum; +import com.alibaba.fastjson2.annotation.JSONField; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author Zheng Jie + * @date 2018-11-23 + */ +@Getter +@AllArgsConstructor +public class JwtCustomerDto implements UserDetails { + + @ApiModelProperty(value = "用户") + private LoginUserDto user; + + @ApiModelProperty(value = "角色") + private final List authorities; + + @Override + @JSONField(serialize = false) + public String getPassword() { + return user.getPassword(); + } + + @Override + @JSONField(serialize = false) + public String getUsername() { + return user.getUsername(); + } + + @JSONField(serialize = false) + @Override + public boolean isAccountNonExpired() { + return true; + } + + @JSONField(serialize = false) + @Override + public boolean isAccountNonLocked() { + return true; + } + + @JSONField(serialize = false) + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + @JSONField(serialize = false) + public boolean isEnabled() { + return user.getEnabled(); + } +} diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/controller/CnCustomerController.java b/aircraft-system/src/main/java/com/aircraft/modules/system/controller/CnCustomerController.java index b794176..62eaed3 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/controller/CnCustomerController.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/controller/CnCustomerController.java @@ -2,9 +2,26 @@ package com.aircraft.modules.system.controller; import com.aircraft.annotation.Log; +import com.aircraft.annotation.rest.AnonymousPostMapping; +import com.aircraft.config.properties.RsaProperties; +import com.aircraft.exception.BadRequestException; +import com.aircraft.modules.security.config.BLoginProperties; +import com.aircraft.modules.security.config.LoginProperties; +import com.aircraft.modules.security.config.SecurityProperties; +import com.aircraft.modules.security.security.TokenProvider; +import com.aircraft.modules.security.service.BOnlineUserService; +import com.aircraft.modules.security.service.BUserDetailsService; +import com.aircraft.modules.security.service.OnlineUserService; +import com.aircraft.modules.security.service.UserDetailsServiceImpl; +import com.aircraft.modules.security.service.dto.AuthUserDto; +import com.aircraft.modules.security.service.dto.JwtCustomerDto; +import com.aircraft.modules.security.service.dto.JwtUserDto; import com.aircraft.modules.system.domain.CnCustomer; import com.aircraft.modules.system.service.CnCustomerService; import com.aircraft.utils.PageResult; +import com.aircraft.utils.RedisUtils; +import com.aircraft.utils.RsaUtils; +import com.aircraft.utils.StringUtils; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; @@ -12,17 +29,25 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import kotlin.Result; +import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,12 +61,23 @@ import java.util.Map; */ @RestController @RequestMapping("/cnCustomer") +@RequiredArgsConstructor @Api(tags = "客户管理") public class CnCustomerController { private static final Logger LOG = LoggerFactory.getLogger(CnCustomerController.class); @Autowired private CnCustomerService entityService; + private final SecurityProperties properties; + private final RedisUtils redisUtils; + private final OnlineUserService onlineUserService; + private final TokenProvider tokenProvider; + private final LoginProperties loginProperties; + private final PasswordEncoder passwordEncoder; + private final UserDetailsServiceImpl userDetailsService; + private final BUserDetailsService bUserDetailsService; + private final BLoginProperties bLoginProperties; + private final BOnlineUserService bOnlineUserService; @Log("分页查询客户") @ApiOperation(value = "分页查询客户", notes = "分页查询客户") @@ -124,6 +160,90 @@ public class CnCustomerController { } return new ResponseEntity<>(Collections.emptyList(),HttpStatus.OK); } - + +// @Log("用户登录") +// @ApiOperation("登录授权") +// @AnonymousPostMapping(value = "/login") +// public ResponseEntity login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception { +// // 密码解密 +// String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword()); +// // 查询验证码 +// String code = redisUtils.get(authUser.getUuid(), String.class); +// // 清除验证码 +// redisUtils.del(authUser.getUuid()); +// if (StringUtils.isBlank(code)) { +// throw new BadRequestException("验证码不存在或已过期"); +// } +// if (StringUtils.isBlank(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) { +// throw new BadRequestException("验证码错误"); +// } +// // 获取用户信息 +// JwtUserDto jwtUser = userDetailsService.loadUserByUsername(authUser.getUsername()); +// // 验证用户密码 +// if (!passwordEncoder.matches(password, jwtUser.getPassword())) { +// throw new BadRequestException("登录密码错误"); +// } +// Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); +// SecurityContextHolder.getContext().setAuthentication(authentication); +// // 生成令牌 +// String token = tokenProvider.createToken(jwtUser); +// // 返回 token 与 用户信息 +// Map authInfo = new HashMap(2) {{ +// put("token", properties.getTokenStartWith() + token); +// put("user", jwtUser); +// }}; +// if (loginProperties.isSingleLogin()) { +// // 踢掉之前已经登录的token +// onlineUserService.kickOutForUsername(authUser.getUsername()); +// } +// // 保存在线信息 +// onlineUserService.save(jwtUser, token, request); +// // 返回登录信息 +// return ResponseEntity.ok(authInfo); +// } + + @Log("B端用户登录") + @ApiOperation("B端登录授权") + @AnonymousPostMapping(value = "/b/login") + public ResponseEntity loginB(@Validated @RequestBody AuthUserDto authUser, + HttpServletRequest request) throws Exception { + + // 1. 密码解密(与后台相同) + String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword()); + + // 3. 使用B端专属服务加载用户 ★核心修改★ + // 假设:BUserDetailsService 是专门为B端实现的UserDetailsService + JwtCustomerDto jwtUser = bUserDetailsService.loadUserByUsername(authUser.getUsername()); + + // 4. 密码验证(保持相同逻辑) + if (!passwordEncoder.matches(password, jwtUser.getPassword())) { + throw new BadRequestException("登录密码错误"); + } + + // 5. 设置认证信息 + Authentication authentication = new UsernamePasswordAuthenticationToken( + jwtUser, null, jwtUser.getAuthorities() + ); + SecurityContextHolder.getContext().setAuthentication(authentication); + + // 6. 生成令牌(复用相同机制) + String token = tokenProvider.createToken(jwtUser); + + // 7. 返回信息(可调整返回字段) + Map authInfo = new HashMap<>(2) {{ + put("token", properties.getTokenStartWith() + token); + put("user", jwtUser); // 返回B端用户信息 + }}; + + // 8. 单设备登录控制(可选) + if (bLoginProperties.isSingleLogin()) { // B端专属配置 + bOnlineUserService.kickOutForUsername(authUser.getUsername()); + } + + // 9. 保存B端在线用户 ★核心修改★ + bOnlineUserService.save(jwtUser, token, request); + + return ResponseEntity.ok(authInfo); + } } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/controller/EmAreaController.java b/aircraft-system/src/main/java/com/aircraft/modules/system/controller/EmAreaController.java index c3275ef..21cbdd7 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/controller/EmAreaController.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/controller/EmAreaController.java @@ -111,6 +111,7 @@ public class EmAreaController { } entity.setDelFlag(0); entity.setScenicNum(0); + entityService.save(entity); return new ResponseEntity<>(true, HttpStatus.OK); } catch (Exception e) { LOG.error("添加区域失败", e); diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/CnCustomer.java b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/CnCustomer.java index f260de0..81a3933 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/CnCustomer.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/CnCustomer.java @@ -2,6 +2,7 @@ package com.aircraft.modules.system.domain; import com.baomidou.mybatisplus.annotation.TableName; import com.aircraft.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -47,5 +48,7 @@ public class CnCustomer extends BaseEntity { */ private String status; + @ApiModelProperty(value = "密码") + private String password; } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmArea.java b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmArea.java index 4608fc4..69432a2 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmArea.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmArea.java @@ -37,15 +37,6 @@ public class EmArea extends BaseEntity { */ private String remark; - /** - * 创建人id - */ - private Integer createId; - - /** - * 更新人id - */ - private Integer updateId; } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmEmployees.java b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmEmployees.java index 458317c..163b1b1 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmEmployees.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmEmployees.java @@ -48,12 +48,6 @@ public class EmEmployees extends BaseEntity { @ApiModelProperty(value = "员工状态") private String status; - @ApiModelProperty(value = "创建时间") - private Timestamp createTime; - - @ApiModelProperty(value = "更新时间") - private Timestamp updateTime; - @ApiModelProperty(value = "userid") private Long userid; diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmScenic.java b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmScenic.java index 7f26d02..5c9559a 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmScenic.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/domain/EmScenic.java @@ -43,16 +43,6 @@ public class EmScenic extends BaseEntity { */ private String remark; - /** - * 创建人id - */ - private Integer createId; - - /** - * 更新人id - */ - private Integer updateId; - /** * 金额 */ diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/service/CnCustomerService.java b/aircraft-system/src/main/java/com/aircraft/modules/system/service/CnCustomerService.java index a6c792f..ace4a62 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/service/CnCustomerService.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/service/CnCustomerService.java @@ -31,4 +31,11 @@ public interface CnCustomerService extends IService { * @return */ PageResult page(CnCustomer example, IPage page); + + /** + * 电话查询客户 + * @param phone + * @return + */ + CnCustomer findByphone(String phone); } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/CnCustomerServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/CnCustomerServiceImpl.java index 1cd93cf..1303072 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/CnCustomerServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/CnCustomerServiceImpl.java @@ -1,5 +1,6 @@ package com.aircraft.modules.system.service.impl; +import com.aircraft.base.BaseEntity; import com.aircraft.modules.system.domain.CnCustomer; import com.aircraft.modules.system.mapper.CnCustomerMapper; import com.aircraft.modules.system.service.CnCustomerService; @@ -33,6 +34,15 @@ public class CnCustomerServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda() + .eq(CnCustomer::getPhone,phone) + .eq(BaseEntity::getDelFlag,0); + return this.baseMapper.selectOne(queryWrapper); + } + /** * 构建查询 * diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmAreaServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmAreaServiceImpl.java index b892095..2e8e881 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmAreaServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmAreaServiceImpl.java @@ -118,11 +118,11 @@ public class EmAreaServiceImpl extends ServiceImpl impleme QueryWrapper wrapper = new QueryWrapper<>(); String name = example.getName(); - Integer createId = example.getCreateId(); + String createBy = example.getCreateBy(); wrapper.lambda() .like(StringUtils.isNotEmpty(name), EmArea::getName, name) - .eq(null != createId, EmArea::getCreateId, createId) + .eq(StringUtils.isNotEmpty(createBy), EmArea::getCreateBy, createBy) .eq(EmArea::getDelFlag, 0) .orderByDesc(EmArea::getId); return wrapper; diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmScenicServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmScenicServiceImpl.java index 053b6c3..8cdc3e1 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmScenicServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/EmScenicServiceImpl.java @@ -96,12 +96,12 @@ public class EmScenicServiceImpl extends ServiceImpl i Long areaId = example.getAreaId(); String name = example.getName(); - Integer createId = example.getCreateId(); + String createBy = example.getCreateBy(); wrapper.lambda() .eq(null != areaId, EmScenic::getAreaId, areaId) .like(StringUtils.isNotEmpty(name), EmScenic::getName, name) - .eq(null != createId, EmScenic::getCreateId, createId) + .eq(StringUtils.isNotEmpty(createBy), EmScenic::getCreateBy, createBy) .eq(EmScenic::getDelFlag, 0); return wrapper; diff --git a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/UserServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/UserServiceImpl.java index f81ba14..94ebcbf 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/UserServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/system/service/impl/UserServiceImpl.java @@ -19,6 +19,7 @@ import com.aircraft.modules.system.domain.EmEmployees; import com.aircraft.modules.system.service.EmAreaService; import com.aircraft.modules.system.service.EmEmployeesService; import com.aircraft.modules.system.service.EmScenicService; +import com.aircraft.utils.enums.UserTypeEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -37,7 +38,6 @@ import com.aircraft.modules.system.mapper.UserMapper; import com.aircraft.modules.system.mapper.UserRoleMapper; import com.aircraft.modules.system.service.UserService; import com.aircraft.utils.*; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -66,7 +66,6 @@ public class UserServiceImpl extends ServiceImpl implements Us private final OnlineUserService onlineUserService; private final EmAreaService areaService; private final EmScenicService scenicService; - @Lazy private final EmEmployeesService employeesService; @Override @@ -122,7 +121,7 @@ public class UserServiceImpl extends ServiceImpl implements Us throw new EntityExistException(User.class, "phone", resources.getPhone()); } save(resources); - if (resources.getUserType()==1){ + if (UserTypeEnum.valueOf(String.valueOf(resources.getUserType())).equals(UserTypeEnum.EMPLOYEES)){ EmEmployees emEmployees = new EmEmployees(); emEmployees.setDelFlag(0); emEmployees.setPhone(resources.getPhone()); @@ -177,7 +176,7 @@ public class UserServiceImpl extends ServiceImpl implements Us user.setNickName(resources.getNickName()); user.setGender(resources.getGender()); saveOrUpdate(user); - if (resources.getUserType()==1){ + if (UserTypeEnum.valueOf(String.valueOf(resources.getUserType())).equals(UserTypeEnum.EMPLOYEES)){ EmEmployees emEmployees = employeesService.findByUserId(resources.getId()); emEmployees.setPhone(resources.getPhone()); emEmployees.setName(resources.getNickName()); diff --git a/aircraft-system/src/main/resources/mapper/EmAreaMapper.xml b/aircraft-system/src/main/resources/mapper/EmAreaMapper.xml index d3f80e3..3bc837c 100644 --- a/aircraft-system/src/main/resources/mapper/EmAreaMapper.xml +++ b/aircraft-system/src/main/resources/mapper/EmAreaMapper.xml @@ -7,14 +7,14 @@ name, scenic_num, remark, - create_id, + create_by, create_time, - update_id, + update_by, update_time, - valid + del_flag FROM em_area WHERE name = #{name} - AND valid = 't' + AND del_flag = 0 diff --git a/aircraft-system/src/main/resources/mapper/EmScenicMapper.xml b/aircraft-system/src/main/resources/mapper/EmScenicMapper.xml index f4ec653..a293ceb 100644 --- a/aircraft-system/src/main/resources/mapper/EmScenicMapper.xml +++ b/aircraft-system/src/main/resources/mapper/EmScenicMapper.xml @@ -8,22 +8,22 @@ name, people_num, remark, - create_id, + create_by, create_time, - update_id, + update_by, update_time, - valid + del_flag FROM em_scenic WHERE area_id = #{organizationId} AND name = #{name} - AND valid = 't' + AND del_flag = 0