|
@@ -0,0 +1,59 @@
|
|
|
|
+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.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 机构配置API
|
|
|
|
+ *
|
|
|
|
+ * @author wang wei
|
|
|
|
+ * @date 2018年4月9日
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("${app.api.root}/orgConfig")
|
|
|
|
+public class OrgConfigApi {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询机构配置", notes = "查询")
|
|
|
|
+ @GetMapping("/{id}/{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");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new ResponseEntity<>(value, HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "更新机构配置", notes = "更新")
|
|
|
|
+ @PutMapping("/{id}/{key}")
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ return new ResponseEntity<>("", HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|