|
@@ -1,12 +1,8 @@
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
@@ -14,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.service.core.service.OrgConfigService;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -27,20 +24,13 @@ import io.swagger.annotations.ApiOperation;
|
|
public class OrgConfigApi {
|
|
public class OrgConfigApi {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ private OrgConfigService orgConfigService;
|
|
|
|
|
|
@ApiOperation(value = "查询机构配置", notes = "查询")
|
|
@ApiOperation(value = "查询机构配置", notes = "查询")
|
|
@GetMapping("/{id}/{key}")
|
|
@GetMapping("/{id}/{key}")
|
|
public ResponseEntity<?> getOrgConfig(@PathVariable Long id, @PathVariable String key) {
|
|
public ResponseEntity<?> getOrgConfig(@PathVariable Long id, @PathVariable String key) {
|
|
|
|
|
|
- List<Map<String, Object>> dataList = jdbcTemplate
|
|
|
|
- .queryForList(" SELECT t.value from ecs_core_org_config t where t.org_id=? and t.key=?", id, key);
|
|
|
|
-
|
|
|
|
- String value = "";
|
|
|
|
- if (1 == dataList.size()) {
|
|
|
|
- Map<String, Object> map = dataList.get(0);
|
|
|
|
- value = (String) map.get("value");
|
|
|
|
- }
|
|
|
|
|
|
+ String value = orgConfigService.getOrgConfig(id, key);
|
|
|
|
|
|
return new ResponseEntity<>(value, HttpStatus.OK);
|
|
return new ResponseEntity<>(value, HttpStatus.OK);
|
|
}
|
|
}
|
|
@@ -49,9 +39,7 @@ public class OrgConfigApi {
|
|
@PutMapping("/{id}/{key}")
|
|
@PutMapping("/{id}/{key}")
|
|
public ResponseEntity<?> setOrgConfig(@PathVariable Long id, @PathVariable String key, @RequestBody String value) {
|
|
public ResponseEntity<?> setOrgConfig(@PathVariable Long id, @PathVariable String key, @RequestBody String value) {
|
|
|
|
|
|
- jdbcTemplate.update(
|
|
|
|
- "INSERT INTO ecs_core_org_config (org_id,key,value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE value=?", id,
|
|
|
|
- key, value, value);
|
|
|
|
|
|
+ orgConfigService.setOrgConfig(id, key, value);
|
|
|
|
|
|
return new ResponseEntity<>("", HttpStatus.OK);
|
|
return new ResponseEntity<>("", HttpStatus.OK);
|
|
}
|
|
}
|