Commit dd10969f by zhiwj

同步修改

parent 3e27feae
......@@ -66,4 +66,6 @@ public interface TabAppletServiceConfigMapper {
TabAppletServiceConfig getAppByAppId(@Param("enterpriseId") Integer enterpriseId, @Param("appId") String appId);
void updateTime(@Param("appId") String appId, @Param("type") int type, @Param("updateTime") Date date);
void delByConfigIdList(@Param("ids") List<Long> configIdList, @Param("enterpriseId") Integer enterpriseId);
}
\ No newline at end of file
......@@ -16,8 +16,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
......@@ -48,45 +50,49 @@ public class AppletServiceConfigServiceImpl implements AppletServiceConfigServic
@Override
public void syncApplet(List<AppletsConfigSimpleOutputDTO> responseResult, Integer enterpriseId) {
if (CollectionUtils.isNotEmpty(responseResult)) {
List<TabAppletServiceConfig> configList = responseResult.stream()
.filter(e -> tabAppletServiceConfigMapper.getAppByAppId(enterpriseId, e.getAppId()) == null)
.map(e -> {
TabAppletServiceConfig appletServiceConfig = new TabAppletServiceConfig();
appletServiceConfig.setEnterpriseId(enterpriseId);
appletServiceConfig.setAppId(e.getAppId());
appletServiceConfig.setName(e.getAppletConfigName());
appletServiceConfig.setType(AppletServiceConfigEnum.APPLET.getCode());
appletServiceConfig.setConfigId(e.getAppletConfigId());
appletServiceConfig.setCreateTime(new Date());
appletServiceConfig.setUpdateTime(new Date());
return appletServiceConfig;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(configList)) {
tabAppletServiceConfigMapper.insertList(configList);
}
// 先删除configId不在入参里的 如果入参是空的 就全部删除
List<Long> configIdList = Optional.ofNullable(responseResult).orElse(Collections.emptyList())
.stream().map(AppletsConfigSimpleOutputDTO::getAppletConfigId).collect(Collectors.toList());
tabAppletServiceConfigMapper.delByConfigIdList(configIdList, enterpriseId);
List<TabAppletServiceConfig> configList = Optional.ofNullable(responseResult).orElse(Collections.emptyList()).stream()
.map(e -> {
TabAppletServiceConfig appletServiceConfig = new TabAppletServiceConfig();
appletServiceConfig.setEnterpriseId(enterpriseId);
appletServiceConfig.setAppId(e.getAppId());
appletServiceConfig.setName(e.getAppletConfigName());
appletServiceConfig.setType(AppletServiceConfigEnum.APPLET.getCode());
appletServiceConfig.setConfigId(e.getAppletConfigId());
appletServiceConfig.setCreateTime(new Date());
appletServiceConfig.setUpdateTime(new Date());
return appletServiceConfig;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(configList)) {
tabAppletServiceConfigMapper.insertList(configList);
}
}
@Override
public void syncServiceConfig(List<ServiceConfigSimpleOutputDTO> responseResult, Integer enterpriseId) {
if (CollectionUtils.isNotEmpty(responseResult)) {
List<TabAppletServiceConfig> configList = responseResult.stream()
.filter(e -> tabAppletServiceConfigMapper.getAppByAppId(enterpriseId, e.getAppId()) == null)
.map(e -> {
TabAppletServiceConfig appletServiceConfig = new TabAppletServiceConfig();
appletServiceConfig.setEnterpriseId(enterpriseId);
appletServiceConfig.setAppId(e.getAppId());
appletServiceConfig.setName(e.getServiceConfigName());
appletServiceConfig.setType(AppletServiceConfigEnum.SERVICE_CONFIG.getCode());
appletServiceConfig.setConfigId(e.getServiceConfigId());
appletServiceConfig.setCreateTime(new Date());
appletServiceConfig.setUpdateTime(new Date());
return appletServiceConfig;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(configList)) {
tabAppletServiceConfigMapper.insertList(configList);
}
List<Long> configIdList = Optional.ofNullable(responseResult).orElse(Collections.emptyList())
.stream().map(ServiceConfigSimpleOutputDTO::getServiceConfigId).collect(Collectors.toList());
tabAppletServiceConfigMapper.delByConfigIdList(configIdList, enterpriseId);
List<TabAppletServiceConfig> configList = Optional.ofNullable(responseResult).orElse(Collections.emptyList()).stream()
// .filter(e -> tabAppletServiceConfigMapper.getAppByAppId(enterpriseId, e.getAppId()) == null)
.map(e -> {
TabAppletServiceConfig appletServiceConfig = new TabAppletServiceConfig();
appletServiceConfig.setEnterpriseId(enterpriseId);
appletServiceConfig.setAppId(e.getAppId());
appletServiceConfig.setName(e.getServiceConfigName());
appletServiceConfig.setType(AppletServiceConfigEnum.SERVICE_CONFIG.getCode());
appletServiceConfig.setConfigId(e.getServiceConfigId());
appletServiceConfig.setCreateTime(new Date());
appletServiceConfig.setUpdateTime(new Date());
return appletServiceConfig;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(configList)) {
tabAppletServiceConfigMapper.insertList(configList);
}
}
......
......@@ -157,7 +157,6 @@
#{item.configId,jdbcType=BIGINT}
)
</foreach>
-- ON DUPLICATE KEY UPDATE name = VALUES(name)
</insert>
<select id="list" resultMap="BaseResultMap">
select
......@@ -202,4 +201,14 @@
<update id="updateTime">
update tab_applet_service_config set update_time = #{updateTime} where app_id = #{appId} and type = #{type}
</update>
<!-- delByConfigIdList-->
<update id="delByConfigIdList">
update tab_applet_service_config set status = 1 where enterprise_id = #{enterpriseId}
<if test="null != ids and ids.size > 0">
and config_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment