refactor: migrate ID types from Long to String across modules

- Update BaseEntity to use String IDs (snowflake algorithm format)
- Migrate context holders (UserContextHolder, TenantContextHolder) to String
- Update MyBatis-Plus configs: LongValue -> StringValue for tenant ID
- Fix type conversions in 6 modules: common, sys, cust, proj, req, exp (partial)

Changes by module:
- fund-common: Context holders, interceptors, test fixes
- fund-sys: Test files updated for String IDs
- fund-cust: Service, DTO, VO, Controller, Config updates
- fund-proj: Complete service layer and controller migration
- fund-req: Complete service layer and controller migration
- fund-exp: ExpenseType service layer complete (FundExpense in progress)

Note: JavaScript precision issue resolved by using String for large IDs
This commit is contained in:
zhangjf 2026-03-02 19:33:01 +08:00
parent fffeaa48a5
commit 9a55286869
40 changed files with 398 additions and 325 deletions

View File

@ -11,7 +11,19 @@
<localRepository>${user.dir}/.mvn/repository</localRepository>
<mirrors>
<!-- 不配置任何私服镜像,避免外部镜像强制接管 central -->
<!-- 使用阿里云公共代理 -->
<mirror>
<id>aliyun-central</id>
<mirrorOf>central</mirrorOf>
<name>Aliyun Central</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
<mirror>
<id>aliyun-public</id>
<mirrorOf>*</mirrorOf>
<name>Aliyun Public</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
<servers>

View File

