mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
modify
This commit is contained in:
@@ -2,10 +2,7 @@ package com.alibaba.otter.canal.admin.controller;
|
|||||||
|
|
||||||
import com.alibaba.otter.canal.admin.model.BaseModel;
|
import com.alibaba.otter.canal.admin.model.BaseModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.alibaba.otter.canal.admin.model.CanalConfig;
|
import com.alibaba.otter.canal.admin.model.CanalConfig;
|
||||||
import com.alibaba.otter.canal.admin.service.CanalConfigService;
|
import com.alibaba.otter.canal.admin.service.CanalConfigService;
|
||||||
@@ -21,4 +18,10 @@ public class CanalConfigController {
|
|||||||
public BaseModel<CanalConfig> canalConfig(@PathVariable String env) {
|
public BaseModel<CanalConfig> canalConfig(@PathVariable String env) {
|
||||||
return BaseModel.getInstance(canalConfigService.getCanalConfig());
|
return BaseModel.getInstance(canalConfigService.getCanalConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/config", method = RequestMethod.PUT)
|
||||||
|
public BaseModel<String> updateConfig(@RequestBody CanalConfig canalConfig, @PathVariable String env) {
|
||||||
|
canalConfigService.updateContent(canalConfig);
|
||||||
|
return BaseModel.getInstance("success");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,6 @@ public interface CanalConfigService {
|
|||||||
CanalConfig getCanalConfig();
|
CanalConfig getCanalConfig();
|
||||||
|
|
||||||
CanalConfig getAdapterConfig();
|
CanalConfig getAdapterConfig();
|
||||||
|
|
||||||
|
void updateContent(CanalConfig canalConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import com.alibaba.otter.canal.admin.dao.CanalConfigDao;
|
import com.alibaba.otter.canal.admin.dao.CanalConfigDao;
|
||||||
import com.alibaba.otter.canal.admin.model.CanalConfig;
|
import com.alibaba.otter.canal.admin.model.CanalConfig;
|
||||||
import com.alibaba.otter.canal.admin.service.CanalConfigService;
|
import com.alibaba.otter.canal.admin.service.CanalConfigService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CanalConfigServiceImpl implements CanalConfigService {
|
public class CanalConfigServiceImpl implements CanalConfigService {
|
||||||
@@ -22,6 +23,6 @@ public class CanalConfigServiceImpl implements CanalConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateContent(CanalConfig canalConfig) {
|
public void updateContent(CanalConfig canalConfig) {
|
||||||
canalConfigDao.findById(canalConfig.getId());
|
canalConfigDao.updateContent(canalConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,3 +6,11 @@ export function getCanalConfig() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateCanalConfig(data) {
|
||||||
|
return request({
|
||||||
|
url: '/canal/config',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
<el-form ref="form" :model="form">
|
<el-form ref="form" :model="form">
|
||||||
<div style="padding-left: 10px;padding-top: 20px;">
|
<div style="padding-left: 10px;padding-top: 20px;">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
canal.properties
|
{{ form.name }}
|
||||||
<el-button type="primary" @click="onSubmit">修改</el-button>
|
<el-button type="primary" @click="onSubmit">修改</el-button>
|
||||||
<el-button @click="onCancel">取消</el-button>
|
<el-button @click="onCancel">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
<editor v-model="form.content" lang="properties" theme="chrome" width="100%" :height="800" @init="editorInit" />
|
<editor v-model="form.content" lang="properties" theme="chrome" width="100%" :height="800" @init="editorInit" />
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getCanalConfig } from '@/api/canalConfig'
|
import { getCanalConfig, updateCanalConfig } from '@/api/canalConfig'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -23,6 +23,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
|
id: null,
|
||||||
name: '',
|
name: '',
|
||||||
content: ''
|
content: ''
|
||||||
}
|
}
|
||||||
@@ -44,17 +45,40 @@ export default {
|
|||||||
},
|
},
|
||||||
loadCanalConfig() {
|
loadCanalConfig() {
|
||||||
getCanalConfig().then(response => {
|
getCanalConfig().then(response => {
|
||||||
this.form.content = response.data.content
|
const data = response.data
|
||||||
|
this.form.id = data.id
|
||||||
|
this.form.name = data.name
|
||||||
|
this.form.content = data.content
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$message('submit!')
|
this.$confirm(
|
||||||
|
'修改Canal主配置可能会导致Server重启,是否继续?',
|
||||||
|
'确定修改',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
).then(() => {
|
||||||
|
updateCanalConfig(this.form).then(response => {
|
||||||
|
if (response.data === 'success') {
|
||||||
|
this.$message({
|
||||||
|
message: '修改成功',
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
|
this.loadCanalConfig()
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
message: '修改失败',
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onCancel() {
|
onCancel() {
|
||||||
this.$message({
|
this.loadCanalConfig()
|
||||||
message: 'cancel!',
|
|
||||||
type: 'warning'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user