Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/coscoshipping/ebtp/system/category/maintenance/dao/mapper/CoscoCategoryMaintenanceMapper.xml
This commit is contained in:
18
pom.xml
18
pom.xml
@ -73,6 +73,24 @@
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Seata分布式事务依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Seata数据源代理 -->
|
||||
<dependency>
|
||||
<groupId>io.seata</groupId>
|
||||
<artifactId>seata-spring-boot-starter</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<!-- <repositories>-->
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.coscoshipping.ebtp.system;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ -16,6 +13,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
@MapperScan({"com.coscoshipping.ebtp.system.**.dao", "com.chinaunicom.mall.ebtp.**.dao" })
|
||||
@ComponentScan(basePackages = { "com.coscoshipping.ebtp.system.*", "com.chinaunicom.mall.ebtp.cloud.*",
|
||||
"com.chinaunicom.mall.ebtp.*" })
|
||||
@EnableDiscoveryClient
|
||||
public class SysManagerEbtpProjectApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -23,16 +21,4 @@ public class SysManagerEbtpProjectApplication {
|
||||
System.out.println("启动成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Grafana 注册项
|
||||
*
|
||||
* @param applicationName 应用名称, 用于grafana应用列表
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MeterRegistryCustomizer<MeterRegistry> configurer(
|
||||
@Value("${spring.application.name}") String applicationName) {
|
||||
return (registry) -> registry.config().commonTags("application", applicationName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,26 @@ import java.util.List;
|
||||
*/
|
||||
public interface CoscoCategoryMaintenanceMapper extends IBaseMapper<CoscoCategoryMaintenance> {
|
||||
|
||||
|
||||
/**
|
||||
* 模糊查询品类名称匹配的节点
|
||||
*/
|
||||
List<CoscoCategoryMaintenanceVO> findByCategoryNameLike(@Param("categoryName") String categoryName,
|
||||
@Param("versionId") Long versionId,
|
||||
@Param("code") String code);
|
||||
|
||||
|
||||
/**
|
||||
* 根据父ID查询节点(用于递归找父级)
|
||||
*/
|
||||
CoscoCategoryMaintenanceVO findByParentId(@Param("parentId") Long parentId, @Param("versionId") Long versionId);
|
||||
|
||||
/**
|
||||
* 批量查询节点(用于加载收集到的所有节点)
|
||||
*/
|
||||
List<CoscoCategoryMaintenanceVO> findAllByIds(@Param("ids") List<Long> ids, @Param("versionId") Long versionId);
|
||||
|
||||
|
||||
List<CoscoCategoryMaintenanceVO> findAllByParentId(@Param("parentId") Long parentId,@Param("versionId") Long versionId);
|
||||
|
||||
void saveData(@Param("categoryMaintenance") CoscoCategoryMaintenance categoryMaintenance);
|
||||
|
@ -17,6 +17,38 @@
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- 模糊查询品类名称 -->
|
||||
<select id="findByCategoryNameLike" resultType="com.coscoshipping.ebtp.system.category.maintenance.entity.CoscoCategoryMaintenanceVO">
|
||||
SELECT * FROM cosco_category_maintenance
|
||||
WHERE version_id = #{versionId}
|
||||
<if test="categoryName!=null and categoryName!=''">
|
||||
AND category_name LIKE CONCAT('%', #{categoryName}, '%')
|
||||
</if>
|
||||
<if test="code!=null and code!=''">
|
||||
AND code LIKE CONCAT('%', #{code}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据父ID查询节点 -->
|
||||
<select id="findByParentId" resultType="com.coscoshipping.ebtp.system.category.maintenance.entity.CoscoCategoryMaintenanceVO">
|
||||
SELECT * FROM cosco_category_maintenance
|
||||
WHERE id = #{parentId}
|
||||
AND version_id = #{versionId}
|
||||
</select>
|
||||
|
||||
<!-- 批量查询节点 -->
|
||||
<select id="findAllByIds" resultType="com.coscoshipping.ebtp.system.category.maintenance.entity.CoscoCategoryMaintenanceVO">
|
||||
SELECT * FROM cosco_category_maintenance
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND version_id = #{versionId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="saveData">
|
||||
INSERT INTO cosco_category_maintenance (`version_id`, `parent_id`, `path`, `path_name`, `category_name`, `code`, `status`)
|
||||
VALUES ( #{categoryMaintenance.versionId},#{categoryMaintenance.parentId},#{categoryMaintenance.path},
|
||||
@ -52,9 +84,9 @@
|
||||
|
||||
<insert id="batchSaveCategory">
|
||||
INSERT INTO cosco_category_maintenance
|
||||
(version_id, parent_id, path, path_name, category_name,code,status) VALUES
|
||||
(id,version_id, parent_id, path, path_name, category_name,code,status) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.versionId}, #{item.parentId}, #{item.path}, #{item.pathName}, #{item.categoryName},#{item.code},#{item.status})
|
||||
(#{item.id},#{item.versionId}, #{item.parentId}, #{item.path}, #{item.pathName}, #{item.categoryName},#{item.code},#{item.status})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.coscoshipping.ebtp.system.category.maintenance.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
import com.coscoshipping.ebtp.system.category.maintenance.dao.CoscoCategoryMaintenanceMapper;
|
||||
@ -12,10 +13,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 对数据表 cosco_category_maintenance 操作的 serviceImpl
|
||||
@ -63,9 +66,92 @@ public class CoscoCategoryMaintenanceServiceImpl extends BaseServiceImpl<CoscoCa
|
||||
|
||||
@Override
|
||||
public List<CoscoCategoryMaintenanceVO> getList(CoscoCategoryMaintenanceVO coscoCategoryMaintenanceVO) {
|
||||
List<CoscoCategoryMaintenanceVO> roots = coscoCategoryMaintenanceMapper.findAllByParentId(0L,coscoCategoryMaintenanceVO.getVersionId());
|
||||
roots.forEach(this::loadChildren);
|
||||
return roots;
|
||||
String categoryName = coscoCategoryMaintenanceVO.getCategoryName();
|
||||
String code = coscoCategoryMaintenanceVO.getCode();
|
||||
Long versionId = coscoCategoryMaintenanceVO.getVersionId();
|
||||
List<CoscoCategoryMaintenanceVO> result = new ArrayList<>();
|
||||
|
||||
if (StringUtils.isNotBlank(categoryName) || StringUtils.isNotBlank(code)) {
|
||||
// 存储已匹配的节点 ID(用于去重)
|
||||
Set<Long> matchedIds = new HashSet<>();
|
||||
List<CoscoCategoryMaintenanceVO> matchedNodes = new ArrayList<>();
|
||||
|
||||
// 1. 品类名称模糊查询
|
||||
if (StringUtils.isNotBlank(categoryName) || StringUtils.isNotBlank(code)) {
|
||||
List<CoscoCategoryMaintenanceVO> nameMatches = coscoCategoryMaintenanceMapper.findByCategoryNameLike(categoryName, versionId,code);
|
||||
for (CoscoCategoryMaintenanceVO node : nameMatches) {
|
||||
if (!matchedIds.contains(node.getId())) {
|
||||
matchedIds.add(node.getId());
|
||||
matchedNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(matchedNodes)) {
|
||||
return result; // 无匹配结果,直接返回空列表
|
||||
}
|
||||
|
||||
// 3. 递归收集所有匹配节点的父级(包括自身)
|
||||
Set<Long> collectedIds = new HashSet<>();
|
||||
for (CoscoCategoryMaintenanceVO node : matchedNodes) {
|
||||
collectAncestors(node, collectedIds, versionId);
|
||||
}
|
||||
|
||||
// 4. 批量查询所有收集到的节点(避免重复查询)
|
||||
List<CoscoCategoryMaintenanceVO> allNodes = coscoCategoryMaintenanceMapper.findAllByIds(
|
||||
new ArrayList<>(collectedIds), versionId
|
||||
);
|
||||
if (CollectionUtils.isEmpty(allNodes)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 5. 构建树形结构(按 parentId 分组子节点)
|
||||
Map<Long, List<CoscoCategoryMaintenanceVO>> parentMap = allNodes.stream()
|
||||
.filter(n -> n.getParentId() != null) // 过滤空父ID
|
||||
.collect(Collectors.groupingBy(CoscoCategoryMaintenanceVO::getParentId));
|
||||
|
||||
// 6. 找到根节点(parentId = 0 或 null)并递归加载子节点
|
||||
List<CoscoCategoryMaintenanceVO> roots = allNodes.stream()
|
||||
.filter(n -> n.getParentId() == null || n.getParentId() == 0)
|
||||
.collect(Collectors.toList());
|
||||
for (CoscoCategoryMaintenanceVO root : roots) {
|
||||
loadChildrenForFiltered(root, parentMap); // 递归加载子节点
|
||||
}
|
||||
result = roots;
|
||||
} else {
|
||||
// 无搜索条件时,加载所有根节点并递归子节点(原逻辑)
|
||||
List<CoscoCategoryMaintenanceVO> roots = coscoCategoryMaintenanceMapper.findAllByParentId(0L, versionId);
|
||||
roots.forEach(this::loadChildren);
|
||||
result = roots;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归收集节点的所有父级(包括自身)
|
||||
*/
|
||||
private void collectAncestors(CoscoCategoryMaintenanceVO node, Set<Long> collectedIds, Long versionId) {
|
||||
if (node == null || collectedIds.contains(node.getId())) {
|
||||
return;
|
||||
}
|
||||
collectedIds.add(node.getId()); // 收集当前节点
|
||||
// 递归查询父节点
|
||||
CoscoCategoryMaintenanceVO parent = coscoCategoryMaintenanceMapper.findByParentId(node.getParentId(), versionId);
|
||||
if (parent != null) {
|
||||
collectAncestors(parent, collectedIds, versionId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为过滤后的节点递归加载子节点
|
||||
*/
|
||||
private void loadChildrenForFiltered(CoscoCategoryMaintenanceVO vo, Map<Long, List<CoscoCategoryMaintenanceVO>> parentMap) {
|
||||
List<CoscoCategoryMaintenanceVO> children = parentMap.getOrDefault(vo.getId(), Collections.emptyList());
|
||||
vo.setChildren(children);
|
||||
// 递归加载子节点的子节点
|
||||
for (CoscoCategoryMaintenanceVO child : children) {
|
||||
loadChildrenForFiltered(child, parentMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadChildren(CoscoCategoryMaintenanceVO vo) {
|
||||
|
@ -31,6 +31,13 @@
|
||||
<select id="selectPageList"
|
||||
resultType="com.coscoshipping.ebtp.system.category.version.entity.CoscoCategoryVersionVO">
|
||||
SELECT * FROM cosco_category_version
|
||||
where 1=1
|
||||
<if test="name!=null and name!=''">
|
||||
and name like concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="version!=null and version!=''">
|
||||
and version =#{version}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectById"
|
||||
resultType="com.coscoshipping.ebtp.system.category.version.entity.CoscoCategoryVersion">
|
||||
|
@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
|
||||
import com.coscoshipping.ebtp.system.category.maintenance.dao.CoscoCategoryMaintenanceMapper;
|
||||
import com.coscoshipping.ebtp.system.category.maintenance.entity.CoscoCategoryMaintenance;
|
||||
import com.coscoshipping.ebtp.system.category.maintenance.service.ICoscoCategoryMaintenanceService;
|
||||
import com.coscoshipping.ebtp.system.category.version.dao.CoscoCategoryVersionMapper;
|
||||
import com.coscoshipping.ebtp.system.category.version.entity.CoscoCategoryVersion;
|
||||
import com.coscoshipping.ebtp.system.category.version.entity.CoscoCategoryVersionVO;
|
||||
@ -33,6 +35,9 @@ public class CoscoCategoryVersionServiceImpl extends BaseServiceImpl<CoscoCatego
|
||||
@Resource
|
||||
private CoscoCategoryMaintenanceMapper coscoCategoryMaintenanceMapper;
|
||||
|
||||
@Resource
|
||||
private ICoscoCategoryMaintenanceService coscoCategoryMaintenanceService;
|
||||
|
||||
/**
|
||||
* 生成查询数据
|
||||
*
|
||||
@ -71,7 +76,8 @@ public class CoscoCategoryVersionServiceImpl extends BaseServiceImpl<CoscoCatego
|
||||
//新增版本时,新增品类维护表,初始化数据
|
||||
coscoCategoryVersionMapper.saveVersion(coscoCategoryVersion);
|
||||
Long versionId = coscoCategoryVersionMapper.selMaxId();
|
||||
coscoCategoryMaintenanceMapper.batchSaveCategory(getList(versionId));
|
||||
coscoCategoryMaintenanceService.saveBatch(getList(versionId));
|
||||
// coscoCategoryMaintenanceMapper.batchSaveCategory(getList(versionId));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,6 +95,7 @@ public class CoscoCategoryVersionServiceImpl extends BaseServiceImpl<CoscoCatego
|
||||
public List<CoscoCategoryMaintenance> getList(Long versionId){
|
||||
List<CoscoCategoryMaintenance> list = new ArrayList<>();
|
||||
CoscoCategoryMaintenance categoryMaintenance = new CoscoCategoryMaintenance();
|
||||
categoryMaintenance.setId(Long.valueOf(PropertyUtils.getSnowflakeId()));
|
||||
categoryMaintenance.setCategoryName("货物");
|
||||
categoryMaintenance.setParentId(0L);
|
||||
categoryMaintenance.setCode("A");
|
||||
@ -96,6 +103,7 @@ public class CoscoCategoryVersionServiceImpl extends BaseServiceImpl<CoscoCatego
|
||||
categoryMaintenance.setVersionId(versionId);
|
||||
list.add(categoryMaintenance);
|
||||
CoscoCategoryMaintenance category = new CoscoCategoryMaintenance();
|
||||
category.setId(Long.valueOf(PropertyUtils.getSnowflakeId()));
|
||||
category.setCategoryName("工程");
|
||||
category.setParentId(0L);
|
||||
category.setCode("B");
|
||||
@ -103,6 +111,7 @@ public class CoscoCategoryVersionServiceImpl extends BaseServiceImpl<CoscoCatego
|
||||
category.setVersionId(versionId);
|
||||
list.add(category);
|
||||
CoscoCategoryMaintenance categoryService = new CoscoCategoryMaintenance();
|
||||
categoryService.setId(Long.valueOf(PropertyUtils.getSnowflakeId()));
|
||||
categoryService.setCategoryName("服务");
|
||||
categoryService.setParentId(0L);
|
||||
categoryService.setCode("C");
|
||||
|
@ -103,21 +103,25 @@ public class FileController extends BaseController {
|
||||
@RequestParam(required = false, value = "objectTable") String objectTable,
|
||||
@RequestParam(required = false, value = "objectParam") String objectParam,
|
||||
@RequestParam(defaultValue = "file", value = "objectType") String objectType,
|
||||
@RequestParam(value = "multipartFiles") MultipartFile... multipartFiles)
|
||||
throws Exception {
|
||||
@RequestParam(value = "multipartFiles") MultipartFile... multipartFiles) {
|
||||
if (StringUtils.isEmpty(appCode) || StringUtils.isEmpty(String.valueOf(objectId))) {
|
||||
return new BaseResponse<List<AnnexAndStorageVO>>(400, false, ResponseEnum.REQUEST_ERROR.getMsg(), null);
|
||||
}
|
||||
List<AnnexAndStorageVO> annexAndStorageVOs = new ArrayList<>();
|
||||
if (multipartFiles != null && multipartFiles.length > 0) {
|
||||
for (MultipartFile file : multipartFiles) {
|
||||
List<AnnexAndStorageVO> annexAndStorageVOList = this.fileService.uploadFile(file, appCode, objectId, objectTable, objectType, objectParam);
|
||||
annexAndStorageVOs.addAll(annexAndStorageVOList);
|
||||
try {
|
||||
if (multipartFiles != null && multipartFiles.length > 0) {
|
||||
for (MultipartFile file : multipartFiles) {
|
||||
List<AnnexAndStorageVO> annexAndStorageVOList = this.fileService.uploadFile(file, appCode, objectId, objectTable, objectType, objectParam);
|
||||
annexAndStorageVOs.addAll(annexAndStorageVOList);
|
||||
}
|
||||
return ok(annexAndStorageVOs);
|
||||
} else {
|
||||
return new BaseResponse<>(400, false, ResponseEnum.FILE_NOT_EXIST_OR_REQUEST_ERROR.getMsg(), null);
|
||||
}
|
||||
return ok(annexAndStorageVOs);
|
||||
} else {
|
||||
return new BaseResponse<>(400, false, ResponseEnum.FILE_NOT_EXIST_OR_REQUEST_ERROR.getMsg(), null);
|
||||
} catch (Exception e) {
|
||||
return new BaseResponse<>(400, false, e.getMessage(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -389,8 +393,8 @@ public class FileController extends BaseController {
|
||||
* @Date 创建时间: 2021/6/24
|
||||
*/
|
||||
@GetMapping("/getDownload")
|
||||
public BaseResponse<Boolean> getDownload(@RequestParam("fileId") String fileId,HttpServletResponse httpServletResponse ,@RequestParam("documentSecretKey") String documentSecretKey){
|
||||
return fileService.getDownload(fileId,httpServletResponse,documentSecretKey);
|
||||
public BaseResponse<Boolean> getDownload(@RequestParam("fileId") String fileId, HttpServletResponse httpServletResponse, @RequestParam("documentSecretKey") String documentSecretKey) {
|
||||
return fileService.getDownload(fileId, httpServletResponse, documentSecretKey);
|
||||
}
|
||||
|
||||
|
||||
@ -401,7 +405,7 @@ public class FileController extends BaseController {
|
||||
* @Date 创建时间: 2021/6/24
|
||||
*/
|
||||
@GetMapping("/getSecretKey")
|
||||
public BaseResponse<String> getSecretKey(){
|
||||
public BaseResponse<String> getSecretKey() {
|
||||
return fileService.getSecretKey();
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class LoginController {
|
||||
return BaseResponse.success(result);
|
||||
|
||||
}
|
||||
@ApiOperation("账号登录")
|
||||
@ApiOperation("专家账号登录")
|
||||
@PostMapping("/accountLogin/expert")
|
||||
public BaseResponse idcardExpertLogin(HttpServletResponse response,@RequestBody LoginUserVo vo) {
|
||||
if(captchaGenerator.checkCaptcha(vo.getIdentifying(),vo.getEncryptValue())){
|
||||
@ -81,7 +81,7 @@ public class LoginController {
|
||||
return BaseResponse.success(null);
|
||||
}
|
||||
}
|
||||
@ApiOperation("账号登录")
|
||||
@ApiOperation("供应商账号登录")
|
||||
@PostMapping("/accountLogin/supplier")
|
||||
public BaseResponse idcardSupplierLogin(HttpServletResponse response,@RequestBody LoginUserVo vo) {
|
||||
if(captchaGenerator.checkCaptcha(vo.getIdentifying(),vo.getEncryptValue())){
|
||||
|
@ -86,7 +86,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
@Value("${login.password.publickey}")
|
||||
private String publickey;
|
||||
@Value("${login.token.time_limit}")
|
||||
private String valid_time_limit;
|
||||
private String validTimeLimit;
|
||||
@Value("${login.reset_password}")
|
||||
private String resetPassword;
|
||||
@Resource
|
||||
@ -190,7 +190,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
userinfoRedisTemplate.opsForValue().set(
|
||||
REDIS_USER_KEY + token,
|
||||
baseCacheUser,
|
||||
Long.parseLong(valid_time_limit),
|
||||
Long.parseLong(validTimeLimit),
|
||||
TimeUnit.HOURS);
|
||||
|
||||
// 5. 记录登录成功日志
|
||||
@ -255,6 +255,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
|
||||
// 检查是否为首次登录
|
||||
boolean isFirstLogin = user.getFirstLogin() != null && user.getFirstLogin() == 1;
|
||||
String userId = user.getUserId().toString();
|
||||
if (isFirstLogin) {
|
||||
// 首次登录需要强制修改密码,返回特殊状态
|
||||
BaseSelf baseSelf = userSupplierLogin(user);
|
||||
@ -263,7 +264,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
// 记录首次登录日志
|
||||
long loginTime = System.currentTimeMillis() - startTime;
|
||||
sysLoginLogService.recordLoginSuccess(
|
||||
user.getUserId().toString(),
|
||||
userId,
|
||||
user.getName(),
|
||||
user.getUsername(),
|
||||
SysLoginLog.USER_TYPE_SUPPLIER,
|
||||
@ -283,27 +284,51 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
|
||||
BaseSelf baseSelf = userSupplierLogin(user);
|
||||
|
||||
// 1. 查询角色信息
|
||||
List<AuthorityEntity> authorityList = baseUserMapper.selectRoleByUserId(userId);
|
||||
|
||||
// 2. 组装BaseCacheUser
|
||||
BaseCacheUser baseCacheUser = new BaseCacheUser();
|
||||
baseCacheUser.setUserId(userId);
|
||||
baseCacheUser.setFullName(user.getName());
|
||||
baseCacheUser.setLoginName(user.getName());
|
||||
baseCacheUser.setMobilePhone(user.getMobile());
|
||||
baseCacheUser.setOfficePhone(user.getMobile());
|
||||
baseCacheUser.setSex(user.getSex() != null ? user.getSex().toString() : null);
|
||||
baseCacheUser.setEmailAddress(user.getEmail());
|
||||
baseCacheUser.setUserType("0");
|
||||
baseCacheUser.setAuthorityList(authorityList);
|
||||
// 角色ID字符串拼接
|
||||
if (authorityList != null && !authorityList.isEmpty()) {
|
||||
StringBuilder roleIds = new StringBuilder();
|
||||
for (AuthorityEntity ae : authorityList) {
|
||||
if (roleIds.length() > 0)
|
||||
roleIds.append(",");
|
||||
roleIds.append(ae.getRoleId());
|
||||
}
|
||||
baseCacheUser.setRoleIds(roleIds.toString());
|
||||
}
|
||||
|
||||
// 存入redis
|
||||
// String token = baseSelf.getToken();
|
||||
// userinfoRedisTemplate.opsForValue().set(
|
||||
// REDIS_USER_KEY + token,
|
||||
// baseCacheUser,
|
||||
// Long.parseLong(valid_time_limit),
|
||||
// TimeUnit.HOURS);
|
||||
String token = baseSelf.getToken();
|
||||
userinfoRedisTemplate.opsForValue().set(
|
||||
REDIS_USER_KEY + token,
|
||||
baseCacheUser,
|
||||
Long.parseLong(validTimeLimit),
|
||||
TimeUnit.HOURS);
|
||||
|
||||
// 记录登录成功日志
|
||||
long loginTime = System.currentTimeMillis() - startTime;
|
||||
sysLoginLogService.recordLoginSuccess(
|
||||
user.getUserId().toString(),
|
||||
user.getName(),
|
||||
user.getUsername(),
|
||||
SysLoginLog.USER_TYPE_SUPPLIER,
|
||||
loginIp,
|
||||
baseSelf.getToken(),
|
||||
loginTime,
|
||||
userAgent,
|
||||
false
|
||||
);
|
||||
userId,
|
||||
user.getName(),
|
||||
user.getUsername(),
|
||||
SysLoginLog.USER_TYPE_SUPPLIER,
|
||||
loginIp,
|
||||
baseSelf.getToken(),
|
||||
loginTime,
|
||||
userAgent,
|
||||
false);
|
||||
|
||||
return baseSelf;
|
||||
} catch (BadPaddingException e) {
|
||||
@ -663,7 +688,7 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
||||
BaseUserToken userToken = tokenList.get(0);
|
||||
CommonExceptionEnum.LOGIN_EXPIRATION.assertStringNotNullByKey("", tokenList.get(0).getUserObject());
|
||||
SecurityEntity securityEntity = JSON.parseObject(userToken.getUserObject(), SecurityEntity.class);
|
||||
userToken.setValidTime(LocalDateTime.now().plusMinutes(Long.valueOf(valid_time_limit)));
|
||||
userToken.setValidTime(LocalDateTime.now().plusMinutes(Long.valueOf(validTimeLimit)));
|
||||
|
||||
this.baseUserTokenService.saveOrUpdate(userToken);
|
||||
|
||||
|
@ -23,6 +23,8 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDateTime;
|
||||
import com.coscoshipping.ebtp.system.user.vo.SupplierRegistrationVO;
|
||||
import com.coscoshipping.ebtp.system.userrole.entity.SysUserRole;
|
||||
import com.coscoshipping.ebtp.system.userrole.service.SysUserRoleService;
|
||||
|
||||
/**
|
||||
* 对数据表 sys_supplier_user 操作的 serviceImpl
|
||||
@ -38,6 +40,12 @@ public class SysSupplierUserServiceImpl extends BaseServiceImpl<SysSupplierUserM
|
||||
@Value("${login.reset_password}")
|
||||
private String resetPassword;
|
||||
|
||||
@Value("${mconfig.role.supplier}")
|
||||
private String supplierRole;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
|
||||
@Override
|
||||
public IPage<SysSupplierUser> getPage(SysSupplierUser sysSupplierUser) {
|
||||
LambdaQueryWrapper<SysSupplierUser> query = buildQueryWrapper(sysSupplierUser);
|
||||
@ -122,6 +130,12 @@ public class SysSupplierUserServiceImpl extends BaseServiceImpl<SysSupplierUserM
|
||||
// 保存到数据库
|
||||
boolean result = baseMapper.insert(supplierUser) > 0;
|
||||
if (result) {
|
||||
// 为用户关联供应商角色(角色ID: 00006)
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(String.valueOf(userId));
|
||||
userRole.setRoleId(supplierRole);
|
||||
sysUserRoleService.save(userRole);
|
||||
|
||||
// 返回包含明文密码的用户信息(仅用于通知)
|
||||
SysSupplierUser resultUser = new SysSupplierUser();
|
||||
resultUser.setUserId(userId);
|
||||
@ -137,6 +151,9 @@ public class SysSupplierUserServiceImpl extends BaseServiceImpl<SysSupplierUserM
|
||||
return resultUser;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,10 @@ server:
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 30MB
|
||||
max-request-size: 100MB
|
||||
cloud:
|
||||
feign:
|
||||
client:
|
||||
@ -84,6 +88,7 @@ spring:
|
||||
# master: mymaster
|
||||
# nodes: 192.168.110.231:26379
|
||||
host: 192.168.110.231
|
||||
# host: localhost
|
||||
port: 6379
|
||||
password: pass
|
||||
database:
|
||||
@ -160,10 +165,35 @@ ribbon:
|
||||
MaxAutoRetries: 1 #对当前实例的重试次数
|
||||
MaxAutoRetriesNextServer: 2 #切换实例的重试次数 1
|
||||
|
||||
# Seata分布式事务配置
|
||||
seata:
|
||||
application-id: ${spring.application.name}
|
||||
tx-service-group: sys-manager-ebtp-project-service-group
|
||||
service:
|
||||
vgroup-mapping:
|
||||
sys-manager-ebtp-project-service-group: default
|
||||
grouplist:
|
||||
default: 192.168.110.231:8091
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
application: seata-server
|
||||
server-addr: 192.168.110.231:8848
|
||||
group: SEATA_GROUP
|
||||
namespace: seata
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: 192.168.110.231:8848
|
||||
namespace: seata
|
||||
group: SEATA_GROUP
|
||||
data-id: seataServer.properties
|
||||
enable-auto-data-source-proxy: true
|
||||
|
||||
mconfig:
|
||||
swagger-ui-open: true
|
||||
exception-handle-enabled: true
|
||||
seata-open-enabled: false
|
||||
seata-open-enabled: true
|
||||
work-id: 1 #终端ID
|
||||
datacenter-id: 1 #数据中心ID
|
||||
host-name: http://10.238.25.112/
|
||||
@ -196,6 +226,8 @@ mconfig:
|
||||
cloud_mall_auth: http://10.238.52.52:8100/auth
|
||||
checkTokenPath: http://10.238.52.52:8100/auth/oauth/check_token
|
||||
xmzxUrl: http://10.238.52.52:8100/
|
||||
role:
|
||||
supplier: 000006
|
||||
|
||||
|
||||
# 用户暴露给 prometheus 的健康数据
|
||||
|
@ -93,6 +93,7 @@ mconfig:
|
||||
app-id: 1
|
||||
feign:
|
||||
name:
|
||||
assess: 1
|
||||
usercenter: 1
|
||||
tender: 1
|
||||
rsms: 1
|
||||
|
8
src/main/resources/bootstrap.yml
Normal file
8
src/main/resources/bootstrap.yml
Normal file
@ -0,0 +1,8 @@
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: 192.168.110.231:8848
|
||||
file-extension: yml
|
||||
namespace: seata
|
||||
group: SEATA_GROUP
|
Reference in New Issue
Block a user