fix(firstleg): restore sailing channel duplicate lookup

This commit is contained in:
2026-09-27 19:56:23 +08:00
parent 48de46739c
commit 69f2a18a44
3 changed files with 38 additions and 2 deletions
@@ -18,7 +18,7 @@ public interface SailingChannelMapper extends BaseMapper<SailingChannelEntity> {
AND (#{query.status} IS NULL OR status=#{query.status})
ORDER BY status ASC,channel_name ASC,id ASC</script>
""")
List<SailingChannelEntity> selectList(@Param("query") ChannelQuery query);
List<SailingChannelEntity> selectChannels(@Param("query") ChannelQuery query);
@Update("""
UPDATE fl_sailing_channel SET channel_code=#{value.channelCode},channel_name=#{value.channelName},
@@ -37,7 +37,7 @@ public class SailingCalendarRepository {
@Resource private SailingFactsRepository facts;
@Resource private OceanBookingRepository oceanBookings;
public List<SailingChannelEntity> channels(ChannelQuery query) { return channels.selectList(query); }
public List<SailingChannelEntity> channels(ChannelQuery query) { return channels.selectChannels(query); }
public SailingChannelEntity channel(long id) { return channels.selectById(id); }
public SailingChannelEntity channelByCode(String code) {
return channels.selectOne(new LambdaQueryWrapper<SailingChannelEntity>()
@@ -0,0 +1,36 @@
package com.baiyue.firstleg.sailingcalendar.mapper;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baiyue.firstleg.sailingcalendar.entity.SailingChannelEntity;
import org.apache.ibatis.binding.MapperMethod;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
import org.junit.jupiter.api.Test;
import java.sql.PreparedStatement;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
class SailingChannelMapperTest {
@Test
void inheritedSelectListStillBindsWrapperForChannelCodeLookup() throws Exception {
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.addMapper(SailingChannelMapper.class);
MappedStatement statement = configuration.getMappedStatement(SailingChannelMapper.class.getName() + ".selectList");
MapperMethod.ParamMap<Object> parameters = new MapperMethod.ParamMap<>();
parameters.put(Constants.WRAPPER, new LambdaQueryWrapper<SailingChannelEntity>()
.eq(SailingChannelEntity::getChannelCode, "MATSON"));
BoundSql sql = statement.getBoundSql(parameters);
PreparedStatement preparedStatement = mock(PreparedStatement.class);
new DefaultParameterHandler(statement, parameters, sql).setParameters(preparedStatement);
assertThat(sql.getSql()).contains("channel_code = ?");
verify(preparedStatement).setString(1, "MATSON");
}
}