updated indexes and collected indexed list APIs according to public server

This commit is contained in:
strawmanbobi
2021-08-13 17:24:49 +08:00
parent f1fa0e2675
commit d4b6a51a23
5 changed files with 103 additions and 56 deletions

10
server/.idea/runConfigurations.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@@ -8,6 +8,7 @@ import net.irext.server.service.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.util.ArrayList;
import java.util.List;
/**
@@ -119,37 +120,41 @@ public class IndexingLogic {
public List<RemoteIndex> listRemoteIndexes(int categoryId, int brandId, String cityCode,
int from, int count, int withParaData) {
List<RemoteIndex> remoteIndexList;
List<RemoteIndex> remoteIndexList = new ArrayList<>();
if (categoryId == Constants.CategoryID.STB.getValue()) {
remoteIndexList = remoteIndexMapper.listRemoteIndexByCity(cityCode, from, count);
} else {
remoteIndexList = remoteIndexMapper.listRemoteIndexByBrand(categoryId, brandId, from, count);
}
if (1 == withParaData) {
List<CollectRemote> collectRemoteList;
return remoteIndexList;
}
if (Constants.CategoryID.STB.getValue() != categoryId) {
collectRemoteList = collectRemoteMapper.selectCollectRemotesByBrand(categoryId, brandId);
} else {
collectRemoteList = collectRemoteMapper.selectCollectRemotesByCity(categoryId, cityCode);
}
public List<RemoteIndex> listCollectedRemoteIndexes(int categoryId, int brandId, String cityCode,
int from, int count) {
List<RemoteIndex> remoteIndexList = new ArrayList<>();
List<CollectRemote> collectRemoteList;
// convert collectRemote to remoteIndex
for (CollectRemote collectRemote : collectRemoteList) {
RemoteIndex remoteIndex = new RemoteIndex();
remoteIndex.setId(collectRemote.getId());
remoteIndex.setCategoryId(categoryId);
remoteIndex.setCategoryName(collectRemote.getCategoryName());
remoteIndex.setBrandId(brandId);
remoteIndex.setBrandName(collectRemote.getBrandName());
remoteIndex.setCityCode(collectRemote.getCityCode());
remoteIndex.setCityName(collectRemote.getCityName());
remoteIndex.setPriority(999);
remoteIndex.setSubCate((byte)Constants.BinaryType.TYPE_PARA_DATA.getValue());
remoteIndex.setStatus((byte) Constants.STATUS_PARA_DATA);
remoteIndexList.add(remoteIndex);
}
if (Constants.CategoryID.STB.getValue() != categoryId) {
collectRemoteList = collectRemoteMapper.selectCollectRemotesByBrand(categoryId, brandId, from, count);
} else {
collectRemoteList = collectRemoteMapper.selectCollectRemotesByCity(categoryId, cityCode, from, count);
}
// convert collectRemote to remoteIndex
for (CollectRemote collectRemote : collectRemoteList) {
RemoteIndex remoteIndex = new RemoteIndex();
remoteIndex.setId(collectRemote.getId());
remoteIndex.setCategoryId(categoryId);
remoteIndex.setCategoryName(collectRemote.getCategoryName());
remoteIndex.setBrandId(brandId);
remoteIndex.setBrandName(collectRemote.getBrandName());
remoteIndex.setCityCode(collectRemote.getCityCode());
remoteIndex.setCityName(collectRemote.getCityName());
remoteIndex.setPriority(999);
remoteIndex.setSubCate((byte)Constants.BinaryType.TYPE_PARA_DATA.getValue());
remoteIndex.setStatus((byte) Constants.STATUS_PARA_DATA);
remoteIndexList.add(remoteIndex);
}
return remoteIndexList;
}

View File

@@ -21,7 +21,7 @@ import java.util.List;
@Mapper
@Controller
public interface BrandMapper {
@Select("SELECT * FROM brand WHERE status = 1 AND category_id = #{categoryId} ORDER BY id LIMIT #{from}, #{count}")
@Select("SELECT * FROM brand WHERE status = 1 AND category_id = #{categoryId} ORDER BY priority LIMIT #{from}, #{count}")
@ResultMap("BaseResultMap")
List<Brand> listBrands(int categoryId, int from, int count);
}

View File

@@ -1,30 +1,30 @@
package net.irext.server.service.mapper;
import net.irext.server.service.model.CollectRemote;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Controller;
import java.util.List;
/**
* Filename: CollectRemoteMapper.java
* Revised: Date: 2018-12-08
* Revision: Revision: 1.0
* <p>
* Description: CollectRemote Mybatis Mapper
* <p>
* Revision log:
* 2018-12-08: created by strawmanbobi
*/
@Mapper
@Controller
public interface CollectRemoteMapper {
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND brand_id = #{brandId} AND status = 2")
@ResultMap("BaseResultMap")
List<CollectRemote> selectCollectRemotesByBrand(Integer categoryId, Integer brandId);
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND city_code = #{cityCode} AND status = 2")
@ResultMap("BaseResultMap")
List<CollectRemote> selectCollectRemotesByCity(Integer categoryId, String cityCode);
}
package net.irext.server.service.mapper;
import net.irext.server.service.model.CollectRemote;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Controller;
import java.util.List;
/**
* Filename: CollectRemoteMapper.java
* Revised: Date: 2018-12-08
* Revision: Revision: 1.0
* <p>
* Description: CollectRemote Mybatis Mapper
* <p>
* Revision log:
* 2018-12-08: created by strawmanbobi
*/
@Mapper
@Controller
public interface CollectRemoteMapper {
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND brand_id = #{brandId} AND status = 2 LIMIT #{from}, #{count}")
@ResultMap("BaseResultMap")
List<CollectRemote> selectCollectRemotesByBrand(Integer categoryId, Integer brandId, Integer from, Integer count);
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND city_code = #{cityCode} AND status = 2 LIMIT #{from}, #{count}")
@ResultMap("BaseResultMap")
List<CollectRemote> selectCollectRemotesByCity(Integer categoryId, String cityCode, Integer from, Integer count);
}

