update document

This commit is contained in:
xuxueli 2019-09-26 20:29:48 +08:00
parent 6716c767ff
commit d127f26264
3 changed files with 9 additions and 49 deletions

View File

@ -16,10 +16,6 @@ public interface XxlJobGroupDao {
public List<XxlJobGroup> findByAddressType(@Param("addressType") int addressType); 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 save(XxlJobGroup xxlJobGroup);
public int update(XxlJobGroup xxlJobGroup); public int update(XxlJobGroup xxlJobGroup);

View File

@ -1,6 +1,5 @@
package com.xxl.job.admin.service.impl; 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.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog; import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.MessageFormat; import java.text.MessageFormat;
@ -132,6 +129,9 @@ public class AdminBizImpl implements AdminBiz {
int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); int ret = xxlJobRegistryDao.registryUpdate(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
if (ret < 1) { if (ret < 1) {
xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); xxlJobRegistryDao.registrySave(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
// fresh
freshGroupRegistryInfo(registryParam);
} }
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }
@ -139,39 +139,16 @@ public class AdminBizImpl implements AdminBiz {
@Override @Override
public ReturnT<String> registryRemove(RegistryParam registryParam) { public ReturnT<String> registryRemove(RegistryParam registryParam) {
int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue()); int ret = xxlJobRegistryDao.registryDelete(registryParam.getRegistGroup(), registryParam.getRegistryKey(), registryParam.getRegistryValue());
if (ret == 1) { if (ret > 0) {
List<XxlJobGroup> autoRegisterGroups = xxlJobGroupDao.findAutoRegisterGroupByAppName(registryParam.getRegistryKey());
removeRegisterFromGroups(autoRegisterGroups, registryParam.getRegistryValue()); // fresh
freshGroupRegistryInfo(registryParam);
} }
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }
private void removeRegisterFromGroups(List<XxlJobGroup> groups, String address) { private void freshGroupRegistryInfo(RegistryParam registryParam){
if (StringUtils.isEmpty(address)) { // Under consideration, prevent affecting core tables
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);
}
}
} }
} }

View File

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