-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ysz information and database support
- Loading branch information
xijiaxiang
committed
May 26, 2018
1 parent
94dbd38
commit 123ac3f
Showing
31 changed files
with
1,072 additions
and
426 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.xixi.controller; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.xixi.mapper.PreSaleDao; | ||
import com.xixi.pojo.PreSaleInfo; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.List; | ||
|
||
/**预售证的控制器 | ||
* Created by xijiaxiang on 2018/5/26. | ||
*/ | ||
@Controller | ||
public class YSZController { | ||
@Autowired | ||
private PreSaleDao preSaleDao; | ||
|
||
@RequestMapping(value="/queryYSZ",produces="application/json;charset=utf-8") | ||
@ResponseBody | ||
public String getYSZ(HttpServletRequest request){ | ||
String pageNumber=request.getParameter("page"); | ||
String limitNumber=request.getParameter("limit"); | ||
int page=1; | ||
int limit=30; | ||
try { | ||
page = Integer.parseInt(pageNumber); | ||
limit = Integer.parseInt(limitNumber); | ||
}catch (NumberFormatException e){ | ||
System.out.println("number format error "); | ||
} | ||
|
||
int count=preSaleDao.queryCount(); | ||
|
||
List<PreSaleInfo> preSaleInfoList=preSaleDao.queryAll((page-1)*limit,limit); | ||
|
||
return "{\"code\":0,\"msg\":\"ok\",\"count\":"+count+",\"data\":"+ JSON.toJSONString(preSaleInfoList)+"}"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.xixi.mapper; | ||
|
||
import com.xixi.pojo.PreSaleInfo; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by xijiaxiang on 2018/5/22. | ||
*/ | ||
public interface PreSaleDao { | ||
/** | ||
* 通过ID查询 | ||
* | ||
* @param id | ||
* @return | ||
*/ | ||
PreSaleInfo queryById(String id); | ||
|
||
/** | ||
* 查询所有 | ||
* | ||
* @param offset 查询起始位置 | ||
* @param limit 查询条数 | ||
* @return | ||
*/ | ||
List<PreSaleInfo> queryAll(@Param("offset") int offset, @Param("limit") int limit); | ||
|
||
int insertOneYSZ(PreSaleInfo preSaleInfo); | ||
|
||
/** | ||
* 查询所有 | ||
* @return | ||
*/ | ||
int queryCount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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="com.xixi.mapper.PreSaleDao"> | ||
<select id="queryById" resultType="PreSaleInfo" parameterType="String"> | ||
<![CDATA[ | ||
SELECT | ||
yszNumber, | ||
projectName, | ||
projectAddress, | ||
yszStartDate | ||
FROM | ||
ysz | ||
WHERE | ||
yszNumber = #{yszNumber}]]> | ||
</select> | ||
|
||
<select id="queryAll" resultType="PreSaleInfo"> | ||
<![CDATA[SELECT | ||
yszNumber, | ||
projectName, | ||
projectAddress, | ||
yszStartDate | ||
FROM | ||
ysz | ||
ORDER BY | ||
str_to_date(REPLACE(REPLACE(REPLACE(yszStartDate,'年','-'),'月','-'),'日',''),'%Y-%m-%d') desc | ||
LIMIT #{offset}, #{limit}]]> | ||
</select> | ||
|
||
<insert id="insertOneYSZ" parameterType="PreSaleInfo"> | ||
INSERT INTO ysz VALUES (#{yszNumber},#{projectName},#{projectAddress},#{yszStartDate}) | ||
</insert> | ||
|
||
<select id="queryCount" resultType="Integer"> | ||
<![CDATA[ select count(*) from ysz ]]> | ||
</select> | ||
</mapper> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.