Skip to content

Commit

Permalink
Command类overwrite父类的add,update,delete方法 (#319)
Browse files Browse the repository at this point in the history
* Command类overwrite父类的add,update,delete方法
* 请求url转义
  • Loading branch information
iamazy committed Dec 9, 2020
1 parent 83d0a5e commit 55fb6a3
Show file tree
Hide file tree
Showing 31 changed files with 260 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public Topic createTopic(Topic topic, List<Broker> select, Identity operator) th
//计算总数
topic.setPartitions(topic.getPartitions() * select.size());
topic.setBrokers(select);
topicService.addWithBrokerGroup(topic, topic.getBrokerGroup(), topic.getBrokers(), operator);
topicService.addWithBrokerGroup(topic);
return topicService.findById(topic.getId()); }

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.joyqueue.nsr;

import org.joyqueue.domain.Replica;
import org.joyqueue.model.domain.TopicPartitionGroup;

import java.util.List;
Expand All @@ -27,4 +28,6 @@ public interface PartitionGroupServerService extends NsrService<TopicPartitionGr
List<TopicPartitionGroup> findByTopic(String topic,String namespace);

TopicPartitionGroup findByTopicAndGroup(String namespace, String topic, Integer groupNo);

List<Replica> getByBrokerId(Integer brokerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import com.alibaba.fastjson.JSON;
import org.joyqueue.convert.NsrPartitionGroupConverter;
import org.joyqueue.domain.PartitionGroup;
import org.joyqueue.domain.Replica;
import org.joyqueue.model.domain.OperLog;
import org.joyqueue.model.domain.TopicPartitionGroup;
import org.joyqueue.nsr.NameServerBase;
import org.joyqueue.nsr.PartitionGroupServerService;
import org.joyqueue.nsr.model.PartitionGroupQuery;
import org.joyqueue.nsr.model.ReplicaQuery;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -39,6 +41,8 @@ public class PartitionGroupServerServiceImpl extends NameServerBase implements P
public static final String GETBYID_PARTITIONGROUP="/partitiongroup/getById";
public static final String GETBYTOPIC_PARTITIONGROUP="/partitiongroup/getByTopic";
public static final String GETBYTOPICANDGROUP_PARTITIONGROUP="/partitiongroup/getByTopicAndGroup";
public static final String POSTBY_REPLICA_BROKER = "/replica/getByBroker";

private NsrPartitionGroupConverter nsrPartitionGroupConverter = new NsrPartitionGroupConverter();

@Override
Expand Down Expand Up @@ -91,4 +95,13 @@ public List<TopicPartitionGroup> findByTopic(String topic, String namespace) {
List<PartitionGroup> partitionGroups = JSON.parseArray(result, PartitionGroup.class);
return partitionGroups.stream().map(partitionGroup -> nsrPartitionGroupConverter.revert(partitionGroup)).collect(Collectors.toList());
}

@Override
public List<Replica> getByBrokerId(Integer brokerId) {
ReplicaQuery replicaQuery = new ReplicaQuery();
replicaQuery.setBrokerId(brokerId);
String result = post(POSTBY_REPLICA_BROKER, replicaQuery);
List<Replica> replicas = JSON.parseArray(result, Replica.class);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import org.joyqueue.model.PageResult;
import org.joyqueue.model.QPageQuery;
import org.joyqueue.model.domain.AppUnsubscribedTopic;
import org.joyqueue.model.domain.Broker;
import org.joyqueue.model.domain.BrokerGroup;
import org.joyqueue.model.domain.Identity;
import org.joyqueue.model.domain.Topic;
import org.joyqueue.model.query.QTopic;
import org.joyqueue.nsr.NsrService;
Expand All @@ -38,11 +35,8 @@ public interface TopicService extends NsrService<Topic ,String> {
/**
* 保存:带分组和Broker信息
* @param topic
* @param brokerGroup
* @param brokers
* @param operator 操作人
*/
void addWithBrokerGroup(Topic topic, BrokerGroup brokerGroup, List<Broker> brokers, Identity operator);
void addWithBrokerGroup(Topic topic);

/**
* 查询未订阅的topics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public int delete(final Application app) {
return super.delete(app);
}

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public int update(Application model) {
return super.update(model);
}

@Override
public Application findByCode(final String code) {
if (code == null || code.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import org.joyqueue.model.QPageQuery;
import org.joyqueue.model.domain.AppUnsubscribedTopic;
import org.joyqueue.model.domain.Broker;
import org.joyqueue.model.domain.BrokerGroup;
import org.joyqueue.model.domain.Consumer;
import org.joyqueue.model.domain.Identity;
import org.joyqueue.model.domain.Namespace;
import org.joyqueue.model.domain.PartitionGroupReplica;
import org.joyqueue.model.domain.Topic;
Expand Down Expand Up @@ -74,13 +72,16 @@ public class TopicServiceImpl implements TopicService {

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void addWithBrokerGroup(Topic topic, BrokerGroup brokerGroup, List<Broker> brokers, Identity operator) {
public void addWithBrokerGroup(Topic topic) {
Namespace namespace = topic.getNamespace();
Topic oldTopic = findByCode(namespace == null?null:namespace.getCode(),topic.getCode());
if (oldTopic != null) {
throw new DuplicateKeyException("topic aleady exist");
}

List<Broker> brokers = topic.getBrokers();
if (brokers == null) {
brokers = new ArrayList<>();
}
if (EnvironmentUtil.isTest()) {
topic.setElectType(TopicPartitionGroup.ElectType.fix.type());
brokers = Lists.newArrayList(brokers.get(0));
Expand Down
2 changes: 1 addition & 1 deletion joyqueue-console/joyqueue-portal/src/mixins/crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default {
if (typeof (_this.beforeDel) === 'function') {
_this.beforeDel(item)
}
apiRequest.delete(_this.urlOrigin.del + '/' + item.id).then((data) => {
apiRequest.delete(_this.urlOrigin.del + '/' + encodeURIComponent(item.id)).then((data) => {
if (data.code !== this.$store.getters.successCode) {
this.$Dialog.error({
content: '删除失败'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export default {
title: '提示',
content: '确定要取消订阅吗?'
}).then(() => {
apiRequest.delete(_this.urls.del + '/' + item.id).then((data) => {
apiRequest.delete(_this.urls.del + '/' + encodeURIComponent(item.id)).then((data) => {
if (data.code !== this.$store.getters.successCode) {
this.$Dialog.error({
content: '取消订阅失败'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ export default {
type: 'number',
trigger: 'change',
min: 1,
max: 1000,
max: 100,
adminMax: 30000,
hint: '批量大小范围为1~1000',
hint: '批量大小范围为1~100',
adminHint: '批量大小范围为1~30000',
required: false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export default {
title: '提示',
content: '确定要取消订阅吗?'
}).then(() => {
apiRequest.delete(_this.urls.del + '/' + item.id).then((data) => {
apiRequest.delete(_this.urls.del + '/' + encodeURIComponent(item.id)).then((data) => {
if (data.code !== this.$store.getters.successCode) {
this.$Dialog.error({
content: '取消订阅失败'
Expand Down
18 changes: 11 additions & 7 deletions joyqueue-console/joyqueue-portal/src/views/topic/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ export default {
for (let policy in this.policies) {
if (this.policies.hasOwnProperty(policy)) {
if (this.policies[policy].key === 'storeMaxTime') {
this.topic.policy[this.policies[policy].key] = this.policies[policy].value * (1000 * 60 * 60)
if (this.policies[policy].value) {
this.topic.policy[this.policies[policy].key] = this.policies[policy].value * (1000 * 60 * 60)
} else {
this.topic.policy[this.policies[policy].key] = undefined
}
} else {
this.topic.policy[this.policies[policy].key] = this.policies[policy].value
}
Expand All @@ -256,9 +260,7 @@ export default {
apiRequest.put(this.urlOrigin.edit + '/' + encodeURIComponent(this.topic.id), {}, this.topic).then((data) => {
this.policyDialog.visible = false
if (data.code === 200) {
this.$Dialog.success({
content: '更新成功'
})
this.$Message.info('更新成功')
}
this.getList()
this.policies = undefined
Expand All @@ -277,11 +279,13 @@ export default {
this.topic.policy = {}
}
this.policies.push({
key: '存储最长时间',
value: item.policy.storeMaxTime / (1000 * 60 * 60)
key: 'storeMaxTime',
txt: '存储最长时间(h)',
value: item.policy.storeMaxTime !== undefined ? item.policy.storeMaxTime / (1000 * 60 * 60) : undefined
})
this.policies.push({
key: '保留未消费数据',
key: 'storeCleanKeepUnconsumed',
txt: '保留未消费数据',
value: item.policy.storeCleanKeepUnconsumed
})
for (let policy in this.policy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@

<!-- producerConfig -->
<route inherit="post"
path="/v1/producer/config/addOrUpdate" handlers="addOrUpdateProducerConfig render"
path="/v1/producer/config/addOrUpdate" handlers="producer#configAddOrUpdate render"
errors="error"/>

<!-- consumer post-id -->
Expand Down Expand Up @@ -487,7 +487,7 @@
errors="error"/>
<!--同步操作 -->
<route inherit="post"
path="/v1/sync/application" handlers="syncApp render"
path="/v1/sync/application" handlers="syncApplication#syncApp render"
errors="error"/>
<route inherit="post"
path="/v1/sync/user" handlers="syncUser render"
Expand Down

This file was deleted.

0 comments on commit 55fb6a3

Please sign in to comment.