提交 662b8806 authored 作者: zgy's avatar zgy

添加文件上传、删除接口;评论保存图片等

上级 c7d5f895
package com.diaoyun.zion.chinafrica.api;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.OssUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.Map;
/**
* @Auther: wudepeng
* @Date: 2020/01/09
* @Description:文件上传API
*/
@Api(tags = "文件上传API")
@RestController
@RequestMapping("/api/upload")
public class UploadController {
@ApiOperation("文件上传")
@PostMapping("/uploadFile")
public Result uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
Result result = new Result();
Map map = new HashMap();
String url = OssUtil.upload(file, "Afrishop");
map.put("url", url);
result.setData(map).setMessage(ResultCodeEnum.SUCCESS.getDesc());
return result;
}
@ApiOperation("删除文件")
@DeleteMapping("/delFile")
public Result delFile(@RequestParam("url") String url) {
Result result = new Result();
Map map = new HashMap();
boolean b = OssUtil.deleteFile(url);
map.put("isDeleted", b);
result.setData(map).setMessage(ResultCodeEnum.SUCCESS.getDesc());
return result;
}
}
...@@ -202,4 +202,6 @@ public class ShopifyController { ...@@ -202,4 +202,6 @@ public class ShopifyController {
public Result giveLike(@ApiParam("评论ID") @PathVariable String commentId) { public Result giveLike(@ApiParam("评论ID") @PathVariable String commentId) {
return tbCfItemCommentService.giveLike(commentId); return tbCfItemCommentService.giveLike(commentId);
} }
} }
...@@ -8,7 +8,7 @@ import java.util.Date; ...@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 tb_cf_item_comment * 表名 tb_cf_item_comment
* *
* @author lipengjun * @author lipengjun
* @date 2019-11-18 14:31:39 * @date 2020-01-09 10:17:03
*/ */
public class TbCfItemCommentEntity implements Serializable { public class TbCfItemCommentEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -29,6 +29,14 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -29,6 +29,14 @@ public class TbCfItemCommentEntity implements Serializable {
* 商品ID * 商品ID
*/ */
private String itemId; private String itemId;
/**
* 类型 0: 只有文本内容 1:带图片
*/
private Integer type;
/**
* 图片或视频的url
*/
private String urls;
/** /**
* 商品评分 * 商品评分
*/ */
...@@ -62,19 +70,41 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -62,19 +70,41 @@ public class TbCfItemCommentEntity implements Serializable {
*/ */
private Date createTime; private Date createTime;
/** /**
* 回复时间 * 更新时间
*/ */
private Date updateTime; private Date updateTime;
private String username; private String userName;
private String orderNo;
private String itemName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getItemName() {
return itemName;
}
public String getUsername() { public void setItemName(String itemName) {
return username; this.itemName = itemName;
} }
public void setUsername(String username) { public static long getSerialVersionUID() {
this.username = username; return serialVersionUID;
} }
/** /**
...@@ -90,7 +120,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -90,7 +120,6 @@ public class TbCfItemCommentEntity implements Serializable {
public String getId() { public String getId() {
return id; return id;
} }
/** /**
* 设置:评论人 * 设置:评论人
*/ */
...@@ -104,7 +133,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -104,7 +133,6 @@ public class TbCfItemCommentEntity implements Serializable {
public String getUserId() { public String getUserId() {
return userId; return userId;
} }
/** /**
* 设置:订单ID * 设置:订单ID
*/ */
...@@ -118,7 +146,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -118,7 +146,6 @@ public class TbCfItemCommentEntity implements Serializable {
public String getOrderId() { public String getOrderId() {
return orderId; return orderId;
} }
/** /**
* 设置:商品ID * 设置:商品ID
*/ */
...@@ -132,7 +159,32 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -132,7 +159,32 @@ public class TbCfItemCommentEntity implements Serializable {
public String getItemId() { public String getItemId() {
return itemId; return itemId;
} }
/**
* 设置:类型 0: 只有文本内容 1:带图片
*/
public void setType(Integer type) {
this.type = type;
}
/**
* 获取:类型 0: 只有文本内容 1:带图片
*/
public Integer getType() {
return type;
}
/**
* 设置:图片或视频的url
*/
public void setUrls(String urls) {
this.urls = urls;
}
/**
* 获取:图片或视频的url
*/
public String getUrls() {
return urls;
}
/** /**
* 设置:商品评分 * 设置:商品评分
*/ */
...@@ -146,7 +198,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -146,7 +198,6 @@ public class TbCfItemCommentEntity implements Serializable {
public Integer getItemScore() { public Integer getItemScore() {
return itemScore; return itemScore;
} }
/** /**
* 设置:服务评分 * 设置:服务评分
*/ */
...@@ -160,7 +211,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -160,7 +211,6 @@ public class TbCfItemCommentEntity implements Serializable {
public Integer getServiceScore() { public Integer getServiceScore() {
return serviceScore; return serviceScore;
} }
/** /**
* 设置:物流评分 * 设置:物流评分
*/ */
...@@ -174,7 +224,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -174,7 +224,6 @@ public class TbCfItemCommentEntity implements Serializable {
public Integer getLogisticsScore() { public Integer getLogisticsScore() {
return logisticsScore; return logisticsScore;
} }
/** /**
* 设置:价格评分 * 设置:价格评分
*/ */
...@@ -188,7 +237,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -188,7 +237,6 @@ public class TbCfItemCommentEntity implements Serializable {
public Integer getPriceScore() { public Integer getPriceScore() {
return priceScore; return priceScore;
} }
/** /**
* 设置:商品评论 * 设置:商品评论
*/ */
...@@ -202,7 +250,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -202,7 +250,6 @@ public class TbCfItemCommentEntity implements Serializable {
public String getItemReview() { public String getItemReview() {
return itemReview; return itemReview;
} }
/** /**
* 设置:点赞人数 * 设置:点赞人数
*/ */
...@@ -216,7 +263,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -216,7 +263,6 @@ public class TbCfItemCommentEntity implements Serializable {
public Long getLikeNum() { public Long getLikeNum() {
return likeNum; return likeNum;
} }
/** /**
* 设置:删除标志 0:正常 1:已删除 * 设置:删除标志 0:正常 1:已删除
*/ */
...@@ -230,7 +276,6 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -230,7 +276,6 @@ public class TbCfItemCommentEntity implements Serializable {
public Integer getDelFlag() { public Integer getDelFlag() {
return delFlag; return delFlag;
} }
/** /**
* 设置:创建时间 * 设置:创建时间
*/ */
...@@ -244,12 +289,17 @@ public class TbCfItemCommentEntity implements Serializable { ...@@ -244,12 +289,17 @@ public class TbCfItemCommentEntity implements Serializable {
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/**
* 设置:更新时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:更新时间
*/
public Date getUpdateTime() { public Date getUpdateTime() {
return updateTime; return updateTime;
} }
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
} }
...@@ -9,6 +9,7 @@ import com.diaoyun.zion.master.base.Result; ...@@ -9,6 +9,7 @@ import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.enums.ResultCodeEnum; import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.IdUtil; import com.diaoyun.zion.master.util.IdUtil;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -138,6 +139,10 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService { ...@@ -138,6 +139,10 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
comment.setLikeNum(0L); comment.setLikeNum(0L);
comment.setCreateTime(new Date()); comment.setCreateTime(new Date());
comment.setUpdateTime(new Date()); comment.setUpdateTime(new Date());
comment.setType(0);
if (!StringUtils.isBlank(comment.getUrls())) {
comment.setType(1);
}
int i = tbCfItemCommentDao.save(comment); int i = tbCfItemCommentDao.save(comment);
if (i > 0) { if (i > 0) {
result.setCode(ResultCodeEnum.SUCCESS.getCode()).setMessage("Comment on success!"); result.setCode(ResultCodeEnum.SUCCESS.getCode()).setMessage("Comment on success!");
...@@ -193,4 +198,6 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService { ...@@ -193,4 +198,6 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
return result; return result;
} }
} }
...@@ -297,13 +297,9 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService { ...@@ -297,13 +297,9 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
String phone = "+" + phoneNum.trim(); String phone = "+" + phoneNum.trim();
Result result = new Result(); Result result = new Result();
TbCfUserInfoEntity user = tbCfUserInfoDao.checkUserByPhone(phone); TbCfUserInfoEntity user = tbCfUserInfoDao.checkUserByPhone(phone);
if (user == null) {
result.setData(ResultCodeEnum.QUERY_ERROR.getCode()).setMessage("You haven't registered yet, please register first!");
return result;
}
String phoneCode = (String) captchaRedisCache.get(KeyConstant.CAPTCHA_PHONE + phone); String phoneCode = (String) captchaRedisCache.get(KeyConstant.CAPTCHA_PHONE + phone);
if (phoneCode == null) { if (phoneCode == null) {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode()).setMessage("Verification code failure"); result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode()).setMessage("Verification code failure!");
return result; return result;
} }
if (user != null && phoneCode.equals(code)) { if (user != null && phoneCode.equals(code)) {
...@@ -311,7 +307,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService { ...@@ -311,7 +307,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
captchaRedisCache.delete(KeyConstant.CAPTCHA_PHONE + phone); captchaRedisCache.delete(KeyConstant.CAPTCHA_PHONE + phone);
} else { } else {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode()); result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode());
result.setMessage("Login failed"); result.setMessage("You haven't registered yet, please register first!");
} }
return result; return result;
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
<result property="userId" column="user_id"/> <result property="userId" column="user_id"/>
<result property="orderId" column="order_id"/> <result property="orderId" column="order_id"/>
<result property="itemId" column="item_id"/> <result property="itemId" column="item_id"/>
<result property="type" column="type"/>
<result property="urls" column="urls"/>
<result property="itemScore" column="item_score"/> <result property="itemScore" column="item_score"/>
<result property="serviceScore" column="service_score"/> <result property="serviceScore" column="service_score"/>
<result property="logisticsScore" column="logistics_score"/> <result property="logisticsScore" column="logistics_score"/>
...@@ -25,6 +27,8 @@ ...@@ -25,6 +27,8 @@
`user_id`, `user_id`,
`order_id`, `order_id`,
`item_id`, `item_id`,
`type`,
`urls`,
`item_score`, `item_score`,
`service_score`, `service_score`,
`logistics_score`, `logistics_score`,
...@@ -72,6 +76,8 @@ ...@@ -72,6 +76,8 @@
`user_id`, `user_id`,
`order_id`, `order_id`,
`item_id`, `item_id`,
`type`,
`urls`,
`item_score`, `item_score`,
`service_score`, `service_score`,
`logistics_score`, `logistics_score`,
...@@ -91,6 +97,8 @@ ...@@ -91,6 +97,8 @@
`order_id`, `order_id`,
`item_id`, `item_id`,
`item_score`, `item_score`,
`type`,
`urls`,
`service_score`, `service_score`,
`logistics_score`, `logistics_score`,
`price_score`, `price_score`,
...@@ -118,7 +126,6 @@ ...@@ -118,7 +126,6 @@
</select> </select>
<select id="queryTotal" resultType="int"> <select id="queryTotal" resultType="int">
select count(*) from tb_cf_item_comment select count(*) from tb_cf_item_comment
WHERE 1=1 WHERE 1=1
...@@ -133,6 +140,8 @@ ...@@ -133,6 +140,8 @@
`user_id`, `user_id`,
`order_id`, `order_id`,
`item_id`, `item_id`,
`type`,
`urls`,
`item_score`, `item_score`,
`service_score`, `service_score`,
`logistics_score`, `logistics_score`,
...@@ -147,6 +156,8 @@ ...@@ -147,6 +156,8 @@
#{userId}, #{userId},
#{orderId}, #{orderId},
#{itemId}, #{itemId},
#{type},
#{urls},
#{itemScore}, #{itemScore},
#{serviceScore}, #{serviceScore},
#{logisticsScore}, #{logisticsScore},
...@@ -164,6 +175,8 @@ ...@@ -164,6 +175,8 @@
<if test="userId != null">`user_id` = #{userId},</if> <if test="userId != null">`user_id` = #{userId},</if>
<if test="orderId != null">`order_id` = #{orderId},</if> <if test="orderId != null">`order_id` = #{orderId},</if>
<if test="itemId != null">`item_id` = #{itemId},</if> <if test="itemId != null">`item_id` = #{itemId},</if>
<if test="type != null">`type` = #{type},</if>
<if test="urls != null">`urls` = #{urls},</if>
<if test="itemScore != null">`item_score` = #{itemScore},</if> <if test="itemScore != null">`item_score` = #{itemScore},</if>
<if test="serviceScore != null">`service_score` = #{serviceScore},</if> <if test="serviceScore != null">`service_score` = #{serviceScore},</if>
<if test="logisticsScore != null">`logistics_score` = #{logisticsScore},</if> <if test="logisticsScore != null">`logistics_score` = #{logisticsScore},</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论