View File

@@ -207,7 +207,6 @@ public class IRIndexingService extends AbstractBaseService {
String cityCode = listIndexesRequest.getCityCode();
int from = listIndexesRequest.getFrom();
int count = listIndexesRequest.getCount();
int withParaData = listIndexesRequest.getWithParaData();
IndexesResponse response = validateToken(id, token, IndexesResponse.class);
if (response.getStatus().getCode() == Constants.ERROR_CODE_AUTH_FAILURE) {
@@ -215,7 +214,40 @@ public class IRIndexingService extends AbstractBaseService {
}
List<RemoteIndex> remoteIndexList =
indexingLogic.listRemoteIndexes(categoryId, brandId, cityCode, from, count, withParaData);
indexingLogic.listRemoteIndexes(categoryId, brandId, cityCode, from, count, 0);
if (remoteIndexList != null) {
response.getStatus().setCode(Constants.ERROR_CODE_SUCCESS);
response.setEntity(remoteIndexList);
} else {
response.getStatus().setCode(Constants.ERROR_CODE_NETWORK_ERROR);
}
return response;
} catch (Exception e) {
e.printStackTrace();
return getExceptionResponse(IndexesResponse.class);
}
}
@PostMapping("/list_collected_indexes")
public IndexesResponse listCollectedRemoteIndexes(HttpServletRequest request,
@HeaderParam("user-lang") String userLang,
@RequestBody ListIndexesRequest listIndexesRequest) {
try {
int id = listIndexesRequest.getId();
String token = listIndexesRequest.getToken();
int categoryId = listIndexesRequest.getCategoryId();
int brandId = listIndexesRequest.getBrandId();
String cityCode = listIndexesRequest.getCityCode();
int from = listIndexesRequest.getFrom();
int count = listIndexesRequest.getCount();
IndexesResponse response = validateToken(id, token, IndexesResponse.class);
if (response.getStatus().getCode() == Constants.ERROR_CODE_AUTH_FAILURE) {
return response;
}
List<RemoteIndex> remoteIndexList =
indexingLogic.listCollectedRemoteIndexes(categoryId, brandId, cityCode, from, count);
if (remoteIndexList != null) {
response.getStatus().setCode(Constants.ERROR_CODE_SUCCESS);
response.setEntity(remoteIndexList);