@ -66,6 +66,6 @@ INSERT INTO customer (id, tenant_id, customer_code, customer_name, contact, phon
VALUES ('1', '1', 'CUST001', '测试客户A', '张三', '13800138001', 1, '1', NOW())
ON DUPLICATE KEY UPDATE customer_code=customer_code;
INSERT INTO customer_contact (tenant_id, customer_id, contact_name, phone, position, is_primary, status, created_by, created_time)
VALUES ('1', '1', '张三', '13800138001', '总经理', 1, 1, '1', NOW())
INSERT INTO customer_contact (id, tenant_id, customer_id, contact_name, phone, position, is_primary, created_by, created_time)
VALUES ('1', '1', '1', '张三', '13800138001', '总经理', 1, '1', NOW())
ON DUPLICATE KEY UPDATE contact_name=contact_name;

View File

@ -8,16 +8,16 @@ package com.fundplatform.common.context;
*/
public final class TenantContextHolder {
private static final ThreadLocal<Long> TENANT_ID_HOLDER = new ThreadLocal<>();
private static final ThreadLocal<String> TENANT_ID_HOLDER = new ThreadLocal<>();
private TenantContextHolder() {
}
public static void setTenantId(Long tenantId) {
public static void setTenantId(String tenantId) {
TENANT_ID_HOLDER.set(tenantId);
}
public static Long getTenantId() {
public static String getTenantId() {
return TENANT_ID_HOLDER.get();
}

View File

@ -46,15 +46,15 @@ public class FeignChainInterceptor implements RequestInterceptor {
template.header(HEADER_REQUEST_TIME, String.valueOf(System.currentTimeMillis()));
// 3. 多租户透传
Long tenantId = TenantContextHolder.getTenantId();
String tenantId = TenantContextHolder.getTenantId();
if (tenantId != null) {
template.header(HEADER_TENANT_ID, String.valueOf(tenantId));
template.header(HEADER_TENANT_ID, tenantId);
}
// 4. 用户信息透传
Long uid = UserContextHolder.getUserId();
String uid = UserContextHolder.getUserId();
if (uid != null) {
template.header(HEADER_UID, String.valueOf(uid));
template.header(HEADER_UID, uid);
}
String uname = UserContextHolder.getUserName();
if (uname != null && !uname.isEmpty()) {

View File

@ -62,23 +62,13 @@ public class ContextInterceptor implements HandlerInterceptor {
// 提取租户ID
String tenantIdStr = request.getHeader(HEADER_TENANT_ID);
if (tenantIdStr != null && !tenantIdStr.isEmpty()) {
try {
Long tenantId = Long.parseLong(tenantIdStr);
TenantContextHolder.setTenantId(tenantId);
} catch (NumberFormatException e) {
// 忽略无效的租户ID
}
TenantContextHolder.setTenantId(tenantIdStr);
}
// 提取用户 ID
String userIdStr = request.getHeader(HEADER_USER_ID);
if (userIdStr != null && !userIdStr.isEmpty()) {
try {
Long userId = Long.parseLong(userIdStr);
UserContextHolder.setUserId(userId);
} catch (NumberFormatException e) {
// 忽略无效的用户 ID
}
UserContextHolder.setUserId(userIdStr);
}
// 提取或生成 TraceId全链路唯一标识

View File

@ -19,9 +19,9 @@ class TenantContextHolderTest {
@Test
@DisplayName("设置租户ID后可以正确获取")
void setAndGetTenantId() {
TenantContextHolder.setTenantId(100L);
TenantContextHolder.setTenantId("100");
assertEquals(100L, TenantContextHolder.getTenantId());
assertEquals("100", TenantContextHolder.getTenantId());
}
@Test
@ -33,7 +33,7 @@ class TenantContextHolderTest {
@Test
@DisplayName("clear 后 getTenantId 返回 null")
void clear_removesValue() {
TenantContextHolder.setTenantId(200L);
TenantContextHolder.setTenantId("200");
TenantContextHolder.clear();
assertNull(TenantContextHolder.getTenantId());
@ -42,17 +42,17 @@ class TenantContextHolderTest {
@Test
@DisplayName("多次设置取最后一次的值")
void setMultipleTimes_lastValueWins() {
TenantContextHolder.setTenantId(10L);
TenantContextHolder.setTenantId(20L);
TenantContextHolder.setTenantId(30L);
TenantContextHolder.setTenantId("10");
TenantContextHolder.setTenantId("20");
TenantContextHolder.setTenantId("30");
assertEquals(30L, TenantContextHolder.getTenantId());
assertEquals("30", TenantContextHolder.getTenantId());
}
@Test
@DisplayName("设置 null 值后 getTenantId 返回 null")
void setNullTenantId() {
TenantContextHolder.setTenantId(100L);
TenantContextHolder.setTenantId("100");
TenantContextHolder.setTenantId(null);
assertNull(TenantContextHolder.getTenantId());
@ -61,16 +61,16 @@ class TenantContextHolderTest {
@Test
@DisplayName("线程隔离 - 子线程设置的值不影响主线程")
void threadIsolation() throws InterruptedException {
TenantContextHolder.setTenantId(1L);
TenantContextHolder.setTenantId("1");
Thread subThread = new Thread(() -> {
TenantContextHolder.setTenantId(999L);
assertEquals(999L, TenantContextHolder.getTenantId());
TenantContextHolder.setTenantId("999");
assertEquals("999", TenantContextHolder.getTenantId());
});
subThread.start();
subThread.join();
// 主线程的值不受子线程影响
assertEquals(1L, TenantContextHolder.getTenantId());
assertEquals("1", TenantContextHolder.getTenantId());
}
}

View File

@ -19,9 +19,9 @@ class UserContextHolderTest {
@Test
@DisplayName("设置用户ID后可以正确获取")
void setAndGetUserId() {
UserContextHolder.setUserId(1L);
UserContextHolder.setUserId("1");
assertEquals(1L, UserContextHolder.getUserId());
assertEquals("1", UserContextHolder.getUserId());
}
@Test
@ -35,10 +35,10 @@ class UserContextHolderTest {
@Test
@DisplayName("同时设置 userId 和 userName")
void setBoth_userId_and_userName() {
UserContextHolder.setUserId(42L);
UserContextHolder.setUserId("42");
UserContextHolder.setUserName("testuser");
assertEquals(42L, UserContextHolder.getUserId());
assertEquals("42", UserContextHolder.getUserId());
assertEquals("testuser", UserContextHolder.getUserName());
}
@ -57,7 +57,7 @@ class UserContextHolderTest {
@Test
@DisplayName("clear 后 userId 和 userName 均为 null")
void clear_removesAllValues() {
UserContextHolder.setUserId(1L);
UserContextHolder.setUserId("1");
UserContextHolder.setUserName("admin");
UserContextHolder.clear();
@ -68,26 +68,26 @@ class UserContextHolderTest {
@Test
@DisplayName("多次设置 userId 取最后一次的值")
void setUserId_multiple_lastWins() {
UserContextHolder.setUserId(1L);
UserContextHolder.setUserId(2L);
UserContextHolder.setUserId(3L);
UserContextHolder.setUserId("1");
UserContextHolder.setUserId("2");
UserContextHolder.setUserId("3");
assertEquals(3L, UserContextHolder.getUserId());
assertEquals("3", UserContextHolder.getUserId());
}
@Test
@DisplayName("线程隔离 - 子线程设置的 userId 不影响主线程")
void threadIsolation_userId() throws InterruptedException {
UserContextHolder.setUserId(1L);
UserContextHolder.setUserId("1");
Thread subThread = new Thread(() -> {
UserContextHolder.setUserId(999L);
assertEquals(999L, UserContextHolder.getUserId());
UserContextHolder.setUserId("999");
assertEquals("999", UserContextHolder.getUserId());
});
subThread.start();
subThread.join();
assertEquals(1L, UserContextHolder.getUserId());
assertEquals("1", UserContextHolder.getUserId());
}
@Test

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerIntercept
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.fundplatform.common.context.TenantContextHolder;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -26,11 +26,11 @@ public class MybatisPlusConfig {
tenantInterceptor.setTenantLineHandler(new com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler() {
@Override
public Expression getTenantId() {
Long tenantId = TenantContextHolder.getTenantId();
String tenantId = TenantContextHolder.getTenantId();
if (tenantId == null) {
return new LongValue(1);
return new StringValue("1");
}
return new LongValue(tenantId);
return new StringValue(tenantId);
}
@Override

View File

@ -30,8 +30,8 @@ public class ContactController {
*/
@Operation(summary = "创建联系人")
@PostMapping
public Result<Long> create(@Valid @RequestBody ContactDTO dto) {
Long id = contactService.createContact(dto);
public Result<String> create(@Valid @RequestBody ContactDTO dto) {
String id = contactService.createContact(dto);
return Result.success(id);
}
@ -40,7 +40,7 @@ public class ContactController {
*/
@Operation(summary = "更新联系人信息")
@PutMapping("/{id}")
public Result<Boolean> update(@Parameter(description = "联系人ID") @PathVariable Long id, @Valid @RequestBody ContactDTO dto) {
public Result<Boolean> update(@Parameter(description = "联系人ID") @PathVariable String id, @Valid @RequestBody ContactDTO dto) {
boolean result = contactService.updateContact(id, dto);
return Result.success(result);
}
@ -50,7 +50,7 @@ public class ContactController {
*/
@Operation(summary = "根据ID查询联系人")
@GetMapping("/{id}")
public Result<ContactVO> getById(@Parameter(description = "联系人ID") @PathVariable Long id) {
public Result<ContactVO> getById(@Parameter(description = "联系人ID") @PathVariable String id) {
ContactVO vo = contactService.getContactById(id);
return Result.success(vo);
}
@ -63,7 +63,7 @@ public class ContactController {
public Result<Page<ContactVO>> page(
@Parameter(description = "页码") @RequestParam(defaultValue = "1") int pageNum,
@Parameter(description = "每页条数") @RequestParam(defaultValue = "10") int pageSize,
@Parameter(description = "客户ID") @RequestParam(required = false) Long customerId) {
@Parameter(description = "客户ID") @RequestParam(required = false) String customerId) {
Page<ContactVO> page = contactService.pageContacts(pageNum, pageSize, customerId);
return Result.success(page);
}
@ -73,7 +73,7 @@ public class ContactController {
*/
@Operation(summary = "删除联系人")
@DeleteMapping("/{id}")
public Result<Boolean> delete(@Parameter(description = "联系人ID") @PathVariable Long id) {
public Result<Boolean> delete(@Parameter(description = "联系人ID") @PathVariable String id) {
boolean result = contactService.deleteContact(id);
return Result.success(result);
}
@ -84,8 +84,8 @@ public class ContactController {
@Operation(summary = "设置主要联系人", description = "将指定联系人设为客户的主要联系人")
@PutMapping("/{customerId}/contact/{contactId}/primary")
public Result<Boolean> setPrimary(
@Parameter(description = "客户ID") @PathVariable Long customerId,
@Parameter(description = "联系人ID") @PathVariable Long contactId) {
@Parameter(description = "客户ID") @PathVariable String customerId,
@Parameter(description = "联系人ID") @PathVariable String contactId) {
boolean result = contactService.setPrimaryContact(customerId, contactId);
return Result.success(result);
}

View File

@ -32,8 +32,8 @@ public class CustomerController {
*/
@Operation(summary = "创建客户")
@PostMapping
public Result<Long> createCustomer(@Valid @RequestBody CustomerCreateDTO dto) {
Long id = customerService.createCustomer(dto);
public Result<String> createCustomer(@Valid @RequestBody CustomerCreateDTO dto) {
String id = customerService.createCustomer(dto);
return Result.success(id);
}
@ -42,7 +42,7 @@ public class CustomerController {
*/
@Operation(summary = "更新客户信息")
@PutMapping("/{id}")
public Result<Void> updateCustomer(@Parameter(description = "客户ID") @PathVariable Long id, @Valid @RequestBody CustomerUpdateDTO dto) {
public Result<Void> updateCustomer(@Parameter(description = "客户ID") @PathVariable String id, @Valid @RequestBody CustomerUpdateDTO dto) {
customerService.updateCustomer(id, dto);
return Result.success();
}
@ -52,7 +52,7 @@ public class CustomerController {
*/
@Operation(summary = "查询客户详情")
@GetMapping("/{id}")
public Result<CustomerVO> getCustomer(@Parameter(description = "客户ID") @PathVariable Long id) {
public Result<CustomerVO> getCustomer(@Parameter(description = "客户ID") @PathVariable String id) {
CustomerVO vo = customerService.getCustomerById(id);
return Result.success(vo);
}
@ -82,7 +82,7 @@ public class CustomerController {
*/
@Operation(summary = "删除客户(逻辑删除)")
@DeleteMapping("/{id}")
public Result<Void> deleteCustomer(@Parameter(description = "客户ID") @PathVariable Long id) {
public Result<Void> deleteCustomer(@Parameter(description = "客户ID") @PathVariable String id) {
customerService.deleteCustomer(id);
return Result.success();
}

View File

@ -8,13 +8,13 @@ import jakarta.validation.constraints.NotNull;
*/
public class ContactDTO {
private Long id;
private String id;
/**
* 客户ID
*/
@NotNull(message = "客户ID不能为空")
private Long customerId;
private String customerId;
/**
* 联系人姓名
@ -52,19 +52,19 @@ public class ContactDTO {
*/
private String remark;
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -12,30 +12,30 @@ public interface ContactService {
/**
* 创建联系人
*/
Long createContact(ContactDTO dto);
String createContact(ContactDTO dto);
/**
* 更新联系人
*/
boolean updateContact(Long id, ContactDTO dto);
boolean updateContact(String id, ContactDTO dto);
/**
* 根据ID查询联系人
*/
ContactVO getContactById(Long id);
ContactVO getContactById(String id);
/**
* 分页查询联系人
*/
Page<ContactVO> pageContacts(int pageNum, int pageSize, Long customerId);
Page<ContactVO> pageContacts(int pageNum, int pageSize, String customerId);
/**
* 删除联系人
*/
boolean deleteContact(Long id);
boolean deleteContact(String id);
/**
* 设置主要联系人
*/
boolean setPrimaryContact(Long customerId, Long contactId);
boolean setPrimaryContact(String customerId, String contactId);
}

View File

@ -13,17 +13,17 @@ public interface CustomerService {
/**
* 创建客户
*/
Long createCustomer(CustomerCreateDTO dto);
String createCustomer(CustomerCreateDTO dto);
/**
* 更新客户
*/
void updateCustomer(Long id, CustomerUpdateDTO dto);
void updateCustomer(String id, CustomerUpdateDTO dto);
/**
* 查询客户详情
*/
CustomerVO getCustomerById(Long id);
CustomerVO getCustomerById(String id);
/**
* 分页查询客户
@ -33,5 +33,5 @@ public interface CustomerService {
/**
* 删除客户
*/
void deleteCustomer(Long id);
void deleteCustomer(String id);
}

View File

@ -32,7 +32,7 @@ public class ContactServiceImpl implements ContactService {
@Override
@Transactional(rollbackFor = Exception.class)
public Long createContact(ContactDTO dto) {
public String createContact(ContactDTO dto) {
CustomerContact contact = new CustomerContact();
contact.setCustomerId(dto.getCustomerId());
contact.setContactName(dto.getContactName());
@ -52,7 +52,7 @@ public class ContactServiceImpl implements ContactService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateContact(Long id, ContactDTO dto) {
public boolean updateContact(String id, ContactDTO dto) {
CustomerContact contact = contactDataService.getById(id);
if (contact == null || contact.getDeleted() == 1) {
throw new RuntimeException("联系人不存在");
@ -73,7 +73,7 @@ public class ContactServiceImpl implements ContactService {
}
@Override
public ContactVO getContactById(Long id) {
public ContactVO getContactById(String id) {
CustomerContact contact = contactDataService.getById(id);
if (contact == null || contact.getDeleted() == 1) {
throw new RuntimeException("联系人不存在");
@ -82,7 +82,7 @@ public class ContactServiceImpl implements ContactService {
}
@Override
public Page<ContactVO> pageContacts(int pageNum, int pageSize, Long customerId) {
public Page<ContactVO> pageContacts(int pageNum, int pageSize, String customerId) {
Page<CustomerContact> page = new Page<>(pageNum, pageSize);
LambdaQueryWrapper<CustomerContact> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CustomerContact::getDeleted, 0);
@ -100,7 +100,7 @@ public class ContactServiceImpl implements ContactService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteContact(Long id) {
public boolean deleteContact(String id) {
LambdaUpdateWrapper<CustomerContact> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(CustomerContact::getId, id);
wrapper.set(CustomerContact::getDeleted, 1);
@ -112,7 +112,7 @@ public class ContactServiceImpl implements ContactService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean setPrimaryContact(Long customerId, Long contactId) {
public boolean setPrimaryContact(String customerId, String contactId) {
// 先清除该客户的所有主要联系人标记
LambdaUpdateWrapper<CustomerContact> clearWrapper = new LambdaUpdateWrapper<>();
clearWrapper.eq(CustomerContact::getCustomerId, customerId);

View File

@ -26,7 +26,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
public Long createCustomer(CustomerCreateDTO dto) {
public String createCustomer(CustomerCreateDTO dto) {
// 检查编码是否重复
LambdaQueryWrapper<Customer> checkWrapper = new LambdaQueryWrapper<>();
checkWrapper.eq(Customer::getCustomerCode, dto.getCustomerCode());
@ -52,7 +52,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
public void updateCustomer(Long id, CustomerUpdateDTO dto) {
public void updateCustomer(String id, CustomerUpdateDTO dto) {
Customer customer = customerDataService.getById(id);
if (customer == null) {
throw new RuntimeException("客户不存在");
@ -84,7 +84,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
public CustomerVO getCustomerById(Long id) {
public CustomerVO getCustomerById(String id) {
Customer customer = customerDataService.getById(id);
if (customer == null) {
throw new RuntimeException("客户不存在");
@ -116,7 +116,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
public void deleteCustomer(Long id) {
public void deleteCustomer(String id) {
customerDataService.removeById(id);
}

View File

@ -7,12 +7,12 @@ import java.time.LocalDateTime;
*/
public class ContactVO {
private Long id;
private String id;
/**
* 客户ID
*/
private Long customerId;
private String customerId;
/**
* 客户名称
@ -64,19 +64,19 @@ public class ContactVO {
*/
private LocalDateTime updatedTime;
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -5,7 +5,7 @@ package com.fundplatform.cust.vo;
*/
public class CustomerVO {
private Long customerId;
private String customerId;
private String customerCode;
private String customerName;
private String contact;
@ -15,11 +15,11 @@ public class CustomerVO {
private Integer status;
private String remark;
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -6,7 +6,7 @@ import jakarta.validation.constraints.Size;
public class ExpenseTypeDTO {
private Long id;
private String id;
@Size(max = 50, message = "类型编码不能超过50个字符")
private String typeCode;
@ -15,7 +15,7 @@ public class ExpenseTypeDTO {
@Size(max = 100, message = "类型名称不能超过100个字符")
private String typeName;
private Long parentId = 0L;
private String parentId = "0";
private Integer typeLevel = 1;
@ -28,11 +28,11 @@ public class ExpenseTypeDTO {
private String remark;
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}
@ -52,11 +52,11 @@ public class ExpenseTypeDTO {
this.typeName = typeName;
}
public Long getParentId() {
public String getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
public void setParentId(String parentId) {
this.parentId = parentId;
}

View File

@ -16,7 +16,7 @@ public interface ExpenseTypeService {
/**
* 创建支出类型
*/
Long createType(ExpenseTypeDTO dto);
String createType(ExpenseTypeDTO dto);
/**
* 更新支出类型
@ -26,7 +26,7 @@ public interface ExpenseTypeService {
/**
* 根据ID查询支出类型
*/
ExpenseTypeVO getTypeById(Long id);
ExpenseTypeVO getTypeById(String id);
/**
* 查询支出类型树形结构
@ -36,15 +36,15 @@ public interface ExpenseTypeService {
/**
* 查询指定父级的子类型列表
*/
List<ExpenseTypeVO> getChildrenByParentId(Long parentId);
List<ExpenseTypeVO> getChildrenByParentId(String parentId);
/**
* 删除支出类型
*/
boolean deleteType(Long id);
boolean deleteType(String id);
/**
* 更新状态
*/
boolean updateStatus(Long id, Integer status);
boolean updateStatus(String id, Integer status);
}

View File

@ -52,11 +52,11 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
@Override
@Transactional(rollbackFor = Exception.class)
public Long createType(ExpenseTypeDTO dto) {
public String createType(ExpenseTypeDTO dto) {
ExpenseType type = new ExpenseType();
type.setTypeCode(dto.getTypeCode());
type.setTypeName(dto.getTypeName());
type.setParentId(dto.getParentId() != null ? dto.getParentId() : 0L);
type.setParentId(dto.getParentId() != null ? dto.getParentId() : "0");
type.setTypeLevel(dto.getTypeLevel() != null ? dto.getTypeLevel() : 1);
type.setSortOrder(dto.getSortOrder() != null ? dto.getSortOrder() : 0);
type.setDescription(dto.getDescription());
@ -86,7 +86,7 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
type.setId(dto.getId());
type.setTypeCode(dto.getTypeCode());
type.setTypeName(dto.getTypeName());
type.setParentId(dto.getParentId() != null ? dto.getParentId() : 0L);
type.setParentId(dto.getParentId() != null ? dto.getParentId() : "0");
type.setSortOrder(dto.getSortOrder());
type.setDescription(dto.getDescription());
type.setStatus(dto.getStatus());
@ -97,7 +97,7 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
}
@Override
public ExpenseTypeVO getTypeById(Long id) {
public ExpenseTypeVO getTypeById(String id) {
ExpenseType type = typeDataService.getById(id);
if (type == null || type.getDeleted() == 1) {
throw new RuntimeException("支出类型不存在");
@ -114,14 +114,14 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
.orderByAsc(ExpenseType::getSortOrder);
List<ExpenseType> types = typeDataService.list(wrapper);
return buildTree(types, 0L);
return buildTree(types, "0");
}
@Override
public List<ExpenseTypeVO> getChildrenByParentId(Long parentId) {
public List<ExpenseTypeVO> getChildrenByParentId(String parentId) {
LambdaQueryWrapper<ExpenseType> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ExpenseType::getDeleted, 0)
.eq(ExpenseType::getParentId, parentId != null ? parentId : 0L)
.eq(ExpenseType::getParentId, parentId != null ? parentId : "0")
.orderByAsc(ExpenseType::getSortOrder);
List<ExpenseType> types = typeDataService.list(wrapper);
@ -130,7 +130,7 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteType(Long id) {
public boolean deleteType(String id) {
// 检查是否有子类型
LambdaQueryWrapper<ExpenseType> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ExpenseType::getParentId, id).eq(ExpenseType::getDeleted, 0);
@ -148,7 +148,7 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateStatus(Long id, Integer status) {
public boolean updateStatus(String id, Integer status) {
LambdaUpdateWrapper<ExpenseType> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(ExpenseType::getId, id)
.set(ExpenseType::getStatus, status)
@ -159,9 +159,9 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
/**
* 构建树形结构
*/
private List<ExpenseTypeVO> buildTree(List<ExpenseType> types, Long parentId) {
private List<ExpenseTypeVO> buildTree(List<ExpenseType> types, String parentId) {
List<ExpenseTypeVO> tree = new ArrayList<>();
Map<Long, List<ExpenseType>> groupedByParent = types.stream()
Map<String, List<ExpenseType>> groupedByParent = types.stream()
.collect(Collectors.groupingBy(ExpenseType::getParentId));
List<ExpenseType> rootTypes = groupedByParent.getOrDefault(parentId, new ArrayList<>());
@ -173,7 +173,7 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
return tree;
}
private List<ExpenseTypeVO> buildChildren(Map<Long, List<ExpenseType>> groupedByParent, Long parentId) {
private List<ExpenseTypeVO> buildChildren(Map<String, List<ExpenseType>> groupedByParent, String parentId) {
List<ExpenseType> children = groupedByParent.getOrDefault(parentId, new ArrayList<>());
return children.stream().map(type -> {
ExpenseTypeVO vo = convertToVO(type);
@ -199,7 +199,7 @@ public class ExpenseTypeServiceImpl implements ExpenseTypeService {
vo.setRemark(type.getRemark());
// 查询父类型名称
if (type.getParentId() != null && type.getParentId() > 0) {
if (type.getParentId() != null && !"0".equals(type.getParentId())) {
ExpenseType parentType = typeDataService.getById(type.getParentId());
if (parentType != null) {
vo.setParentName(parentType.getTypeName());

View File

@ -8,21 +8,17 @@ import java.util.List;
public class ExpenseTypeVO {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String id;
private String typeCode;
private String typeName;
@JsonSerialize(using = ToStringSerializer.class)
private Long parentId;
private String parentId;
private String parentName;
private Integer typeLevel;
private Integer sortOrder;
private String description;
private Integer status;
@JsonSerialize(using = ToStringSerializer.class)
private Long tenantId;
@JsonSerialize(using = ToStringSerializer.class)
private Long createdBy;
private String tenantId;
private String createdBy;
private LocalDateTime createdTime;
private LocalDateTime updatedTime;
private String remark;
@ -30,11 +26,11 @@ public class ExpenseTypeVO {
/** 子节点列表(用于树形结构) */
private List<ExpenseTypeVO> children;
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}
@ -54,11 +50,11 @@ public class ExpenseTypeVO {
this.typeName = typeName;
}
public Long getParentId() {
public String getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
public void setParentId(String parentId) {
this.parentId = parentId;
}
@ -102,19 +98,19 @@ public class ExpenseTypeVO {
this.status = status;
}
public Long getTenantId() {
public String getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public Long getCreatedBy() {
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerIntercept
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.fundplatform.common.context.TenantContextHolder;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -26,11 +26,11 @@ public class MybatisPlusConfig {
tenantInterceptor.setTenantLineHandler(new com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler() {
@Override
public Expression getTenantId() {
Long tenantId = TenantContextHolder.getTenantId();
String tenantId = TenantContextHolder.getTenantId();
if (tenantId == null) {
return new LongValue(1);
return new StringValue("1");
}
return new LongValue(tenantId);
return new StringValue(tenantId);
}
@Override

View File

@ -30,8 +30,8 @@ public class ProjectController {
* 创建项目
*/
@PostMapping
public Result<Long> createProject(@Valid @RequestBody ProjectCreateDTO dto) {
Long id = projectService.createProject(dto);
public Result<String> createProject(@Valid @RequestBody ProjectCreateDTO dto) {
String id = projectService.createProject(dto);
return Result.success(id);
}
@ -39,7 +39,7 @@ public class ProjectController {
* 更新项目
*/
@PutMapping("/{id}")
public Result<Void> updateProject(@PathVariable Long id, @Valid @RequestBody ProjectUpdateDTO dto) {
public Result<Void> updateProject(@PathVariable String id, @Valid @RequestBody ProjectUpdateDTO dto) {
projectService.updateProject(id, dto);
return Result.success();
}
@ -67,7 +67,7 @@ public class ProjectController {
* 查询项目详情
*/
@GetMapping("/{id}")
public Result<ProjectVO> getProject(@PathVariable Long id) {
public Result<ProjectVO> getProject(@PathVariable String id) {
ProjectVO vo = projectService.getProjectById(id);
return Result.success(vo);
}
@ -76,7 +76,7 @@ public class ProjectController {
* 删除项目
*/
@DeleteMapping("/{id}")
public Result<Void> deleteProject(@PathVariable Long id) {
public Result<Void> deleteProject(@PathVariable String id) {
projectService.deleteProject(id);
return Result.success();
}

View File

@ -49,8 +49,8 @@ public class RequirementController {
*/
@PostMapping
public Result<RequirementVO> create(
@RequestHeader("X-Tenant-Id") Long tenantId,
@RequestHeader("X-User-Id") Long userId,
@RequestHeader("X-Tenant-Id") String tenantId,
@RequestHeader("X-User-Id") String userId,
@Valid @RequestBody RequirementDTO dto) {
return requirementService.create(tenantId, userId, dto);
}
@ -60,9 +60,9 @@ public class RequirementController {
*/
@PutMapping("/{requirementId}")
public Result<RequirementVO> update(
@RequestHeader("X-Tenant-Id") Long tenantId,
@RequestHeader("X-User-Id") Long userId,
@PathVariable Long requirementId,
@RequestHeader("X-Tenant-Id") String tenantId,
@RequestHeader("X-User-Id") String userId,
@PathVariable String requirementId,
@Valid @RequestBody RequirementDTO dto) {
return requirementService.update(tenantId, userId, requirementId, dto);
}
@ -72,9 +72,9 @@ public class RequirementController {
*/
@DeleteMapping("/{requirementId}")
public Result<Void> delete(
@RequestHeader("X-Tenant-Id") Long tenantId,
@RequestHeader("X-User-Id") Long userId,
@PathVariable Long requirementId) {
@RequestHeader("X-Tenant-Id") String tenantId,
@RequestHeader("X-User-Id") String userId,
@PathVariable String requirementId) {
return requirementService.delete(tenantId, userId, requirementId);
}
@ -83,9 +83,9 @@ public class RequirementController {
*/
@PutMapping("/{requirementId}/status")
public Result<RequirementVO> updateStatus(
@RequestHeader("X-Tenant-Id") Long tenantId,
@RequestHeader("X-User-Id") Long userId,
@PathVariable Long requirementId,
@RequestHeader("X-Tenant-Id") String tenantId,
@RequestHeader("X-User-Id") String userId,
@PathVariable String requirementId,
@RequestParam String status) {
return requirementService.updateStatus(tenantId, userId, requirementId, status);
}
@ -95,9 +95,9 @@ public class RequirementController {
*/
@PutMapping("/{requirementId}/progress")
public Result<RequirementVO> updateProgress(
@RequestHeader("X-Tenant-Id") Long tenantId,
@RequestHeader("X-User-Id") Long userId,
@PathVariable Long requirementId,
@RequestHeader("X-Tenant-Id") String tenantId,
@RequestHeader("X-User-Id") String userId,
@PathVariable String requirementId,
@RequestParam Integer progress) {
return requirementService.updateProgress(tenantId, userId, requirementId, progress);
}

View File

@ -18,7 +18,7 @@ public class ProjectCreateDTO {
private String projectName;
@NotNull(message = "客户ID不能为空")
private Long customerId;
private String customerId;
private String customerName;
@ -47,11 +47,11 @@ public class ProjectCreateDTO {
this.projectName = projectName;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -18,7 +18,7 @@ public class ProjectUpdateDTO {
private String projectName;
@NotNull(message = "客户ID不能为空")
private Long customerId;
private String customerId;
@NotBlank(message = "项目类型不能为空")
private String projectType;
@ -46,11 +46,11 @@ public class ProjectUpdateDTO {
this.projectName = projectName;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -16,17 +16,17 @@ public interface ProjectService {
/**
* 创建项目
*/
Long createProject(ProjectCreateDTO dto);
String createProject(ProjectCreateDTO dto);
/**
* 更新项目
*/
void updateProject(Long id, ProjectUpdateDTO dto);
void updateProject(String id, ProjectUpdateDTO dto);
/**
* 查询项目详情
*/
ProjectVO getProjectById(Long id);
ProjectVO getProjectById(String id);
/**
* 分页查询项目
@ -36,7 +36,7 @@ public interface ProjectService {
/**
* 删除项目
*/
void deleteProject(Long id);
void deleteProject(String id);
/**
* 获取项目状态分布

View File

@ -99,7 +99,7 @@ public class RequirementService {
* 创建需求工单
*/
@Transactional
public Result<RequirementVO> create(Long tenantId, Long userId, RequirementDTO dto) {
public Result<RequirementVO> create(String tenantId, String userId, RequirementDTO dto) {
// 检查编号唯一性
long count = requirementDataService.count(
new LambdaQueryWrapper<Requirement>()
@ -141,7 +141,7 @@ public class RequirementService {
* 更新需求工单
*/
@Transactional
public Result<RequirementVO> update(Long tenantId, Long userId, Long requirementId, RequirementDTO dto) {
public Result<RequirementVO> update(String tenantId, String userId, String requirementId, RequirementDTO dto) {
Requirement requirement = requirementDataService.getOne(
new LambdaQueryWrapper<Requirement>()
.eq(Requirement::getId, requirementId)
@ -182,7 +182,7 @@ public class RequirementService {
* 删除需求工单
*/
@Transactional
public Result<Void> delete(Long tenantId, Long userId, Long requirementId) {
public Result<Void> delete(String tenantId, String userId, String requirementId) {
Requirement requirement = requirementDataService.getOne(
new LambdaQueryWrapper<Requirement>()
.eq(Requirement::getId, requirementId)
@ -208,7 +208,7 @@ public class RequirementService {
* 更新需求状态
*/
@Transactional
public Result<RequirementVO> updateStatus(Long tenantId, Long userId, Long requirementId, String status) {
public Result<RequirementVO> updateStatus(String tenantId, String userId, String requirementId, String status) {
Requirement requirement = requirementDataService.getOne(
new LambdaQueryWrapper<Requirement>()
.eq(Requirement::getId, requirementId)
@ -235,7 +235,7 @@ public class RequirementService {
* 更新开发进度
*/
@Transactional
public Result<RequirementVO> updateProgress(Long tenantId, Long userId, Long requirementId, Integer progress) {
public Result<RequirementVO> updateProgress(String tenantId, String userId, String requirementId, Integer progress) {
Requirement requirement = requirementDataService.getOne(
new LambdaQueryWrapper<Requirement>()
.eq(Requirement::getId, requirementId)

View File

@ -31,7 +31,7 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public Long createProject(ProjectCreateDTO dto) {
public String createProject(ProjectCreateDTO dto) {
// 检查编码是否重复
LambdaQueryWrapper<Project> checkWrapper = new LambdaQueryWrapper<>();
checkWrapper.eq(Project::getProjectCode, dto.getProjectCode());
@ -60,7 +60,7 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public void updateProject(Long id, ProjectUpdateDTO dto) {
public void updateProject(String id, ProjectUpdateDTO dto) {
Project project = projectDataService.getById(id);
if (project == null) {
throw new RuntimeException("项目不存在");
@ -94,7 +94,7 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public ProjectVO getProjectById(Long id) {
public ProjectVO getProjectById(String id) {
Project project = projectDataService.getById(id);
if (project == null) {
throw new RuntimeException("项目不存在");
@ -126,7 +126,7 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public void deleteProject(Long id) {
public void deleteProject(String id) {
projectDataService.removeById(id);
}

View File

@ -8,10 +8,10 @@ import java.time.LocalDate;
*/
public class ProjectVO {
private Long projectId;
private String projectId;
private String projectCode;
private String projectName;
private Long customerId;
private String customerId;
private String customerName;
private String projectType;
private BigDecimal budgetAmount;
@ -21,11 +21,11 @@ public class ProjectVO {
private Integer status;
private String remark;
public Long getProjectId() {
public String getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
public void setProjectId(String projectId) {
this.projectId = projectId;
}
@ -45,11 +45,11 @@ public class ProjectVO {
this.projectName = projectName;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -9,13 +9,13 @@ import java.time.LocalDateTime;
*/
public class RequirementVO {
private Long requirementId;
private String requirementId;
private String requirementCode;
private String requirementName;
private String description;
private Long projectId;
private String projectId;
private String projectName;
private Long customerId;
private String customerId;
private String customerName;
private String priority;
private String priorityName;
@ -32,15 +32,15 @@ public class RequirementVO {
private String statusName;
private Integer progress;
private String attachmentUrl;
private Long tenantId;
private String tenantId;
private LocalDateTime createdTime;
private LocalDateTime updatedTime;
public Long getRequirementId() {
public String getRequirementId() {
return requirementId;
}
public void setRequirementId(Long requirementId) {
public void setRequirementId(String requirementId) {
this.requirementId = requirementId;
}
@ -68,11 +68,11 @@ public class RequirementVO {
this.description = description;
}
public Long getProjectId() {
public String getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
public void setProjectId(String projectId) {
this.projectId = projectId;
}
@ -84,11 +84,11 @@ public class RequirementVO {
this.projectName = projectName;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
@ -220,11 +220,11 @@ public class RequirementVO {
this.attachmentUrl = attachmentUrl;
}
public Long getTenantId() {
public String getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

View File

@ -25,8 +25,8 @@ public class FundRequestController {
* 创建用款申请
*/
@PostMapping
public Result<Long> create(@Valid @RequestBody FundRequestDTO dto) {
Long id = fundRequestService.createRequest(dto);
public Result<String> create(@Valid @RequestBody FundRequestDTO dto) {
String id = fundRequestService.createRequest(dto);
return Result.success(id);
}
@ -43,7 +43,7 @@ public class FundRequestController {
* 根据ID查询用款申请
*/
@GetMapping("/{id}")
public Result<FundRequestVO> getById(@PathVariable Long id) {
public Result<FundRequestVO> getById(@PathVariable String id) {
FundRequestVO vo = fundRequestService.getRequestById(id);
return Result.success(vo);
}
@ -66,7 +66,7 @@ public class FundRequestController {
* 删除用款申请
*/
@DeleteMapping("/{id}")
public Result<Boolean> delete(@PathVariable Long id) {
public Result<Boolean> delete(@PathVariable String id) {
boolean result = fundRequestService.deleteRequest(id);
return Result.success(result);
}
@ -75,7 +75,7 @@ public class FundRequestController {
* 提交审批
*/
@PostMapping("/{id}/submit")
public Result<Boolean> submit(@PathVariable Long id) {
public Result<Boolean> submit(@PathVariable String id) {
boolean result = fundRequestService.submitApproval(id);
return Result.success(result);
}
@ -84,7 +84,7 @@ public class FundRequestController {
* 审批通过
*/
@PutMapping("/{id}/approve")
public Result<Boolean> approve(@PathVariable Long id, @RequestParam(required = false) String comment) {
public Result<Boolean> approve(@PathVariable String id, @RequestParam(required = false) String comment) {
boolean result = fundRequestService.approve(id, comment);
return Result.success(result);
}
@ -93,7 +93,7 @@ public class FundRequestController {
* 审批拒绝
*/
@PutMapping("/{id}/reject")
public Result<Boolean> reject(@PathVariable Long id, @RequestParam(required = false) String comment) {
public Result<Boolean> reject(@PathVariable String id, @RequestParam(required = false) String comment) {
boolean result = fundRequestService.reject(id, comment);
return Result.success(result);
}
@ -102,7 +102,7 @@ public class FundRequestController {
* 撤回申请
*/
@PutMapping("/{id}/withdraw")
public Result<Boolean> withdraw(@PathVariable Long id) {
public Result<Boolean> withdraw(@PathVariable String id) {
boolean result = fundRequestService.withdraw(id);
return Result.success(result);
}

View File

@ -13,7 +13,7 @@ import java.time.LocalDateTime;
*/
public class FundRequestDTO {
private Long id;
private String id;
@NotBlank(message = "申请标题不能为空")
@Size(max = 200, message = "申请标题不能超过200个字符")
@ -41,9 +41,9 @@ public class FundRequestDTO {
@Size(max = 500, message = "用途说明不能超过500个字符")
private String purpose;
private Long projectId;
private String projectId;
private Long customerId;
private String customerId;
private LocalDateTime expectedPayDate;
@ -51,11 +51,11 @@ public class FundRequestDTO {
private String remark;
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}
@ -123,19 +123,19 @@ public class FundRequestDTO {
this.purpose = purpose;
}
public Long getProjectId() {
public String getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}

View File

@ -15,7 +15,7 @@ public interface FundRequestService {
* @param dto 用款申请DTO
* @return 申请ID
*/
Long createRequest(FundRequestDTO dto);
String createRequest(FundRequestDTO dto);
/**
* 更新用款申请
@ -31,7 +31,7 @@ public interface FundRequestService {
* @param id 申请ID
* @return 用款申请VO
*/
FundRequestVO getRequestById(Long id);
FundRequestVO getRequestById(String id);
/**
* 分页查询用款申请
@ -51,7 +51,7 @@ public interface FundRequestService {
* @param id 申请ID
* @return 是否成功
*/
boolean deleteRequest(Long id);
boolean deleteRequest(String id);
/**
* 提交审批
@ -59,7 +59,7 @@ public interface FundRequestService {
* @param id 申请ID
* @return 是否成功
*/
boolean submitApproval(Long id);
boolean submitApproval(String id);
/**
* 审批通过
@ -68,7 +68,7 @@ public interface FundRequestService {
* @param comment 审批意见
* @return 是否成功
*/
boolean approve(Long id, String comment);
boolean approve(String id, String comment);
/**
* 审批拒绝
@ -77,7 +77,7 @@ public interface FundRequestService {
* @param comment 审批意见
* @return 是否成功
*/
boolean reject(Long id, String comment);
boolean reject(String id, String comment);
/**
* 撤回申请
@ -85,5 +85,5 @@ public interface FundRequestService {
* @param id 申请ID
* @return 是否成功
*/
boolean withdraw(Long id);
boolean withdraw(String id);
}

View File

@ -36,7 +36,7 @@ public class FundRequestServiceImpl implements FundRequestService {
@Override
@Transactional(rollbackFor = Exception.class)
public Long createRequest(FundRequestDTO dto) {
public String createRequest(FundRequestDTO dto) {
FundRequest request = new FundRequest();
request.setRequestNo(generateRequestNo());
request.setTitle(dto.getTitle());
@ -101,7 +101,7 @@ public class FundRequestServiceImpl implements FundRequestService {
}
@Override
public FundRequestVO getRequestById(Long id) {
public FundRequestVO getRequestById(String id) {
FundRequest request = requestDataService.getById(id);
if (request == null || request.getDeleted() == 1) {
throw new RuntimeException("用款申请不存在");
@ -135,7 +135,7 @@ public class FundRequestServiceImpl implements FundRequestService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteRequest(Long id) {
public boolean deleteRequest(String id) {
LambdaUpdateWrapper<FundRequest> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(FundRequest::getId, id);
wrapper.set(FundRequest::getDeleted, 1);
@ -147,7 +147,7 @@ public class FundRequestServiceImpl implements FundRequestService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submitApproval(Long id) {
public boolean submitApproval(String id) {
FundRequest request = requestDataService.getById(id);
if (request == null || request.getDeleted() == 1) {
throw new RuntimeException("用款申请不存在");
@ -168,7 +168,7 @@ public class FundRequestServiceImpl implements FundRequestService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean approve(Long id, String comment) {
public boolean approve(String id, String comment) {
FundRequest request = requestDataService.getById(id);
if (request == null || request.getDeleted() == 1) {
throw new RuntimeException("用款申请不存在");
@ -191,7 +191,7 @@ public class FundRequestServiceImpl implements FundRequestService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean reject(Long id, String comment) {
public boolean reject(String id, String comment) {
FundRequest request = requestDataService.getById(id);
if (request == null || request.getDeleted() == 1) {
throw new RuntimeException("用款申请不存在");
@ -214,7 +214,7 @@ public class FundRequestServiceImpl implements FundRequestService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean withdraw(Long id) {
public boolean withdraw(String id) {
FundRequest request = requestDataService.getById(id);
if (request == null || request.getDeleted() == 1) {
throw new RuntimeException("用款申请不存在");

View File

@ -8,7 +8,7 @@ import java.time.LocalDateTime;
*/
public class FundRequestVO {
private Long id;
private String id;
private String requestNo;
private String title;
private BigDecimal amount;
@ -19,31 +19,31 @@ public class FundRequestVO {
private String payeeBank;
private String payeeAccount;
private String purpose;
private Long projectId;
private String projectId;
private String projectName;
private Long customerId;
private String customerId;
private String customerName;
private LocalDateTime requestDate;
private LocalDateTime expectedPayDate;
private Integer approvalStatus;
private String approvalStatusName;
private Integer currentNode;
private Long approverId;
private String approverId;
private String approverName;
private LocalDateTime approvalTime;
private String approvalComment;
private String attachments;
private Long tenantId;
private Long createdBy;
private String tenantId;
private String createdBy;
private String createdByName;
private LocalDateTime createdTime;
private LocalDateTime updatedTime;
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}
@ -127,11 +127,11 @@ public class FundRequestVO {
this.purpose = purpose;
}
public Long getProjectId() {
public String getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
public void setProjectId(String projectId) {
this.projectId = projectId;
}
@ -143,11 +143,11 @@ public class FundRequestVO {
this.projectName = projectName;
}
public Long getCustomerId() {
public String getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
@ -199,11 +199,11 @@ public class FundRequestVO {
this.currentNode = currentNode;
}
public Long getApproverId() {
public String getApproverId() {
return approverId;
}
public void setApproverId(Long approverId) {
public void setApproverId(String approverId) {
this.approverId = approverId;
}
@ -239,19 +239,19 @@ public class FundRequestVO {
this.attachments = attachments;
}
public Long getTenantId() {
public String getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public Long getCreatedBy() {
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}

View File

@ -39,12 +39,12 @@ class AuthServiceImplTest {
@BeforeEach
void setUp() {
mockUser = new SysUser();
mockUser.setId(1L);
mockUser.setId("1");
mockUser.setUsername("testuser");
// MD5("password123") 的值直接使用固定的 MD5 字符串避免调用加密工具
mockUser.setPassword("482c811da5d5b4bc6d497ffa98491e38");
mockUser.setStatus(1);
mockUser.setTenantId(100L);
mockUser.setTenantId("100");
mockUser.setDeleted(0);
}
@ -58,17 +58,17 @@ class AuthServiceImplTest {
when(userDataService.getOne(ArgumentMatchers.<LambdaQueryWrapper<SysUser>>any()))
.thenReturn(mockUser);
when(tokenService.generateToken(1L, "testuser", 100L))
when(tokenService.generateToken("1", "testuser", "100"))
.thenReturn("mock-token-uuid");
LoginVO result = authService.login(request);
assertNotNull(result);
assertEquals(1L, result.getUserId());
assertEquals("1", result.getUserId());
assertEquals("testuser", result.getUsername());
assertEquals("mock-token-uuid", result.getToken());
assertEquals(100L, result.getTenantId());
verify(tokenService).generateToken(1L, "testuser", 100L);
assertEquals("100", result.getTenantId());
verify(tokenService).generateToken("1", "testuser", "100");
}
@Test
@ -83,7 +83,7 @@ class AuthServiceImplTest {
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.login(request));
assertEquals("用户名或密码错误", ex.getMessage());
verify(tokenService, never()).generateToken(anyLong(), anyString(), anyLong());
verify(tokenService, never()).generateToken(anyString(), anyString(), anyString());
}
@Test
@ -98,7 +98,7 @@ class AuthServiceImplTest {
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.login(request));
assertEquals("用户名或密码错误", ex.getMessage());
verify(tokenService, never()).generateToken(anyLong(), anyString(), anyLong());
verify(tokenService, never()).generateToken(anyString(), anyString(), anyString());
}
@Test
@ -120,20 +120,20 @@ class AuthServiceImplTest {
@Test
@DisplayName("登出成功 - 清除所有 Token")
void logout_success() {
doNothing().when(tokenService).deleteAllUserTokens(1L);
doNothing().when(tokenService).deleteAllUserTokens("1");
authService.logout(1L);
authService.logout("1");
verify(tokenService).deleteAllUserTokens(1L);
verify(tokenService).deleteAllUserTokens("1");
}
@Test
@DisplayName("刷新 Token 成功")
void refreshToken_success() {
when(userDataService.getById(1L)).thenReturn(mockUser);
when(tokenService.generateToken(1L, "testuser", 100L)).thenReturn("new-token");
when(userDataService.getById("1")).thenReturn(mockUser);
when(tokenService.generateToken("1", "testuser", "100")).thenReturn("new-token");
LoginVO result = authService.refreshToken(1L);
LoginVO result = authService.refreshToken("1");
assertNotNull(result);
assertEquals("new-token", result.getToken());
@ -142,9 +142,9 @@ class AuthServiceImplTest {
@Test
@DisplayName("刷新 Token 失败 - 用户不存在")
void refreshToken_fail_userNotFound() {
when(userDataService.getById(99L)).thenReturn(null);
when(userDataService.getById("99")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.refreshToken(99L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.refreshToken("99"));
assertEquals("用户不存在", ex.getMessage());
}
@ -152,9 +152,9 @@ class AuthServiceImplTest {
@DisplayName("刷新 Token 失败 - 用户已被禁用")
void refreshToken_fail_userDisabled() {
mockUser.setStatus(0);
when(userDataService.getById(1L)).thenReturn(mockUser);
when(userDataService.getById("1")).thenReturn(mockUser);
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.refreshToken(1L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.refreshToken("1"));
assertEquals("用户已被禁用", ex.getMessage());
}
@ -164,12 +164,12 @@ class AuthServiceImplTest {
mockUser.setRealName("测试用户");
mockUser.setPhone("13800138000");
mockUser.setEmail("test@example.com");
when(userDataService.getById(1L)).thenReturn(mockUser);
when(userDataService.getById("1")).thenReturn(mockUser);
UserVO result = authService.getUserInfo(1L);
UserVO result = authService.getUserInfo("1");
assertNotNull(result);
assertEquals(1L, result.getId());
assertEquals("1", result.getId());
assertEquals("testuser", result.getUsername());
assertEquals("测试用户", result.getRealName());
}
@ -177,9 +177,9 @@ class AuthServiceImplTest {
@Test
@DisplayName("获取用户信息失败 - 用户不存在")
void getUserInfo_fail_userNotFound() {
when(userDataService.getById(99L)).thenReturn(null);
when(userDataService.getById("99")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.getUserInfo(99L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> authService.getUserInfo("99"));
assertEquals("用户不存在", ex.getMessage());
}
}

View File

@ -49,14 +49,14 @@ class RoleServiceImplTest {
@BeforeEach
void setUp() {
mockRole = new SysRole();
mockRole.setId(1L);
mockRole.setId("1");
mockRole.setRoleCode("ADMIN");
mockRole.setRoleName("管理员");
mockRole.setDataScope(1);
mockRole.setStatus(1);
mockRole.setSortOrder(1);
mockRole.setDeleted(0);
mockRole.setTenantId(100L);
mockRole.setTenantId("100");
}
// ==================== createRole ====================
@ -111,12 +111,12 @@ class RoleServiceImplTest {
@DisplayName("更新角色成功")
void updateRole_success() {
RoleDTO dto = new RoleDTO();
dto.setId(1L);
dto.setId("1");
dto.setRoleName("超级管理员");
dto.setDataScope(1);
dto.setStatus(1);
when(roleDataService.getById(1L)).thenReturn(mockRole);
when(roleDataService.getById("1")).thenReturn(mockRole);
when(roleDataService.updateById(any(SysRole.class))).thenReturn(true);
boolean result = roleService.updateRole(dto);
@ -139,10 +139,10 @@ class RoleServiceImplTest {
@DisplayName("更新角色失败 - 角色不存在")
void updateRole_fail_notFound() {
RoleDTO dto = new RoleDTO();
dto.setId(99L);
dto.setId("1");
dto.setRoleName("不存在的角色");
when(roleDataService.getById(99L)).thenReturn(null);
when(roleDataService.getById("1")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> roleService.updateRole(dto));
assertEquals("角色不存在", ex.getMessage());
@ -153,10 +153,10 @@ class RoleServiceImplTest {
void updateRole_fail_deleted() {
mockRole.setDeleted(1);
RoleDTO dto = new RoleDTO();
dto.setId(1L);
dto.setId("1");
dto.setRoleName("已删除角色");
when(roleDataService.getById(1L)).thenReturn(mockRole);
when(roleDataService.getById("1")).thenReturn(mockRole);
RuntimeException ex = assertThrows(RuntimeException.class, () -> roleService.updateRole(dto));
assertEquals("角色不存在", ex.getMessage());
@ -167,12 +167,12 @@ class RoleServiceImplTest {
@Test
@DisplayName("根据ID查询角色成功")
void getRoleById_success() {
when(roleDataService.getById(1L)).thenReturn(mockRole);
when(roleDataService.getById("1")).thenReturn(mockRole);
RoleVO vo = roleService.getRoleById(1L);
RoleVO vo = roleService.getRoleById("1");
assertNotNull(vo);
assertEquals(1L, vo.getId());
assertEquals("1", vo.getId());
assertEquals("ADMIN", vo.getRoleCode());
assertEquals("管理员", vo.getRoleName());
assertEquals("全部数据", vo.getDataScopeName());
@ -181,9 +181,9 @@ class RoleServiceImplTest {
@Test
@DisplayName("根据ID查询角色失败 - 不存在")
void getRoleById_fail_notFound() {
when(roleDataService.getById(99L)).thenReturn(null);
when(roleDataService.getById("1")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> roleService.getRoleById(99L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> roleService.getRoleById("1"));
assertEquals("角色不存在", ex.getMessage());
}
@ -191,9 +191,9 @@ class RoleServiceImplTest {
@DisplayName("根据ID查询角色失败 - 已删除")
void getRoleById_fail_deleted() {
mockRole.setDeleted(1);
when(roleDataService.getById(1L)).thenReturn(mockRole);
when(roleDataService.getById("1")).thenReturn(mockRole);
RuntimeException ex = assertThrows(RuntimeException.class, () -> roleService.getRoleById(1L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> roleService.getRoleById("1"));
assertEquals("角色不存在", ex.getMessage());
}
@ -265,7 +265,7 @@ class RoleServiceImplTest {
void deleteRole_success() {
when(roleDataService.update(ArgumentMatchers.<LambdaUpdateWrapper<SysRole>>any())).thenReturn(true);
boolean result = roleService.deleteRole(1L);
boolean result = roleService.deleteRole("1");
assertTrue(result);
}
@ -277,7 +277,7 @@ class RoleServiceImplTest {
void updateStatus_success() {
when(roleDataService.update(ArgumentMatchers.<LambdaUpdateWrapper<SysRole>>any())).thenReturn(true);
boolean result = roleService.updateStatus(1L, 0);
boolean result = roleService.updateStatus("1", 0);
assertTrue(result);
}
@ -293,9 +293,9 @@ class RoleServiceImplTest {
for (int i = 0; i < scopes.length; i++) {
mockRole.setDataScope(scopes[i]);
mockRole.setDeleted(0);
when(roleDataService.getById((long) (i + 10))).thenReturn(mockRole);
when(roleDataService.getById(String.valueOf(i + 10))).thenReturn(mockRole);
RoleVO vo = roleService.getRoleById((long) (i + 10));
RoleVO vo = roleService.getRoleById(String.valueOf(i + 10));
assertEquals(names[i], vo.getDataScopeName(), "dataScope=" + scopes[i] + " 的名称应为 " + names[i]);
}
}
@ -304,9 +304,9 @@ class RoleServiceImplTest {
@DisplayName("数据范围名称转换 - 未知值返回空字符串")
void getRoleById_unknownDataScope() {
mockRole.setDataScope(99);
when(roleDataService.getById(1L)).thenReturn(mockRole);
when(roleDataService.getById("1")).thenReturn(mockRole);
RoleVO vo = roleService.getRoleById(1L);
RoleVO vo = roleService.getRoleById("1");
assertEquals("", vo.getDataScopeName());
}
}

View File

@ -52,10 +52,10 @@ class TenantServiceImplTest {
@BeforeEach
void setUp() {
// 设置 UserContextHolderTenantServiceImpl 调用 UserContextHolder.getUserId()
UserContextHolder.setUserId(1L);
UserContextHolder.setUserId("1");
mockTenant = new SysTenant();
mockTenant.setId(1L);
mockTenant.setId("1");
mockTenant.setTenantCode("TENANT001");
mockTenant.setTenantName("测试租户");
mockTenant.setContact("张三");
@ -125,13 +125,13 @@ class TenantServiceImplTest {
@DisplayName("更新租户成功")
void updateTenant_success() {
TenantDTO dto = new TenantDTO();
dto.setId(1L);
dto.setId("1");
dto.setTenantCode("TENANT001"); // 编码不变
dto.setTenantName("更新的租户名");
dto.setContact("李四");
dto.setStatus(1);
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
when(tenantDataService.updateById(any(SysTenant.class))).thenReturn(true);
boolean result = tenantService.updateTenant(dto);
@ -153,11 +153,11 @@ class TenantServiceImplTest {
@DisplayName("更新租户失败 - 租户不存在")
void updateTenant_fail_notFound() {
TenantDTO dto = new TenantDTO();
dto.setId(99L);
dto.setId("99");
dto.setTenantCode("XXXX");
dto.setTenantName("不存在");
when(tenantDataService.getById(99L)).thenReturn(null);
when(tenantDataService.getById("99")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateTenant(dto));
assertEquals("租户不存在", ex.getMessage());
@ -168,11 +168,11 @@ class TenantServiceImplTest {
void updateTenant_fail_deleted() {
mockTenant.setDeleted(1);
TenantDTO dto = new TenantDTO();
dto.setId(1L);
dto.setId("1");
dto.setTenantCode("TENANT001");
dto.setTenantName("已删除租户");
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateTenant(dto));
assertEquals("租户不存在", ex.getMessage());
@ -182,11 +182,11 @@ class TenantServiceImplTest {
@DisplayName("更新租户失败 - 更换编码时新编码已被占用")
void updateTenant_fail_newCodeExists() {
TenantDTO dto = new TenantDTO();
dto.setId(1L);
dto.setId("1");
dto.setTenantCode("EXISTING_CODE");
dto.setTenantName("修改编码的租户");
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
when(tenantDataService.count(ArgumentMatchers.<LambdaQueryWrapper<SysTenant>>any())).thenReturn(1L);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateTenant(dto));
@ -198,12 +198,12 @@ class TenantServiceImplTest {
@Test
@DisplayName("根据ID查询租户成功")
void getTenantById_success() {
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
TenantVO vo = tenantService.getTenantById(1L);
TenantVO vo = tenantService.getTenantById("1");
assertNotNull(vo);
assertEquals(1L, vo.getId());
assertEquals("1", vo.getId());
assertEquals("TENANT001", vo.getTenantCode());
assertEquals("测试租户", vo.getTenantName());
assertEquals("启用", vo.getStatusName());
@ -213,9 +213,9 @@ class TenantServiceImplTest {
@DisplayName("根据ID查询租户 - 禁用状态名称为\"禁用\"")
void getTenantById_disabled_statusName() {
mockTenant.setStatus(0);
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
TenantVO vo = tenantService.getTenantById(1L);
TenantVO vo = tenantService.getTenantById("1");
assertEquals("禁用", vo.getStatusName());
}
@ -223,9 +223,9 @@ class TenantServiceImplTest {
@Test
@DisplayName("根据ID查询租户失败 - 不存在")
void getTenantById_fail_notFound() {
when(tenantDataService.getById(99L)).thenReturn(null);
when(tenantDataService.getById("99")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.getTenantById(99L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.getTenantById("99"));
assertEquals("租户不存在", ex.getMessage());
}
@ -233,9 +233,9 @@ class TenantServiceImplTest {
@DisplayName("根据ID查询租户失败 - 已删除")
void getTenantById_fail_deleted() {
mockTenant.setDeleted(1);
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.getTenantById(1L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.getTenantById("1"));
assertEquals("租户不存在", ex.getMessage());
}
@ -277,10 +277,10 @@ class TenantServiceImplTest {
@Test
@DisplayName("删除租户成功")
void deleteTenant_success() {
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
when(tenantDataService.update(ArgumentMatchers.<LambdaUpdateWrapper<SysTenant>>any())).thenReturn(true);
boolean result = tenantService.deleteTenant(1L);
boolean result = tenantService.deleteTenant("1");
assertTrue(result);
}
@ -288,9 +288,9 @@ class TenantServiceImplTest {
@Test
@DisplayName("删除租户失败 - 租户不存在")
void deleteTenant_fail_notFound() {
when(tenantDataService.getById(99L)).thenReturn(null);
when(tenantDataService.getById("99")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.deleteTenant(99L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.deleteTenant("99"));
assertEquals("租户不存在", ex.getMessage());
}
@ -298,9 +298,9 @@ class TenantServiceImplTest {
@DisplayName("删除租户失败 - 不允许删除默认租户")
void deleteTenant_fail_defaultTenant() {
mockTenant.setTenantCode("DEFAULT");
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.deleteTenant(1L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.deleteTenant("1"));
assertEquals("默认租户不能删除", ex.getMessage());
}
@ -308,9 +308,9 @@ class TenantServiceImplTest {
@DisplayName("删除租户失败 - 已删除的租户")
void deleteTenant_fail_alreadyDeleted() {
mockTenant.setDeleted(1);
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.deleteTenant(1L));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.deleteTenant("1"));
assertEquals("租户不存在", ex.getMessage());
}
@ -319,10 +319,10 @@ class TenantServiceImplTest {
@Test
@DisplayName("更新租户状态成功")
void updateStatus_success() {
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
when(tenantDataService.update(ArgumentMatchers.<LambdaUpdateWrapper<SysTenant>>any())).thenReturn(true);
boolean result = tenantService.updateStatus(1L, 0);
boolean result = tenantService.updateStatus("1", 0);
assertTrue(result);
}
@ -330,9 +330,9 @@ class TenantServiceImplTest {
@Test
@DisplayName("更新租户状态失败 - 租户不存在")
void updateStatus_fail_notFound() {
when(tenantDataService.getById(99L)).thenReturn(null);
when(tenantDataService.getById("99")).thenReturn(null);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateStatus(99L, 0));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateStatus("99", 0));
assertEquals("租户不存在", ex.getMessage());
}
@ -340,9 +340,9 @@ class TenantServiceImplTest {
@DisplayName("更新租户状态失败 - 已删除的租户")
void updateStatus_fail_deleted() {
mockTenant.setDeleted(1);
when(tenantDataService.getById(1L)).thenReturn(mockTenant);
when(tenantDataService.getById("1")).thenReturn(mockTenant);
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateStatus(1L, 0));
RuntimeException ex = assertThrows(RuntimeException.class, () -> tenantService.updateStatus("1", 0));
assertEquals("租户不存在", ex.getMessage());
}
}

75
start-services.sh Executable file
View File

@ -0,0 +1,75 @@
#!/bin/bash
# 资金服务平台 - 服务启动脚本
# 使用 Maven spring-boot:run 启动各个微服务
# 设置环境变量
export MAVEN_HOME=/home/along/MyApp/apache-maven-3.9.9
export PATH=$MAVEN_HOME/bin:$PATH
export JAVA_HOME=/home/along/MyApp/jdk-21.0.7
export PATH=$JAVA_HOME/bin:$PATH
# 项目根目录
PROJECT_DIR="/home/along/MyCode/wjbl/fundplatform"
LOG_DIR="/tmp/fundplatform-logs"
# 创建日志目录
mkdir -p $LOG_DIR
echo "========================================="
echo "资金服务平台 - 启动所有服务"
echo "========================================="
cd $PROJECT_DIR
# 服务列表(按启动顺序)
SERVICES=(
"fund-sys:8100"
"fund-gateway:9000"
"fund-cust:8200"
"fund-proj:8300"
"fund-req:8400"
"fund-exp:8500"
"fund-receipt:8600"
"fund-report:8700"
"fund-file:8800"
)
# 启动服务函数
start_service() {
local service_module=$1
local service_port=$2
echo "启动服务: $service_module (端口: $service_port)"
nohup mvn spring-boot:run -pl $service_module -am \
> $LOG_DIR/$service_module.log 2>&1 &
echo " PID: $!"
echo " 日志: $LOG_DIR/$service_module.log"
# 等待一小段时间让服务开始启动
sleep 3
}
# 启动所有服务
for service in "${SERVICES[@]}"; do
IFS=':' read -r module port <<< "$service"
start_service "$module" "$port"
done
echo ""
echo "========================================="
echo "所有服务已开始启动"
echo "========================================="
echo "日志目录: $LOG_DIR"
echo ""
echo "检查服务状态:"
echo " ps aux | grep 'spring-boot:run'"
echo ""
echo "查看服务日志:"
echo " tail -f $LOG_DIR/fund-sys.log"
echo ""
echo "访问 Nacos 控制台查看服务注册状态:"
echo " http://localhost:8048"
echo "========================================="