我正在尝试实现受 IN 子句限制的搜索功能:
我想实现带有过滤器限制的搜索实现:
@GetMapping("find")
public Page<MerchantUserDTO> getAllBySpecification(
@And({
@Spec(path = "name", spec = LikeIgnoreCase.class),
@Spec(path = "login", spec = LikeIgnoreCase.class),
@Spec(path = "email", spec = LikeIgnoreCase.class),
}) Specification<Users> specification,
@SortDefault(sort = "login", direction = Sort.Direction.DESC) Pageable pageable
) {
return merchantUserService.getAllBySpecification(specification, pageable)
.map(g -> MerchantUserDTO.builder()
.id(g.getId())
.login(g.getLogin())
.build()
);
}
@Override
public Page<Users> getAllBySpecification(Specification<Users> specification, Pageable pageable) {
return dao.findAllByTypeIn(specification, pageable, "MerchantUser");
}
Run Code Online (Sandbox Code Playgroud)
存储库:
@Repository
public interface MerchantUserRepository extends JpaRepository<Users, Integer>, JpaSpecificationExecutor<Users> {
Page<Users> findAllByTypeIn(Pageable page, String... types);
Page<Users> …Run Code Online (Sandbox Code Playgroud) Drone我已经在我的远程主机上设置了Ubuntu 18.04 Linux。为了方便起见,我安装了drone-runner-exec. 我已经成功地将它连接到我的GitHub等。所以现在它工作正常,即它克隆存储库并开始运行我的管道。步骤之一是简单的 bash 脚本,它必须更新存储库中的子文件夹。
steps:
- name: Getting subfolders
commands:
- ./my_script
Run Code Online (Sandbox Code Playgroud)
运行程序执行脚本,但在某些点上失败。搜索后,我发现在用户下执行的脚本我已经安装了Drone. 我在ps aux输出中看到 和docker都drone在root.
所以我的问题 - 如何更改运行程序运行的系统用户?
如果标题不清楚,我很抱歉,让我通过给出示例代码来澄清:
更新配置文件Dto
public class UpdateProfileDto {
@NotEmpty
private String firstName;
@NotEmpty
private String lastName;
@Size(max = 20)
private String currentPassword;
@Size(max = 20)
private String newPassword;
@Size(max = 20)
private String confirmNewPassword;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
编码映射
@Qualifier
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface EncodedMapping {
}
Run Code Online (Sandbox Code Playgroud)
密码编码器映射器
public class PasswordEncoderMapper {
protected final PasswordEncoder passwordEncoder;
public PasswordEncoderMapper(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
@EncodedMapping
public String encode(String value) {
return passwordEncoder.encode(value);
}
}
Run Code Online (Sandbox Code Playgroud)
用户映射器
@Mapper(config = MapperConfig.class, componentModel = "spring", …Run Code Online (Sandbox Code Playgroud) 我想在单独的线程中运行一个方法。因此我尝试使用@Async但它不起作用。打印输出始终引用相同的线程 ID。
我的应用程序.java
@SpringBootApplication
@EnableAsync
@EnableConfigurationProperties(ConfigProperties.class)
public class MyApp {
public static void main(String[] args) throws Exception {
SpringApplication.run(MyApp.class, args);
}
@Bean("threadPoolTaskExecutor")
public TaskExecutor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(20);
executor.setMaxPoolSize(1000);
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setThreadNamePrefix("Async-");
return executor;
}
}
Run Code Online (Sandbox Code Playgroud)
MyService.java
@Slf4j
@Service
public class MyService implements ISichtServiceBroker {
@Inject
public MyService(Helper helper) {
this.helper = helper;
}
@Transactional
public void handle(Message message) {
System.out.println("Execute method synchronously - " + Thread.currentThread().getName());
handleAsync(message);
}
@Async("threadPoolTaskExecutor")
public void handleAsync(Message message) {
System.out.println("Execute method …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 JPA 实体来创建数据库架构。但是 hibernate 没有创建我尝试创建表的指定架构。以下是我的代码
package io.spring.models;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "brands", schema = "production")
public class Brand implements Serializable {
private static final long serialVersionUID = -7234173905789565680L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "brand_id")
private Integer brandId;
@Column(name = "brandName")
private String brandName;
public Integer getBrandId() {
return brandId;
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public String getBrandName() {
return brandName;
} …Run Code Online (Sandbox Code Playgroud) 我有这段验证代码,并且认为它不符合 Kotlin 的精神,
在这段代码中,我与数据类内容网络人员进行了比较:网络人员和工作人员:网络人员
if (networker.name != worker.name && networker.name != null) {
worker.name = networker.name
}
if (networker.lastName != worker.lastName && networker.lastName != null) {
worker.lastName = networker.lastName
}
if (networker.phone != worker.phone && networker.phone != null) {
worker.phone = networker.phone
}
if (networker.email != worker.email && networker.email != null) {
worker.email = networker.email
}
Run Code Online (Sandbox Code Playgroud)
请问如何用更好更优雅的 Kotlin 代码来改进这个
spring-boot ×3
jpa ×2
asynchronous ×1
docker ×1
drone.io ×1
hibernate ×1
jpa-2.0 ×1
jpa-2.1 ×1
kotlin ×1
linux ×1
mapstruct ×1
spring-data ×1
ubuntu-18.04 ×1