增加系统配置
This commit is contained in:
parent
91a678e5ad
commit
2add95d112
|
|
@ -0,0 +1,36 @@
|
|||
package org.jetlinks.community.auth.entity;
|
||||
|
||||
import lombok.*;
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec;
|
||||
import org.hswebframework.web.api.crud.entity.GenericEntity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Table;
|
||||
import java.sql.JDBCType;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "s_system_conf")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SystemConfigEntity extends GenericEntity<String> {
|
||||
|
||||
/**
|
||||
* 前端配置
|
||||
*/
|
||||
@Column
|
||||
@ColumnType(jdbcType = JDBCType.CLOB)
|
||||
@JsonCodec
|
||||
private Map<String, Object> frontConfig;
|
||||
|
||||
public static SystemConfigEntity front(String id,Map<String, Object> front){
|
||||
SystemConfigEntity entity=new SystemConfigEntity();
|
||||
entity.setId(id);
|
||||
entity.setFrontConfig(front);
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package org.jetlinks.community.auth.web;
|
||||
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository;
|
||||
import org.hswebframework.web.authorization.annotation.Authorize;
|
||||
import org.hswebframework.web.authorization.annotation.QueryAction;
|
||||
import org.hswebframework.web.authorization.annotation.Resource;
|
||||
import org.hswebframework.web.authorization.annotation.SaveAction;
|
||||
import org.jetlinks.community.auth.entity.SystemConfigEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("/system/config")
|
||||
@RestController
|
||||
@Resource(id = "system-config", name = "系统配置")
|
||||
public class SystemConfigController {
|
||||
|
||||
private final ReactiveRepository<SystemConfigEntity, String> repository;
|
||||
|
||||
public SystemConfigController(ReactiveRepository<SystemConfigEntity, String> repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@GetMapping("/front")
|
||||
@QueryAction
|
||||
@Authorize(ignore = true)
|
||||
public Mono<Map<String, Object>> getFrontConfig() {
|
||||
return repository.findById("default")
|
||||
.map(SystemConfigEntity::getFrontConfig)
|
||||
.defaultIfEmpty(Collections.emptyMap());
|
||||
}
|
||||
|
||||
@PostMapping("/front")
|
||||
@QueryAction
|
||||
@SaveAction
|
||||
public Mono<Void> saveFrontConfig(@RequestBody Mono<Map<String, Object>> config) {
|
||||
return config
|
||||
.map(front -> SystemConfigEntity.front("default", front))
|
||||
.as(repository::save)
|
||||
.then();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue