feat: 重构员工控制器并优化JSON序列化配置
refactor(EmployeeController): 重命名EmployyeController为EmployeeController并优化代码结构 feat(EmployeeController): 添加@JsonIgnoreProperties注解解决循环引用问题 feat(JacksonConfig): 新增Jackson配置类处理Hibernate代理和循环引用 fix(EmployeeService): 修复缓存注解格式问题 feat(Employee): 添加@JsonIgnoreProperties注解忽略可能导致循环引用的字段 feat(EmployeeRole): 添加@JsonIgnore注解忽略关联字段 fix(application.properties): 调整Redis缓存配置和错误处理设置 refactor(IndexController): 移除错误处理方法 feat(GlobalExceptionHandler): 新增全局异常处理类 refactor(SecurityConfig): 优化安全配置并启用方法级安全注解 refactor(AbstractCtx): 优化日期时间处理方法 build: 更新项目版本至0.0.53-SNAPSHOT
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.company.tasker;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -76,7 +77,7 @@ public class CompanyCompositeUpdateTasker extends Tasker<Object> {
|
||||
} catch (Exception e) {
|
||||
cloudRk.setDescription(e.getMessage());
|
||||
} finally {
|
||||
cloudRk.setLatestUpdate(Instant.now());
|
||||
cloudRk.setLatestUpdate(LocalDateTime.now());
|
||||
cloudRkService.save(cloudRk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ecep.contract.ds.other.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.ds.other.service.BankService;
|
||||
import com.ecep.contract.model.Bank;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/bank")
|
||||
public class BankController {
|
||||
@Autowired
|
||||
private BankService bankService;
|
||||
|
||||
@RequestMapping("/findById")
|
||||
public Bank findById(Integer id) {
|
||||
return bankService.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Page<Bank> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<Bank> spec = null;
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
// PagedModel<Bank> pagedModel = new PagedModel<>();
|
||||
return bankService.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public Bank save(Bank bank) {
|
||||
return bankService.save(bank);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
public void delete(Integer id) {
|
||||
Bank bank = bankService.findById(id);
|
||||
bankService.delete(bank);
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/employee")
|
||||
public class EmployyeController {
|
||||
public class EmployeeController {
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@@ -29,9 +30,9 @@ public class EmployyeController {
|
||||
@RequestMapping("/list")
|
||||
public Page<Employee> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0") int pageNumber,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
Specification<Employee> spec = (root, query, cb) -> cb.conjunction();
|
||||
Specification<Employee> spec = null;
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return employeeService.findAll(spec, pageable);
|
||||
@@ -51,7 +51,8 @@ public class EmployeeService implements IEntityService<Employee> {
|
||||
// 从员工仓库中根据ID查找员工信息,如果不存在则返回null
|
||||
return employeeRepository.findById(id).orElse(null);
|
||||
}
|
||||
@Cacheable(key = "'ac-'+#p0")
|
||||
|
||||
@Cacheable(key = "'ac-'+#p0")
|
||||
public Employee findByAccount(String username) {
|
||||
return employeeRepository.findByAccount(username).orElse(null);
|
||||
}
|
||||
@@ -86,7 +87,7 @@ public class EmployeeService implements IEntityService<Employee> {
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'ac-'+#p0.account"),
|
||||
@CacheEvict(key = "'ac-'+#p0.account"),
|
||||
@CacheEvict(key = "'name-'+#p0.name"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
})
|
||||
@@ -155,4 +156,6 @@ public class EmployeeService implements IEntityService<Employee> {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user