我有这个弹簧控制器:
@RestController
@RequestMapping("/communications")
class CommunicationController(private val service: CommunicationService) {
@ApiOperation(
produces = APPLICATION_JSON_VALUE,
consumes = APPLICATION_JSON_VALUE
)
@GetMapping(
consumes = [APPLICATION_JSON_VALUE],
produces = [APPLICATION_JSON_VALUE]
)
fun findAll(
criterias: CommunicationCriterias,
page: Pageable
): List<CommunicationDTO> = service.findCommunications(criterias, page)
}
Run Code Online (Sandbox Code Playgroud)
当我通过swagger-ui(springfox)界面测试此端点时,出现415: content type invalid错误.似乎content-type: application/json没有在标题中设置.
缺什么 ?
我有一个使用非角度登录页面的角度应用程序。仅当用户登录时,Angular应用才会加载。
我已经端到端测试我的无棱角登录与页面量角器和茉莉按照这个帖子,运行位于我的测试代码e2e/login.spec.js和使用browser.ignoreSynchronization = true,以防止没有角加载。
我现在想对我的角度应用程序进行一些测试,但是不能,因为后端重定向到登录页面。这意味着我需要为每个角度视图测试记录一个testingUser。如果进行大量测试,效果不是很好。
我知道有一种解决方案,可以通过模拟后端API来解决登录页面倾斜的问题(请参阅同一篇文章),但无法使用我现有的API 。
有没有办法让用户保持登录状态?它是什么?还是其他解决方法?我是否需要在angular应用程序内实现开发人员登录页面以进行测试?
我有这张桌子:
create table expert_country (
expert_id varchar(36) not null,
country_id varchar(36) not null,
main boolean not null default false,
primary key (expert_id, country_id),
constraint foreign key (expert_id) references expert (id),
constraint foreign key (country_id) references country (id),
-- constraint i'm looking for
);
Run Code Online (Sandbox Code Playgroud)
但是我无法弄清楚每个国家只有一个主要专家所需要增加的限制。
我试过了constraint unique (country_id, true),constraint unique (*, country_id, true)但是它不是有效的sql。有任何想法吗?
我过去常常在我的春天里验证我的豆子@RestController:
@PostMapping("/documents")
@ResponseStatus(HttpStatus.CREATED)
fun create(@Valid @RequestBody document: DocumentCreate) {
return documentService.create(document)
}
Run Code Online (Sandbox Code Playgroud)
即使它看起来很愚蠢,我现在想根据DocumentCreate布尔属性验证我的bean,如:
@PostMapping("/documents")
@ResponseStatus(HttpStatus.CREATED)
fun create(@RequestBody document: DocumentCreate) {
return when {
document.needValidation -> documentService.createWithValidation(document),
else -> documentService.createWithoutValidation(document)
}
}
Run Code Online (Sandbox Code Playgroud)
我试图将@Valid注释移动到文档@Service类,但它不会触发验证.我怎样才能做到这一点?可能吗?
spring spring-mvc hibernate-validator kotlin spring-validator
当离开表单状态已更改的页面时,我使用createBrowserHistorywith来处理确认用户验证:getUserConfirmation
import { createBrowserHistory } from 'history';
import store from './store';
import { displayPrompt } from './ui/navigation-prompt/navigationPromptDucks';
export default createBrowserHistory({
getUserConfirmation(message, callback) {
store.dispatch(displayPrompt(message, callback));
},
});
Run Code Online (Sandbox Code Playgroud)
它运作良好:当我开始编辑表单并尝试离开当前页面时,我收到了确认提示。
现在,假设我有一个删除按钮来删除表单的资源,当删除成功时,我得到了到资源列表页面的历史记录重定向。
我的问题是:如果我开始编辑表单并最终决定点击删除按钮来删除资源而不是编辑它,历史记录会触发表单已更改,并将在历史记录重定向之前显示确认提示。
我有两个选择。首先,我可以放回初始表单状态以避免出现提示。其次,还有另一种方法可以防止在某些情况下出现提示。
最好的解决方案是什么?如果是第二个,你能告诉我该怎么做吗?
方案一(首选)
在历史重定向之前重置表单:
const mapDispatchToProps = (dispatch, { user, history, t }) => ({
deleteUser: () => new Promise((resolve, reject) => {
dispatch(newAlertDialog(
t('confirmDeleteUser', { user: user.name }),
t('confirmDeleteTitle'),
() => dispatch(requestDeleteUser(user.id, resolve, reject)),
t('delete'),
))
}).then(() => {
// reset form to avoid prompt user …Run Code Online (Sandbox Code Playgroud) 我有这个简单的状态机配置:
@Configuration
@EnableStateMachine
public class SimpleStateMachineConfiguration extends StateMachineConfigurerAdapter<State, Boolean> {
@Override
public void configure(StateMachineStateConfigurer<State, Boolean> states) throws Exception {
states.withStates()
.initial(State.INITIAL)
.states(EnumSet.allOf(State.class));
}
@Override
public void configure(StateMachineTransitionConfigurer<State, Boolean> transitions) throws Exception {
transitions
.withExternal()
.source(State.INITIAL)
.target(State.HAS_CUSTOMER_NUMBER)
.event(true)
.action(retrieveCustomerAction())
// here I'd like to retrieve the customer from this action, like:
// stateMachine.start();
// stateMachine.sendEvent(true);
// stateMachine.retrieveCustomerFromAction();
.and()
.withExternal()
.source(State.INITIAL)
.target(State.NO_CUSTOMER_NUMBER)
.event(false)
.action(createCustomerAction());
// here I'd like to send the customer instance to create, like:
// stateMachine.start();
// stateMachine.sendEvent(false);
// stateMachine.sendCustomerToAction(Customer …Run Code Online (Sandbox Code Playgroud) 有没有办法copy在条件状态未验证的情况下使用Kotlin 函数并使用原始对象值属性?或者类似的功能可以做到这一点?
例子:
data class UserEntity(
id = String,
email = String,
firstName = String,
lastName = String
)
data class UserUpdate(
firstName = String?,
lastName = String?
)
@Service
class UserService(userRepository: UserRepository) {
fun update(id: String, dto: UserUpdate) = userRepository.save(
userRepository.findById(id).copy(
// *it* is not available as the initial object the
// copy function is called from.
firstName = dto.firstName ?: it.firstName,
// I'd like something like:
lastName = dto.lastName ?: keepTheOriginalLastNameProperty
)
)
}
Run Code Online (Sandbox Code Playgroud) 我想将 a 转换(使用 Java 8 流),Map<Long, List<MyClass>>其中Map<Long, Set<Long>>代表Set<Long>每个.idMyClassList
我努力了:
myFirstMap.entrySet().stream()
.map(e -> e.getValue().stream()
.map(MyClass::getId)
.collect(Collectors.toSet()))
Run Code Online (Sandbox Code Playgroud)
但我不知道如何得到结果。
我想有延伸时,它的焦点一个文本输入和撑扩展时失去焦点.是否有可能只用css这样做?
我目前有:
.expend-input:focus {
height:200px;
width:100%;
}
Run Code Online (Sandbox Code Playgroud)
kotlin ×3
spring ×3
java ×2
angularjs ×1
copy ×1
css ×1
history.js ×1
input ×1
java-8 ×1
java-stream ×1
mysql ×1
protractor ×1
reactjs ×1
spring-boot ×1
spring-mvc ×1
springfox ×1
sql ×1
swagger-ui ×1