Commit 84fe9d0d by jscat

nyx: 配餐

添加配餐bean和api接口
1. 添加tbl_pairing
2. query tbl_pairing
parent 3e86fefb
package cn.com.fun.nyxkey.api.domain;
package cn.com.fun.nyxkey.api.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 配餐表
* Created by jscat on 2020/05/30.
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Rockwell_keyT_pair{
private String pairId; // 发文的id, uuid format
private String userId; // 用户的id, uuid format
private String food; // 食物
private String wineName; // wine的名称
private String wineDesc; // wine的描述
private String imgLink; // 该条source的imgage link
private String wineLink; // 该条source的wine link
private String sourceLink; // 该条source的URL link
private String numLike; // 针对每条pair的点赞次数,每点一次,则累加
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createDatetime; // 统计周期
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date updateDatetime; // 更新日期
}
package cn.com.fun.nyxkey.api.domain.query;
package cn.com.fun.nyxkey.api.domain.query;
import cn.com.fun.nyxkey.api.common.Pagination;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* Created by jscat on 2020/05/30.
1. 输入布里,返回搜索结果,默认pagination, order by num_like
2. 输入userId,返回该id所有的配餐, order by num_like
3. 输入长相思,返回长相思所有的配餐, order by num_like
*/
@Data
@AllArgsConstructor
public class Rockwell_keyT_pairQuery {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createDatetime;
private String userId;
private List<String> listStrSearchName;
private Pagination pagination;
public Rockwell_keyT_pairQuery(){
// 分页设置,默认是1页4条记录
this.pagination = new Pagination(1, 4);
}
public void setListStrSearchName(List<String> strSearchName)
{
if(strSearchName.equals("null") || strSearchName.equals("") || strSearchName.equals("0"))
{
this.listStrSearchName = null;
}
else
{
this.listStrSearchName = strSearchName;
}
}
public void setUserId(String strUserId)
{
if(strUserId.equals("null") || strUserId.equals("0"))
{
this.userId = null;
}
else
{
this.userId = strUserId;
}
}
public void setCreateDatetime(Date createDatetime)
{
if(createDatetime.equals("null"))
{
this.createDatetime = null;
}
else
{
this.createDatetime = createDatetime;
}
}
@Override
public String toString() {
return "Rockwell_keyT_postQuery{" +
"createDatetime='" + createDatetime + '\'' +
"listStrSearchName='" + listStrSearchName + '\'' +
"userId='" + userId + '\'' +
"pagination='" + pagination + '\'' +
'}';
}
}
package cn.com.fun.nyxkey.api.repository; package cn.com.fun.nyxkey.api.repository;
...@@ -39,6 +39,10 @@ public interface Rockwell_keyMapper { ...@@ -39,6 +39,10 @@ public interface Rockwell_keyMapper {
void addT_post(Rockwell_keyT_post rockwell_keyT_post); void addT_post(Rockwell_keyT_post rockwell_keyT_post);
void addT_postLike(Rockwell_keyT_post rockwell_keyT_post); void addT_postLike(Rockwell_keyT_post rockwell_keyT_post);
/* pair api */
List<Rockwell_keyT_pair> getT_pair(Rockwell_keyT_pairQuery rockwell_keyT_pairQuery);
void addT_pair(Rockwell_keyT_pair rockwell_keyT_pair);
/* area api */ /* area api */
List<Rockwell_keyV_area_total> getCityList(); List<Rockwell_keyV_area_total> getCityList();
List<Rockwell_keyV_area_total> getCityInfo(Rockwell_keyT_areaQuery rockwell_keyT_areaQuery); List<Rockwell_keyV_area_total> getCityInfo(Rockwell_keyT_areaQuery rockwell_keyT_areaQuery);
......
package cn.com.fun.nyxkey.api.service; package cn.com.fun.nyxkey.api.service;
...@@ -50,6 +50,11 @@ public interface Rockwell_keyService { ...@@ -50,6 +50,11 @@ public interface Rockwell_keyService {
int Rockwell_keyServiceAddT_post(String userId, String noteImage, String tag, String title, String content) throws UnsupportedEncodingException; int Rockwell_keyServiceAddT_post(String userId, String noteImage, String tag, String title, String content) throws UnsupportedEncodingException;
int Rockwell_keyServiceAddT_postLike(String postId); int Rockwell_keyServiceAddT_postLike(String postId);
/* pair api 20200530 jscat */
JSONResult Rockwell_keyServiceGetT_pair(String userId, String strSearchName, int pageNum, int pageCount);
int Rockwell_keyServiceAddT_pair(String userId, String food, String wineName, String wineDesc,
String imgLink, String wineLink, String sourceLink) throws UnsupportedEncodingException;
/* member pos api */ /* member pos api */
JSONResult Rockwell_keyServiceGetCityList(); JSONResult Rockwell_keyServiceGetCityList();
JSONResult Rockwell_keyServiceGetCityInfo(String city); JSONResult Rockwell_keyServiceGetCityInfo(String city);
......
package cn.com.fun.nyxkey.api.service.impl; package cn.com.fun.nyxkey.api.service.impl;
...@@ -332,6 +332,56 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService { ...@@ -332,6 +332,56 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
return 0; return 0;
} }
/*
pair service pair-1.1
获取 pair
*/
public JSONResult Rockwell_keyServiceGetT_pair(String userId, String strSearchName, int pageNum, int pageCount){
Rockwell_keyT_pairQuery rockwell_keyT_pairQuery = new Rockwell_keyT_pairQuery();
rockwell_keyT_pairQuery.setUserId(userId);
List<String> listSearchName = new ArrayList<String>();
if(!(strSearchName.equals("") || strSearchName.equals("0")))
{
listSearchName = Arrays.asList(strSearchName.replaceAll(" +", " ").split(" "));
System.out.println("sql string: "+listSearchName.toString());
LOGGER.debug("============= sql string: "+listSearchName.toString());
rockwell_keyT_pairQuery.setListStrSearchName(listSearchName);
}
rockwell_keyT_pairQuery.setPagination(new Pagination(pageNum, pageCount));
List<Rockwell_keyT_pair> listRockwell_keyT_pair = new ArrayList<Rockwell_keyT_pair>();
listRockwell_keyT_pair = rockwell_keyMapper.getT_pair(rockwell_keyT_pairQuery);
int totalCount = listRockwell_keyT_pair.size();
JSONResult jsonResult = new JSONResult(totalCount, listRockwell_keyT_pair);
return jsonResult;
}
/*
pair service pair-1.2
添加 pair
*/
public int Rockwell_keyServiceAddT_pair(String userId, String food, String wineName, String wineDesc,
String imgLink, String wineLink, String sourceLink) throws UnsupportedEncodingException
{
LOGGER.debug("find Rockwell_keyServiceAddT_pair");
System.out.println("find Rockwell_keyServiceAddT_pair");
Rockwell_keyT_pair rockwell_keyT_pair = new Rockwell_keyT_pair();
rockwell_keyT_pair.setPairId("pid_"+UUID.randomUUID().toString());
rockwell_keyT_pair.setUserId(userId);
rockwell_keyT_pair.setFood(food);
rockwell_keyT_pair.setWineName(wineName);
rockwell_keyT_pair.setWineDesc(wineDesc);
rockwell_keyT_pair.setImgLink(imgLink);
rockwell_keyT_pair.setWineLink(wineLink);
rockwell_keyT_pair.setSourceLink(sourceLink);
rockwell_keyT_pair.setCreateDatetime(new Date());
rockwell_keyT_pair.setUpdateDatetime(new Date());
rockwell_keyMapper.addT_pair(rockwell_keyT_pair);
return 0;
}
/* member pos api */ /* member pos api */
public JSONResult Rockwell_keyServiceGetCityList() public JSONResult Rockwell_keyServiceGetCityList()
{ {
......
package cn.com.fun.nyxkey.api.web.controller; package cn.com.fun.nyxkey.api.web.controller;
...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.UnsupportedEncodingException;
import java.util.*; import java.util.*;
/* /*
...@@ -277,6 +278,51 @@ public class NyxApiController { ...@@ -277,6 +278,51 @@ public class NyxApiController {
keyService.Rockwell_keyServiceAddT_postLike(postId); keyService.Rockwell_keyServiceAddT_postLike(postId);
} }
// 5.0 pair api PairApi-1.1
@ApiOperation(value="获取配餐的pairing信息", notes="获取配餐的pairing信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", required = false, dataType = "String"),
@ApiImplicitParam(name = "strSearchName", value = "关键词", required = false, dataType = "String"),
@ApiImplicitParam(name = "pageNum", value = "页码,从1开始", required = false, dataType = "String", defaultValue = "1"),
@ApiImplicitParam(name = "pageCount", value = "每页的数据个数,默认是4个", required = false, dataType = "String", defaultValue = "4")
})
@RequestMapping(value = "/nyx/pair/query", method = RequestMethod.GET)
public JSONResult RockwellQueryPair(
@RequestParam(value = "userId", required = false, defaultValue = "0") String userId,
@RequestParam(value = "strSearchName", required = false, defaultValue = "0") String strSearchName,
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
@RequestParam(value = "pageCount", required = false, defaultValue = "5") int pageCount
) {
return keyService.Rockwell_keyServiceGetT_pair(userId, strSearchName, pageNum, pageCount);
}
// 5.1 pair api add PairApi-1.2
@ApiOperation(value="为pair添加pairing,对应tbl_pairing", notes="为t_pairing添加pairing,对应tbl_pairing")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", required = false, dataType = "String"),
@ApiImplicitParam(name = "food", value = "food名称", required = false, dataType = "String"),
@ApiImplicitParam(name = "wineName", value = "wine名称", required = false, dataType = "String"),
@ApiImplicitParam(name = "wineDesc", value = "wine描述", required = false, dataType = "String"),
@ApiImplicitParam(name = "imgLink", value = "wine图片链接", required = false, dataType = "String"),
@ApiImplicitParam(name = "wineLink", value = "wine链接", required = false, dataType = "String"),
@ApiImplicitParam(name = "sourceLink", value = "source链接", required = false, dataType = "String")
})
@RequestMapping(value = "/nyx/pair/add/item", method = RequestMethod.POST)
@ResponseBody
public void RockwellAddPairItem(
@RequestParam(value = "userId", required = false, defaultValue = "0") String userId,
@RequestParam(value = "food", required = false, defaultValue = "0") String food,
@RequestParam(value = "wineName", required = false, defaultValue = "0") String wineName,
@RequestParam(value = "wineDesc", required = false, defaultValue = "0") String wineDesc,
@RequestParam(value = "imgLink", required = false, defaultValue = "0") String imgLink,
@RequestParam(value = "wineLink", required = false, defaultValue = "0") String wineLink,
@RequestParam(value = "sourceLink", required = false, defaultValue = "0") String sourceLink
) throws UnsupportedEncodingException
{
keyService.Rockwell_keyServiceAddT_pair(userId, food, wineName, wineDesc, imgLink, wineLink, sourceLink);
}
// 5.0 member pos api // 5.0 member pos api
@ApiOperation(value="获取citylist", notes="获取citylist") @ApiOperation(value="获取citylist", notes="获取citylist")
@ApiImplicitParams({}) @ApiImplicitParams({})
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
...@@ -273,6 +273,27 @@ limitations under the License. ...@@ -273,6 +273,27 @@ limitations under the License.
WHERE post_id=#{postId} WHERE post_id=#{postId}
</select> </select>
<select id="getT_pair" parameterType="cn.com.fun.nyxkey.api.domain.query.Rockwell_keyT_pairQuery" resultType="cn.com.fun.nyxkey.api.domain.Rockwell_keyT_pair">
SELECT * FROM tbl_pairing
WHERE 1=1
<if test="userId != null and userId != '' ">
AND ( user_id = #{userId} )
</if>
<foreach collection="listStrSearchName" index="index" item="item" open="" separator=" " close="">
AND ( food LIKE CONCAT('%',#{item},'%') OR CONCAT(wine_name,wine_desc) LIKE CONCAT('%',#{item},'%'))
</foreach>
order by num_like desc, create_datetime desc
<if test="pagination != null ">
<include refid="pagination"/>
</if>
</select>
<!-- pair api 添加一条pair信息 -->
<insert id="addT_pair" parameterType="cn.com.fun.nyxkey.api.domain.Rockwell_keyT_pair">
insert into tbl_pairing (pair_id, user_id, food, wine_name, wine_desc, img_link, wine_link, source_link, num_like, create_datetime, update_datetime)
values (#{pairId}, #{userId}, #{food}, #{wineName}, #{wineDesc}, #{imgLink}, #{wineLink}, #{sourceLink}, '0', #{createDatetime}, #{updateDatetime})
</insert>
<!-- post api 4.1 从 view_post_info 获取 post信息 <!-- post api 4.1 从 view_post_info 获取 post信息
--> -->
<select id="getCityList" resultType="cn.com.fun.nyxkey.api.domain.Rockwell_keyV_area_total"> <select id="getCityList" resultType="cn.com.fun.nyxkey.api.domain.Rockwell_keyV_area_total">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论