update document

master
xuxueli 5 years ago
parent 6716c767ff
commit d127f26264
  1. 4
      xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java
  2. 41
      xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
  3. 13
      xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml

@ -16,10 +16,6 @@ public interface XxlJobGroupDao {
public List<XxlJobGroup> findByAddressType(@Param("addressType") int addressType);
public List<XxlJobGroup> findAutoRegisterGroupByAppName(@Param("appName") String appName);
public int updateAddressListById(@Param("id") int id, @Param("addressList") String addressList);
public int save(XxlJobGroup xxlJobGroup);
public int update(XxlJobGroup xxlJobGroup);

@ -1,6 +1,5 @@
package com.xxl.job.admin.service.impl;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
@ -18,8 +17,6 @@ import com.xxl.job.core.handler.IJobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.text.MessageFormat;
@ -132,6 +129,9 @@ public class AdminBizImpl implements AdminBiz {
int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
if (ret < 1) {
xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
// fresh
freshGroupRegistryInfo(registryParam);
}
return ReturnT.SUCCESS;
}
@ -139,39 +139,16 @@ public class AdminBizImpl implements AdminBiz {
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
if (ret == 1) {
List<XxlJobGroup> autoRegisterGroups = xxlJobGroupDao.findAutoRegisterGroupByAppName(registryParam.getRegistryKey());
removeRegisterFromGroups(autoRegisterGroups, registryParam.getRegistryValue());
if (ret > 0) {
// fresh
freshGroupRegistryInfo(registryParam);
}
return ReturnT.SUCCESS;
}
private void removeRegisterFromGroups(List<XxlJobGroup> groups, String address) {
if (StringUtils.isEmpty(address)) {
return;
}
if (CollectionUtils.isEmpty(groups)) {
return;
}
for (XxlJobGroup group : groups) {
List<String> addressList = group.getRegistryList();
if (addressList == null) {
continue;
}
if (!addressList.contains(address)) {
continue;
}
addressList.remove(address);
String newAddressListStr = StringUtils.collectionToCommaDelimitedString(addressList);
String oldAddressListStr = group.getAddressList();
int update = xxlJobGroupDao.updateAddressListById(group.getId(), newAddressListStr);
if (logger.isDebugEnabled()) {
logger.debug("update group name [{}] title [{}] old address list [{}] new address list [{}] update result [{}]",
group.getAppName(), group.getTitle(), oldAddressListStr, newAddressListStr, update);
}
}
private void freshGroupRegistryInfo(RegistryParam registryParam){
// Under consideration, prevent affecting core tables
}
}

@ -27,13 +27,6 @@
ORDER BY t.order ASC
</select>
<select id="findAutoRegisterGroupByAppName" resultMap="XxlJobGroup">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_group AS t
WHERE `app_name` = #{appName}
AND `address_type` = 0
</select>
<select id="findByAddressType" parameterType="java.lang.Integer" resultMap="XxlJobGroup">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_group AS t
@ -56,12 +49,6 @@
WHERE id = #{id}
</update>
<update id="updateAddressListById">
UPDATE xxl_job_group
SET `address_list` = #{addressList}
WHERE id = #{id}
</update>
<delete id="remove" parameterType="java.lang.Integer" >
DELETE FROM xxl_job_group
WHERE id = #{id}

Loading…
Cancel
Save