implemented list_categories restful API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.irext.server.service;
|
||||
|
||||
import net.irext.server.service.model.Category;
|
||||
import net.irext.server.service.model.RemoteIndex;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
@@ -17,13 +18,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
* 2019-06-10: created by strawmanbobi
|
||||
*/
|
||||
|
||||
@MappedTypes(RemoteIndex.class)
|
||||
@MapperScan("net.irext.server.service.mapper")
|
||||
@SpringBootApplication
|
||||
public class IRPrivateServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(IRPrivateServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.irext.server.service.businesslogic;
|
||||
|
||||
import net.irext.server.service.mapper.CategoryMapper;
|
||||
import net.irext.server.service.mapper.RemoteIndexMapper;
|
||||
import net.irext.server.service.model.Category;
|
||||
import net.irext.server.service.model.RemoteIndex;
|
||||
@@ -21,6 +22,9 @@ import java.util.List;
|
||||
@Controller
|
||||
public class IndexingLogic {
|
||||
|
||||
@Autowired
|
||||
private CategoryMapper categoryMapper;
|
||||
|
||||
@Autowired
|
||||
private RemoteIndexMapper remoteIndexMapper;
|
||||
|
||||
@@ -32,7 +36,7 @@ public class IndexingLogic {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Category> listCategories(int lang, int from, int count) {
|
||||
return null;
|
||||
public List<Category> listCategories(int lang, int from, int count) {
|
||||
return categoryMapper.listCategories(from, count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.irext.server.service.cache;
|
||||
|
||||
import net.irext.server.service.model.UserApp;
|
||||
|
||||
/**
|
||||
* Filename: IUserAppRepository.java
|
||||
* Revised: Date: 2019-06-08
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.irext.server.service.cache.impl;
|
||||
|
||||
import net.irext.server.service.cache.IUserAppRepository;
|
||||
import net.irext.server.service.model.UserApp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.irext.server.service.mapper;
|
||||
|
||||
import net.irext.server.service.model.Category;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.ResultMap;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Filename: CategoryMapper.java
|
||||
* Revised: Date: 2019-06-12
|
||||
* Revision: Revision: 1.0
|
||||
* <p>
|
||||
* Description: CategoryMapper
|
||||
* <p>
|
||||
* Revision log:
|
||||
* 2019-06-12: created by strawmanbobi
|
||||
*/
|
||||
@Mapper
|
||||
public interface CategoryMapper {
|
||||
@Select("SELECT * FROM category WHERE status = 1 ORDER BY id LIMIT #{from}, #{count}")
|
||||
@ResultMap("BaseResultMap")
|
||||
List<Category> listCategories(int from, int count);
|
||||
}
|
||||
@@ -12,14 +12,13 @@ import java.util.List;
|
||||
* Revised: Date: 2018-12-08
|
||||
* Revision: Revision: 1.0
|
||||
* <p>
|
||||
* Description: CollectRemote Mybatis Mapper
|
||||
* Description: RemoteIndexMapper
|
||||
* <p>
|
||||
* Revision log:
|
||||
* 2018-12-08: created by strawmanbobi
|
||||
*/
|
||||
@Mapper
|
||||
public interface RemoteIndexMapper {
|
||||
|
||||
@Select("SELECT * FROM remote_index WHERE id = #{id}")
|
||||
@ResultMap("BaseResultMap")
|
||||
List<RemoteIndex> getRemoteIndexById(int id);
|
||||
|
||||
@@ -10,10 +10,12 @@ import net.irext.server.service.restapi.base.AbstractBaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,8 +46,9 @@ public class IRIndexingService extends AbstractBaseService {
|
||||
}
|
||||
|
||||
@PostMapping("/list_categories")
|
||||
public CategoriesResponse listCategories(@HeaderParam("user-lang") String userLang,
|
||||
ListCategoriesRequest listCategoriesRequest) {
|
||||
public CategoriesResponse listCategories(HttpServletRequest request,
|
||||
@HeaderParam("user-lang") String userLang,
|
||||
@RequestBody ListCategoriesRequest listCategoriesRequest) {
|
||||
try {
|
||||
int id = listCategoriesRequest.getId();
|
||||
String token = listCategoriesRequest.getToken();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="net.irext.server.service.mapper.CategoryMapper">
|
||||
<resultMap id="BaseResultMap" type="net.irext.server.service.model.Category">
|
||||
<!--
|
||||
WARNING - @mbggenerated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Thu May 04 12:06:44 CST 2017.
|
||||
-->
|
||||
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="TINYINT"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="CHAR"/>
|
||||
<result column="name_en" property="nameEn" jdbcType="VARCHAR"/>
|
||||
<result column="name_tw" property="nameTw" jdbcType="VARCHAR"/>
|
||||
<result column="contributor" property="contributor" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user