Authored by caoyan

运单截屏

package com.yoho.order.dal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.ExpressScreenshots;
/**
* Created by caoyan on 2018/9/12.
*/
public interface ExpressScreenshotsMapper {
List<ExpressScreenshots> selectByWaybillCode(@Param("waybillCode") String waybillCode);
int insert(ExpressScreenshots expressScreenshots);
}
... ...
package com.yoho.order.model;
import java.io.Serializable;
/**
* @author caoyan
* @date 2018/9/13
*/
public class ExpressScreenshots implements Serializable {
private static final long serialVersionUID = 2607922995706119816L;
private Integer id;
private String waybillCode;
private String url;
private Integer createTime;
private Integer createUid;
private String createUserName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getWaybillCode() {
return waybillCode;
}
public void setWaybillCode(String waybillCode) {
this.waybillCode = waybillCode;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getCreateUid() {
return createUid;
}
public void setCreateUid(Integer createUid) {
this.createUid = createUid;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
@Override
public String toString() {
return "ExpressScreenshots{" +
"id=" + id +
", waybillCode='" + waybillCode + '\'' +
", url='" + url + '\'' +
", createTime='" + createTime + '\'' +
", createUid=" + createUid +
", createUserName=" + createUserName +
'}';
}
}
... ...
<?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.yoho.order.dal.ExpressScreenshotsMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.ExpressScreenshots">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="waybill_code" property="waybillCode" jdbcType="VARCHAR" />
<result column="url" property="url" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="create_uid" property="createUid" jdbcType="INTEGER" />
<result column="create_user_name" property="createUserName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, waybill_code, url, create_time, create_uid, create_user_name
</sql>
<insert id="insert" parameterType="com.yoho.order.model.ExpressScreenshots">
insert into express_screenshots (waybill_code, url, create_time, create_uid, create_user_name)
values (#{waybillCode}, #{url}, #{createTime}, #{createUid}, #{createUserName})
</insert>
<select id="selectByWaybillCode" resultMap = "BaseResultMap">
select <include refid="Base_Column_List"></include>
from express_screenshots where waybill_code= #{waybillCode}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.order.controller;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.ufo.order.request.ExpressScreenshotsReq;
import com.yoho.ufo.order.response.ExpressScreenshotsRsp;
import com.yoho.ufo.order.service.IExpressScreenshotsService;
import com.yoho.ufo.service.model.ApiResponse;
@RestController
@RequestMapping(value = "/expressScreenshots")
public class ExpressScreenshotsController {
private static final Logger LOGGER = LoggerFactory.getLogger(ExpressScreenshotsController.class);
@Autowired
private IExpressScreenshotsService expressScreenshotsService;
@RequestMapping(value = "/save")
public ApiResponse save(ExpressScreenshotsReq req) {
LOGGER.info("expressScreenshots save in. req is {}", req);
if(StringUtils.isEmpty(req.getWaybillCode()) || StringUtils.isEmpty(req.getUrl())) {
return new ApiResponse.ApiResponseBuilder().code(400).message("waybillCode or url is empty").build();
}
int result = expressScreenshotsService.save(req.getWaybillCode(), req.getUrl());
if(result > 0) {
return new ApiResponse.ApiResponseBuilder().code(200).message("保存成功").data(result).build();
}else {
return new ApiResponse.ApiResponseBuilder().code(500).message("保存失败").data(result).build();
}
}
@RequestMapping(value = "/queryByWaybillCode")
public ApiResponse queryByWaybillCode(ExpressScreenshotsReq req ) {
String waybillCode = req.getWaybillCode();
LOGGER.info("queryByWaybillCode in. waybillCode is {}", waybillCode);
List<ExpressScreenshotsRsp> result = expressScreenshotsService.queryListByWaybillCode(waybillCode);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
package com.yoho.ufo.order.request;
public class ExpressScreenshotsReq {
private String waybillCode;
private String url;
public String getWaybillCode() {
return waybillCode;
}
public void setWaybillCode(String waybillCode) {
this.waybillCode = waybillCode;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
... ...
package com.yoho.ufo.order.response;
public class ExpressScreenshotsRsp {
private String waybillCode;
private String url;
private String createTimeStr;
private String createUserName;
public String getWaybillCode() {
return waybillCode;
}
public void setWaybillCode(String waybillCode) {
this.waybillCode = waybillCode;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getCreateTimeStr() {
return createTimeStr;
}
public void setCreateTimeStr(String createTimeStr) {
this.createTimeStr = createTimeStr;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
}
... ...
package com.yoho.ufo.order.service;
import java.util.List;
import com.yoho.order.model.ExpressScreenshots;
import com.yoho.ufo.order.response.ExpressScreenshotsRsp;
public interface IExpressScreenshotsService {
int save(String waybillCode, String url);
List<ExpressScreenshotsRsp> queryListByWaybillCode(String waybillCode)
}
... ...
package com.yoho.ufo.order.service.impl;
import java.util.List;
import org.elasticsearch.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.order.dal.ExpressScreenshotsMapper;
import com.yoho.order.model.ExpressScreenshots;
import com.yoho.ufo.order.response.ExpressScreenshotsRsp;
import com.yoho.ufo.order.service.IExpressScreenshotsService;
import com.yoho.ufo.service.impl.UserHelper;
/**
* @author craig.qin
*/
@Service
public class ExpressScreenshotsServiceImpl implements IExpressScreenshotsService {
private static final Logger LOGGER = LoggerFactory.getLogger(ExpressScreenshotsServiceImpl.class);
@Autowired
private ExpressScreenshotsMapper expressScreenshotsMapper;
@Override
public int save(String waybillCode, String url){
ExpressScreenshots record = new ExpressScreenshots();
record.setWaybillCode(waybillCode);
record.setUrl(url);
record.setCreateTime(DateUtil.getCurrentTimeSecond());
// UserHelper userInfo = new UserHelper();
// record.setCreateUid(userInfo.getUserId());
// record.setCreateUserName(userInfo.getUserName());
record.setCreateUid(10961101);
record.setCreateUserName("测试名字");
return expressScreenshotsMapper.insert(record);
}
@Override
public List<ExpressScreenshotsRsp> queryListByWaybillCode(String waybillCode) {
List<ExpressScreenshots> list = expressScreenshotsMapper.selectByWaybillCode(waybillCode);
List<ExpressScreenshotsRsp> rspList = Lists.newArrayList();
for(ExpressScreenshots item : list) {
ExpressScreenshotsRsp rsp = new ExpressScreenshotsRsp();
rsp.setWaybillCode(item.getWaybillCode());
rsp.setUrl(item.getUrl());
rsp.setCreateTimeStr(DateUtil.getDateStrBySecond(item.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
rsp.setCreateUserName(item.getCreateUserName());
rspList.add(rsp);
}
return rspList;
}
}
... ...
... ... @@ -52,6 +52,7 @@ datasources:
- com.yoho.order.dal.OrderConfigMapper
- com.yoho.order.dal.PhoneUidCameraMapper
- com.yoho.order.dal.PhoneUidDepotMapper
- com.yoho.order.dal.ExpressScreenshotsMapper
ufo_resource:
servers:
... ...
... ... @@ -52,6 +52,7 @@ datasources:
- com.yoho.order.dal.OrderConfigMapper
- com.yoho.order.dal.PhoneUidCameraMapper
- com.yoho.order.dal.PhoneUidDepotMapper
- com.yoho.order.dal.ExpressScreenshotsMapper
ufo_resource:
servers:
... ...