Commit 6724eb62 authored by m1991's avatar m1991

资讯模块数据——图片展示功能修复

parent dd875197
...@@ -21,15 +21,14 @@ public interface ShopZxMapper extends BaseMapper<shopZx> { ...@@ -21,15 +21,14 @@ public interface ShopZxMapper extends BaseMapper<shopZx> {
* @param * @param
* @return 1 * @return 1
*/ */
int zxadd(@Param("zxUrl") String zxUrl,@Param("zxField") String zxField,@Param("zxAddress") String zxAddress,@Param("inviteCode") String inviteCode,@Param("zxDate") Long zxDate); int zxadd(@Param("zxUrl") String zxUrl,@Param("zxField") String zxField,@Param("inviteCode") String inviteCode,@Param("zxDate") Long zxDate);
/** /**
* 用户头像上传 * 用户头像上传并更新
* @param zxUrl * @param
* @param zxDate
* @return * @return
*/ */
int zxadd1(@Param("zxUrl") String zxUrl ,@Param("zxDate") Long zxDate); int zxadd1(@Param("headImage") String headImage,@Param("userId") String userId);
/** /**
* 查询资讯数据 * 查询资讯数据
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<result column="invite_code" property="inviteCode"/> <result column="invite_code" property="inviteCode"/>
<result column="zx_to_examine" property="zxToExamine"/> <result column="zx_to_examine" property="zxToExamine"/>
<result column="zx_field" property="zxField"/> <result column="zx_field" property="zxField"/>
<result column="zx_address" property="zxAddress"/>
<result column="zx_date" property="zxDate"/> <result column="zx_date" property="zxDate"/>
</resultMap> </resultMap>
<sql id="table"> <sql id="table">
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
</sql> </sql>
<sql id="vals"> <sql id="vals">
#{zxUrl},#{zxField},#{zxAddress},#{inviteCode},#{zxDate} #{zxUrl},#{zxField},#{inviteCode},#{zxDate}
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
...@@ -43,14 +42,16 @@ ...@@ -43,14 +42,16 @@
</insert> </insert>
<!--用户头像插入--> <!--用户头像插入-->
<insert id="zxadd1" parameterType="cn.wisenergy.model.app.shopZx"> <update id="zxadd1" parameterType="cn.wisenergy.model.app.User">
insert into UPDATE
<include refid="table"/> user_info
zx_url,zx_date <set>
value( head_image=#{headImage}
#{zxUrl},#{zxDate} </set>
) <where>
</insert> user_id=#{userId}
</where>
</update>
<!--资讯内容倒叙查询--> <!--资讯内容倒叙查询-->
......
...@@ -48,6 +48,9 @@ public class zxUserDto { ...@@ -48,6 +48,9 @@ public class zxUserDto {
@ApiModelProperty(name = "zx_likes", value = "获赞数") @ApiModelProperty(name = "zx_likes", value = "获赞数")
private Integer zxLikes; private Integer zxLikes;
@ApiModelProperty(name = "liked_status", value = "点赞状态")
private Integer likedStatus;
/** /**
* 资讯文字输入字段 * 资讯文字输入字段
*/ */
......
...@@ -19,14 +19,14 @@ public interface UploadService { ...@@ -19,14 +19,14 @@ public interface UploadService {
* @param request * @param request
* @return * @return
*/ */
Map<String, Object> uploadVideo(MultipartFile file,HttpServletRequest request,String zxField,String zxAddress,String inviteCode) throws Exception; Map<String, Object> uploadVideo(MultipartFile file,HttpServletRequest request,String zxField,String inviteCode) throws Exception;
/** /**
* TODO 用户头像上传 * TODO 用户头像上传
* *
* @return * @return
*/ */
Map<String, Object> uploadImage(MultipartFile file) throws Exception; Map<String, Object> uploadImage(MultipartFile file,String inviteCode) throws Exception;
/** /**
...@@ -34,7 +34,7 @@ public interface UploadService { ...@@ -34,7 +34,7 @@ public interface UploadService {
* @param file * @param file
* @return * @return
*/ */
List imageUpload( MultipartFile[] file, String zxField, String zxAddress,String inviteCode); List imageUpload( MultipartFile[] file, String zxField,String inviteCode);
...@@ -49,7 +49,7 @@ public interface UploadService { ...@@ -49,7 +49,7 @@ public interface UploadService {
* @param pageSize * @param pageSize
* @return * @return
*/ */
Map selectPage(Integer pageNum, Integer pageSize); Map selectPage(Integer pageNum, Integer pageSize,String inviteCode);
/** /**
* TODO 资讯点赞 * TODO 资讯点赞
......
...@@ -56,7 +56,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -56,7 +56,7 @@ public class UploadServiceImpl implements UploadService {
* 视频文件上传 * 视频文件上传
*/ */
@Override @Override
public Map<String, Object> uploadVideo(MultipartFile file,HttpServletRequest request,String zxField,String zxAddress,String inviteCode) throws Exception { public Map<String, Object> uploadVideo(MultipartFile file,HttpServletRequest request,String zxField,String inviteCode) throws Exception {
Map<String, Object> resultMap=new HashMap<String, Object>(); Map<String, Object> resultMap=new HashMap<String, Object>();
/** /**
* http://路径 request.getScheme() + "://" + request.getServerName() * http://路径 request.getScheme() + "://" + request.getServerName()
...@@ -100,7 +100,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -100,7 +100,7 @@ public class UploadServiceImpl implements UploadService {
* 生成当前时间戳 * 生成当前时间戳
*/ */
Long zxDate= System.currentTimeMillis(); Long zxDate= System.currentTimeMillis();
shopZxMapper.zxadd(zxUrl,zxField,zxAddress,inviteCode, zxDate); shopZxMapper.zxadd(zxUrl,zxField,inviteCode, zxDate);
return resultMap; return resultMap;
} }
...@@ -108,7 +108,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -108,7 +108,7 @@ public class UploadServiceImpl implements UploadService {
* 图片文件上传 * 图片文件上传
*/ */
@Override @Override
public Map<String, Object> uploadImage(MultipartFile file) throws Exception { public Map<String, Object> uploadImage(MultipartFile file,String inviteCode) throws Exception {
Map<String, Object> resultMap=new HashMap<String, Object>(); Map<String, Object> resultMap=new HashMap<String, Object>();
/** /**
...@@ -137,6 +137,8 @@ public class UploadServiceImpl implements UploadService { ...@@ -137,6 +137,8 @@ public class UploadServiceImpl implements UploadService {
newFile.getParentFile().mkdirs(); newFile.getParentFile().mkdirs();
} }
User user=usersMapper.InvitedCode2(inviteCode);
String userId=user.getUserId();
//将内存中的数据写入磁盘 //将内存中的数据写入磁盘
file.transferTo(newFile); file.transferTo(newFile);
//图片上传保存url //图片上传保存url
...@@ -144,7 +146,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -144,7 +146,7 @@ public class UploadServiceImpl implements UploadService {
resultMap.put("zxUrl", zxUrl); resultMap.put("zxUrl", zxUrl);
resultMap.put("returnCode", 0); resultMap.put("returnCode", 0);
shopZxMapper.zxadd1(zxUrl, zxDate); shopZxMapper.zxadd1(zxUrl,userId);
return resultMap; return resultMap;
} }
...@@ -152,12 +154,11 @@ public class UploadServiceImpl implements UploadService { ...@@ -152,12 +154,11 @@ public class UploadServiceImpl implements UploadService {
* 多图片 * 多图片
* @param files * @param files
* @param zxField * @param zxField
* @param zxAddress
* @param inviteCode * @param inviteCode
* @return * @return
*/ */
@Override @Override
public List imageUpload(MultipartFile[] files, String zxField, String zxAddress,String inviteCode) { public List imageUpload(MultipartFile[] files, String zxField, String inviteCode) {
//获取上传图片数量,打印在控制台 //获取上传图片数量,打印在控制台
System.out.println("上传图片数量" + files.length); System.out.println("上传图片数量" + files.length);
String zxUrl = new String(); String zxUrl = new String();
...@@ -210,7 +211,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -210,7 +211,7 @@ public class UploadServiceImpl implements UploadService {
* 生成当前时间戳 * 生成当前时间戳
*/ */
Long zxDate= Long.valueOf(System.currentTimeMillis()); Long zxDate= Long.valueOf(System.currentTimeMillis());
shopZxMapper.zxadd(zxUrl,zxField,zxAddress,inviteCode, zxDate); shopZxMapper.zxadd(zxUrl,zxField,inviteCode, zxDate);
return root; return root;
} }
...@@ -273,14 +274,13 @@ public class UploadServiceImpl implements UploadService { ...@@ -273,14 +274,13 @@ public class UploadServiceImpl implements UploadService {
* 资讯文件展示 * 资讯文件展示
*/ */
@Override @Override
public Map selectPage(Integer pageNum, Integer pageSize) { public Map selectPage(Integer pageNum, Integer pageSize,String inviteCode) {
Map map = new HashMap(); Map map = new HashMap();
pageNum=pageNum-1; pageNum=pageNum-1;
List<zxUserDto> shopZxList = shopZxMapper.selectPage(pageNum,pageSize); List<zxUserDto> shopZxList = shopZxMapper.selectPage(pageNum,pageSize);
for (zxUserDto shopZx : shopZxList) { for (zxUserDto shopZx : shopZxList) {
String[] zxUrl = shopZx.getZxUrl().split(","); String[] zxUrl = shopZx.getZxUrl().split(",");
// List<String> strings = Arrays.asList(split);
ArrayList list =new ArrayList(); ArrayList list =new ArrayList();
if (null != zxUrl){ if (null != zxUrl){
for (String split:zxUrl) { for (String split:zxUrl) {
...@@ -290,9 +290,24 @@ public class UploadServiceImpl implements UploadService { ...@@ -290,9 +290,24 @@ public class UploadServiceImpl implements UploadService {
shopZx.setAskImgList(list); shopZx.setAskImgList(list);
} }
} }
shopZx.setUserId(shopZx.getUserId().replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"));
int likedId =shopZx.getZxid();
shopZx.setUserId(shopZx.getUserId().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
if(null!=inviteCode&&""!=inviteCode) {
//用户个人邀请码查询用户数据
User user=usersMapper.InvitedCode2(inviteCode);
String userLikeId=user.getUserId();
userLikes d = LikesMapper.selectlikes(userLikeId, likedId);
if (null == d) {
shopZx.setLikedStatus(0);
} else {
shopZx.setLikedStatus(1);
}
}
} }
map.put("data",shopZxList); map.put("data",shopZxList);
return map; return map;
......
...@@ -60,7 +60,7 @@ public class SmsController { ...@@ -60,7 +60,7 @@ public class SmsController {
//生成随机数 //生成随机数
String code= MathUtils.random(); String code= MathUtils.random();
//保存至Redis MINUTE_INT //保存至Redis MINUTE_INT
redisUtils.set(key,code,Constants.Duration.TEN_HOURS_HOUR_INT); redisUtils.set(key,code,Constants.Duration.MINUTE_INT);
boolean flag=smsUtils.sendMessage(phone,Constants.Sms.TemplateCode.LOGIN_SF_REGISTER,code); boolean flag=smsUtils.sendMessage(phone,Constants.Sms.TemplateCode.LOGIN_SF_REGISTER,code);
return (flag? ResultUtils.returnSuccess():ResultUtils.returnFail()); return (flag? ResultUtils.returnSuccess():ResultUtils.returnFail());
......
...@@ -46,7 +46,6 @@ public class UploadController { ...@@ -46,7 +46,6 @@ public class UploadController {
* @param file * @param file
* @param request * @param request
* @param zxField * @param zxField
* @param zxAddress
* @return * @return
* @throws Exception * @throws Exception
*/ */
...@@ -57,25 +56,22 @@ public class UploadController { ...@@ -57,25 +56,22 @@ public class UploadController {
@ApiImplicitParam(name = "zxAddress", value = "资讯发布地址", dataType = "String"), @ApiImplicitParam(name = "zxAddress", value = "资讯发布地址", dataType = "String"),
@ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = true, dataType = "String")}) @ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = true, dataType = "String")})
@RequestMapping(value = "/uploadVideo", method = RequestMethod.POST) @RequestMapping(value = "/uploadVideo", method = RequestMethod.POST)
public Map<String, Object> uploadVideo(@RequestParam(value = "files")MultipartFile file, HttpServletRequest request, String zxField, String zxAddress,String inviteCode) throws Exception { public Map<String, Object> uploadVideo(@RequestParam(value = "files")MultipartFile file, HttpServletRequest request, String zxField, String inviteCode) throws Exception {
return uploadService.uploadVideo(file, request, zxField, zxAddress,inviteCode); return uploadService.uploadVideo(file, request, zxField,inviteCode);
} }
/** /**
* TODO 用户头像上传 * TODO 用户头像上传/更新头像接口
* *
* @param * @param
* @return * @return
* @throws Exception * @throws Exception
*/ */
@ApiOperation(value = "用户头像上传接口", notes = "返回路径给前台", httpMethod = "POST", produces = "application/json; charset=UTF-8") @ApiOperation(value = "用户头像上传接口", notes = "返回路径给前台", httpMethod = "POST", produces = "application/json; charset=UTF-8")
@ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "单图片", dataType = "MultipartFile")
@ApiImplicitParam(name = "file", value = "单图片", dataType = "MultipartFile"),
@ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = true, dataType = "String")})
@RequestMapping(value = "/uploadImage", method = RequestMethod.POST) @RequestMapping(value = "/uploadImage", method = RequestMethod.POST)
public Map<String, Object> uploadImage(@RequestParam(value = "files")MultipartFile file) throws Exception { public Map<String, Object> uploadImage(@RequestParam(value = "files")MultipartFile file,String inviteCode) throws Exception {
return uploadService.uploadImage(file,inviteCode);
return uploadService.uploadImage(file);
} }
...@@ -91,12 +87,11 @@ public class UploadController { ...@@ -91,12 +87,11 @@ public class UploadController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "zxField", value = "资讯文字", dataType = "String"), @ApiImplicitParam(name = "zxField", value = "资讯文字", dataType = "String"),
@ApiImplicitParam(name = "files", value = "多图片", paramType = "form", allowMultiple=true, dataType = "__file"), @ApiImplicitParam(name = "files", value = "多图片", paramType = "form", allowMultiple=true, dataType = "__file"),
@ApiImplicitParam(name = "zxAddress", value = "发表地址", dataType = "String"),
@ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = true, dataType = "String")}) @ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = true, dataType = "String")})
@RequestMapping(method = RequestMethod.POST, value = "/multipleImageUpload", headers = "content-type=multipart/form-data") @RequestMapping(method = RequestMethod.POST, value = "/multipleImageUpload", headers = "content-type=multipart/form-data")
public List multipleImageUpload(@RequestParam(required=false,value = "files") MultipartFile[] files, String zxField, String zxAddress,String inviteCode) { public List multipleImageUpload(@RequestParam(required=false,value = "files") MultipartFile[] files, String zxField,String inviteCode) {
return uploadService.imageUpload(files, zxField, zxAddress,inviteCode); return uploadService.imageUpload(files, zxField,inviteCode);
} }
...@@ -108,11 +103,12 @@ public class UploadController { ...@@ -108,11 +103,12 @@ public class UploadController {
*/ */
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "从几开始", required = true,dataType = "integer"), @ApiImplicitParam(name = "pageNum", value = "从几开始", required = true,dataType = "integer"),
@ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = false, dataType = "String"),
@ApiImplicitParam(name = "pageSize", value = "一页展示数量", required = true, dataType = "Integger")}) @ApiImplicitParam(name = "pageSize", value = "一页展示数量", required = true, dataType = "Integger")})
@RequestMapping(method = RequestMethod.GET, value = "/zxAll") @RequestMapping(method = RequestMethod.GET, value = "/zxAll")
public Map selectPage(int pageNum, int pageSize){ public Map selectPage(int pageNum, int pageSize,String inviteCode){
return uploadService.selectPage(pageNum,pageSize); return uploadService.selectPage(pageNum,pageSize,inviteCode);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment