updated indexes and collected indexed list APIs according to public server
This commit is contained in:
10
server/.idea/runConfigurations.xml
generated
Normal file
10
server/.idea/runConfigurations.xml
generated
Normal 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>
|
||||||
@@ -8,6 +8,7 @@ import net.irext.server.service.model.*;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,37 +120,41 @@ public class IndexingLogic {
|
|||||||
|
|
||||||
public List<RemoteIndex> listRemoteIndexes(int categoryId, int brandId, String cityCode,
|
public List<RemoteIndex> listRemoteIndexes(int categoryId, int brandId, String cityCode,
|
||||||
int from, int count, int withParaData) {
|
int from, int count, int withParaData) {
|
||||||
List<RemoteIndex> remoteIndexList;
|
List<RemoteIndex> remoteIndexList = new ArrayList<>();
|
||||||
if (categoryId == Constants.CategoryID.STB.getValue()) {
|
if (categoryId == Constants.CategoryID.STB.getValue()) {
|
||||||
remoteIndexList = remoteIndexMapper.listRemoteIndexByCity(cityCode, from, count);
|
remoteIndexList = remoteIndexMapper.listRemoteIndexByCity(cityCode, from, count);
|
||||||
} else {
|
} else {
|
||||||
remoteIndexList = remoteIndexMapper.listRemoteIndexByBrand(categoryId, brandId, from, count);
|
remoteIndexList = remoteIndexMapper.listRemoteIndexByBrand(categoryId, brandId, from, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 == withParaData) {
|
return remoteIndexList;
|
||||||
List<CollectRemote> collectRemoteList;
|
}
|
||||||
|
|
||||||
if (Constants.CategoryID.STB.getValue() != categoryId) {
|
public List<RemoteIndex> listCollectedRemoteIndexes(int categoryId, int brandId, String cityCode,
|
||||||
collectRemoteList = collectRemoteMapper.selectCollectRemotesByBrand(categoryId, brandId);
|
int from, int count) {
|
||||||
} else {
|
List<RemoteIndex> remoteIndexList = new ArrayList<>();
|
||||||
collectRemoteList = collectRemoteMapper.selectCollectRemotesByCity(categoryId, cityCode);
|
List<CollectRemote> collectRemoteList;
|
||||||
}
|
|
||||||
|
|
||||||
// convert collectRemote to remoteIndex
|
if (Constants.CategoryID.STB.getValue() != categoryId) {
|
||||||
for (CollectRemote collectRemote : collectRemoteList) {
|
collectRemoteList = collectRemoteMapper.selectCollectRemotesByBrand(categoryId, brandId, from, count);
|
||||||
RemoteIndex remoteIndex = new RemoteIndex();
|
} else {
|
||||||
remoteIndex.setId(collectRemote.getId());
|
collectRemoteList = collectRemoteMapper.selectCollectRemotesByCity(categoryId, cityCode, from, count);
|
||||||
remoteIndex.setCategoryId(categoryId);
|
}
|
||||||
remoteIndex.setCategoryName(collectRemote.getCategoryName());
|
|
||||||
remoteIndex.setBrandId(brandId);
|
// convert collectRemote to remoteIndex
|
||||||
remoteIndex.setBrandName(collectRemote.getBrandName());
|
for (CollectRemote collectRemote : collectRemoteList) {
|
||||||
remoteIndex.setCityCode(collectRemote.getCityCode());
|
RemoteIndex remoteIndex = new RemoteIndex();
|
||||||
remoteIndex.setCityName(collectRemote.getCityName());
|
remoteIndex.setId(collectRemote.getId());
|
||||||
remoteIndex.setPriority(999);
|
remoteIndex.setCategoryId(categoryId);
|
||||||
remoteIndex.setSubCate((byte)Constants.BinaryType.TYPE_PARA_DATA.getValue());
|
remoteIndex.setCategoryName(collectRemote.getCategoryName());
|
||||||
remoteIndex.setStatus((byte) Constants.STATUS_PARA_DATA);
|
remoteIndex.setBrandId(brandId);
|
||||||
remoteIndexList.add(remoteIndex);
|
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;
|
return remoteIndexList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
@Controller
|
@Controller
|
||||||
public interface BrandMapper {
|
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")
|
@ResultMap("BaseResultMap")
|
||||||
List<Brand> listBrands(int categoryId, int from, int count);
|
List<Brand> listBrands(int categoryId, int from, int count);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
package net.irext.server.service.mapper;
|
package net.irext.server.service.mapper;
|
||||||
|
|
||||||
import net.irext.server.service.model.CollectRemote;
|
import net.irext.server.service.model.CollectRemote;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filename: CollectRemoteMapper.java
|
* Filename: CollectRemoteMapper.java
|
||||||
* Revised: Date: 2018-12-08
|
* Revised: Date: 2018-12-08
|
||||||
* Revision: Revision: 1.0
|
* Revision: Revision: 1.0
|
||||||
* <p>
|
* <p>
|
||||||
* Description: CollectRemote Mybatis Mapper
|
* Description: CollectRemote Mybatis Mapper
|
||||||
* <p>
|
* <p>
|
||||||
* Revision log:
|
* Revision log:
|
||||||
* 2018-12-08: created by strawmanbobi
|
* 2018-12-08: created by strawmanbobi
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Controller
|
@Controller
|
||||||
public interface CollectRemoteMapper {
|
public interface CollectRemoteMapper {
|
||||||
|
|
||||||
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND brand_id = #{brandId} AND status = 2")
|
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND brand_id = #{brandId} AND status = 2 LIMIT #{from}, #{count}")
|
||||||
@ResultMap("BaseResultMap")
|
@ResultMap("BaseResultMap")
|
||||||
List<CollectRemote> selectCollectRemotesByBrand(Integer categoryId, Integer brandId);
|
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")
|
@Select("SELECT * FROM collect_remote WHERE category_id = #{categoryId} AND city_code = #{cityCode} AND status = 2 LIMIT #{from}, #{count}")
|
||||||
@ResultMap("BaseResultMap")
|
@ResultMap("BaseResultMap")
|
||||||
List<CollectRemote> selectCollectRemotesByCity(Integer categoryId, String cityCode);
|
List<CollectRemote> selectCollectRemotesByCity(Integer categoryId, String cityCode, Integer from, Integer count);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,6 @@ public class IRIndexingService extends AbstractBaseService {
|
|||||||
String cityCode = listIndexesRequest.getCityCode();
|
String cityCode = listIndexesRequest.getCityCode();
|
||||||
int from = listIndexesRequest.getFrom();
|
int from = listIndexesRequest.getFrom();
|
||||||
int count = listIndexesRequest.getCount();
|
int count = listIndexesRequest.getCount();
|
||||||
int withParaData = listIndexesRequest.getWithParaData();
|
|
||||||
|
|
||||||
IndexesResponse response = validateToken(id, token, IndexesResponse.class);
|
IndexesResponse response = validateToken(id, token, IndexesResponse.class);
|
||||||
if (response.getStatus().getCode() == Constants.ERROR_CODE_AUTH_FAILURE) {
|
if (response.getStatus().getCode() == Constants.ERROR_CODE_AUTH_FAILURE) {
|
||||||
@@ -215,7 +214,40 @@ public class IRIndexingService extends AbstractBaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<RemoteIndex> remoteIndexList =
|
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) {
|
if (remoteIndexList != null) {
|
||||||
response.getStatus().setCode(Constants.ERROR_CODE_SUCCESS);
|
response.getStatus().setCode(Constants.ERROR_CODE_SUCCESS);
|
||||||
response.setEntity(remoteIndexList);
|
response.setEntity(remoteIndexList);
|
||||||
|
|||||||
Reference in New Issue
Block a user