Commit 2384de30 authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/master'

parents 5c29dae1 7b4b313c
package com.wwdz.ch.core.captcha; package com.wwdz.ch.core.captcha;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
import java.util.*;
import java.util.Map.Entry;
/** /**
* 缓存系统中的验证码 * 缓存系统中的验证码
*/ */
...@@ -97,4 +93,8 @@ public class CaptchaCodeManager { ...@@ -97,4 +93,8 @@ public class CaptchaCodeManager {
} }
} }
public static void removeCacheData(String flagUid) {
captchaCodeCache.remove(flagUid);
}
} }
...@@ -7,14 +7,32 @@ public interface CategoryDao { ...@@ -7,14 +7,32 @@ public interface CategoryDao {
List<Category> queryByLevel(Integer level, Integer offset, Integer limit); List<Category> queryByLevel(Integer level, Integer offset, Integer limit);
/**
* 通过level查询未删除的分类列表
*
* @param level
* @return
*/
List<Category> listByLevel(Integer level); List<Category> listByLevel(Integer level);
List<Category> queryByPid(Integer pid); List<Category> queryByPid(Integer pid);
Category findById(Integer id); Category findById(Integer id);
/**
* 通过名称精确查询未删除的分类
*
* @param name
* @return
*/
Category findByName(String name); Category findByName(String name);
/**
* 通过名称模糊查询未删除的分类列表
*
* @param name
* @return
*/
List<Category> queryByName(String name); List<Category> queryByName(String name);
List<Category> querySelective(String id, String name, Integer page, Integer size, String sort, String order); List<Category> querySelective(String id, String name, Integer page, Integer size, String sort, String order);
......
...@@ -6,13 +6,80 @@ import com.wwdz.ch.db.domain.Favorites; ...@@ -6,13 +6,80 @@ import com.wwdz.ch.db.domain.Favorites;
import java.util.List; import java.util.List;
public interface FavoritesDao { public interface FavoritesDao {
/**
* 插入新记录
*
* @param record
* @return
*/
int insert(Favorites record); int insert(Favorites record);
/**
* 删除记录
*
* @param id
* @return
*/
int delete(Long id); int delete(Long id);
/**
* 更新记录
*
* @param record
* @return
*/
int update(Favorites record); int update(Favorites record);
/**
* 通过id查询单条记录
*
* @param id
* @return
*/
Favorites info(Long id); Favorites info(Long id);
/**
* 通过用户id查询列表
*
* @param userId
* @return
*/
List<Favorites> listByUserId(Long userId); List<Favorites> listByUserId(Long userId);
/**
* 通过用户id分页查询
*
* @param userId
* @param page
* @param size
* @return
*/
PageInfo<Favorites> pageByUserId(Long userId, int page, int size); PageInfo<Favorites> pageByUserId(Long userId, int page, int size);
/**
* 判断是否存在相同title的记录(排除自己)
*
* @param id
* @param userId
* @param title
* @return
*/
boolean isExisted(Long id, Long userId, String title); boolean isExisted(Long id, Long userId, String title);
/**
* 批量删除记录
*
* @param id
* @param ids
* @return
*/
int delete(Long id, List<Long> ids); int delete(Long id, List<Long> ids);
/**
* 通过用户id获取默认的收藏册记录
*
* @param userId
* @return
*/
Favorites defaultFavorites(Long userId); Favorites defaultFavorites(Long userId);
} }
...@@ -8,17 +8,114 @@ import java.util.List; ...@@ -8,17 +8,114 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface FavoritesItemsRelationDao { public interface FavoritesItemsRelationDao {
/**
* 插入新纪录
*
* @param record
* @return
*/
int insert(FavoritesItemsRelation record); int insert(FavoritesItemsRelation record);
/**
* 批量插入新纪录
*
* @param list
* @return
*/
int batchInsert(List<FavoritesItemsRelation> list); int batchInsert(List<FavoritesItemsRelation> list);
/**
* 通过收藏册id批量删除记录
*
* @param favoritesId
* @param favoritesIds
* @return
*/
int deleteByFavoritesId(Long favoritesId, List<Long> favoritesIds); int deleteByFavoritesId(Long favoritesId, List<Long> favoritesIds);
/**
* 通过收藏册id和藏品id列表删除对应的记录
*
* @param favoritesId
* @param itemIds
* @return
*/
int deleteByChosen(Long favoritesId, List<Long> itemIds); int deleteByChosen(Long favoritesId, List<Long> itemIds);
/**
* 通过用户id和藏品id删除对应的记录
*
* @param userId
* @param itemId
* @return
*/
int deleteByUserIdItemId(Long userId, Long itemId); int deleteByUserIdItemId(Long userId, Long itemId);
/**
* 通过收藏册id查询列表
*
* @param favoritesId
* @param favoritesIds
* @return
*/
List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds); List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds);
/**
* 通过用户id和藏品id获取对应的记录
*
* @param userId
* @param itemId
* @return
*/
FavoritesItemsRelation selectByUserIdItemId(Long userId, Long itemId); FavoritesItemsRelation selectByUserIdItemId(Long userId, Long itemId);
/**
* 通过收藏册id分页查询
*
* @param favoritesId
* @param page
* @param size
* @return
*/
PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size); PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size);
/**
* 通过藏品id统计记录数
*
* @param itemId
* @return
*/
long countByItemId(Long itemId); long countByItemId(Long itemId);
/**
* 判断是否已经存在用户id和藏品id对应的记录
*
* @param userId
* @param itemId
* @return
*/
boolean isCollected(Long userId, Long itemId); boolean isCollected(Long userId, Long itemId);
/**
* 通过收藏册id统计记录数
*
* @param favoritesId
* @return
*/
long countByFavoritesId(Long favoritesId); long countByFavoritesId(Long favoritesId);
/**
* 通过藏品id分组统计记录数量最多的20条记录
*
* @return
*/
List<Map<String, Object>> findItemIdByCount(); List<Map<String, Object>> findItemIdByCount();
/**
* 连表查询获取藏品的图片
*
* @param favoritesId
* @return
*/
List<FavoritesItemsDto> queryItemImages(Long favoritesId); List<FavoritesItemsDto> queryItemImages(Long favoritesId);
} }
...@@ -5,11 +5,62 @@ import com.wwdz.ch.db.domain.Footprint; ...@@ -5,11 +5,62 @@ import com.wwdz.ch.db.domain.Footprint;
import java.util.List; import java.util.List;
public interface FootPrintDao { public interface FootPrintDao {
/**
* 通过用户id查询列表
*
* @param userId
* @return
*/
List<Footprint> listByUserId(Long userId); List<Footprint> listByUserId(Long userId);
/**
* 通过用户id分页查询
*
* @param userId
* @param page
* @param size
* @return
*/
List<Footprint> pageByUserId(Long userId, Integer page, Integer size); List<Footprint> pageByUserId(Long userId, Integer page, Integer size);
/**
* 通过用户id统计记录数
*
* @param userId
* @return
*/
long countByUserId(Long userId); long countByUserId(Long userId);
/**
* 批量删除记录
*
* @param ids
* @return
*/
int delete(List<Long> ids); int delete(List<Long> ids);
/**
* 通过用户id和藏品id获取对应的记录
*
* @param userId
* @param itemId
* @return
*/
Footprint selectByUserIdItem(Long userId, Long itemId); Footprint selectByUserIdItem(Long userId, Long itemId);
/**
* 插入新记录
*
* @param footprint
* @return
*/
int insert(Footprint footprint); int insert(Footprint footprint);
/**
* 更新记录时间
*
* @param footprint
* @return
*/
int upateTime(Footprint footprint); int upateTime(Footprint footprint);
} }
...@@ -13,6 +13,12 @@ public interface ItemDao { ...@@ -13,6 +13,12 @@ public interface ItemDao {
List<Item> findList(CoinRequestDto coinRequestDto); List<Item> findList(CoinRequestDto coinRequestDto);
/**
* 获取未删除的列表
*
* @param coinRequestDto
* @return
*/
List<Item> findListNotDeleted(CoinRequestDto coinRequestDto); List<Item> findListNotDeleted(CoinRequestDto coinRequestDto);
List<Item> findListByPage(CoinRequestDto coinRequestDto); List<Item> findListByPage(CoinRequestDto coinRequestDto);
......
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.Keyword;
import java.util.List;
public interface KeywordDao {
List<Keyword> findList();
}
...@@ -3,19 +3,70 @@ package com.wwdz.ch.db.dao; ...@@ -3,19 +3,70 @@ package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.User; import com.wwdz.ch.db.domain.User;
public interface UserDao { public interface UserDao {
/**
* 通过oid查询未删除的记录
*
* @param openId
* @return
*/
User queryByOid(String openId); User queryByOid(String openId);
/**
* 通过手机号查询未删除的记录
*
* @param mobile
* @return
*/
User queryByMobile(String mobile); User queryByMobile(String mobile);
/**
* 通过id查询未删除的记录
*
* @param id
* @return
*/
User queryById(Long id); User queryById(Long id);
/**
* 判断是否已存在相同昵称的记录
*
* @param userId
* @param nickname
* @return
*/
boolean isExistedByNickname(Long userId, String nickname); boolean isExistedByNickname(Long userId, String nickname);
/**
* 判断是否已存在相同微信号的记录
*
* @param userId
* @param wechatId
* @return
*/
boolean isExistedByWechatId(Long userId, String wechatId); boolean isExistedByWechatId(Long userId, String wechatId);
/**
* 插入新记录
*
* @param user
* @return
*/
int insert(User user); int insert(User user);
/**
* 更新记录
*
* @param user
* @return
*/
int updateById(User user); int updateById(User user);
/**
* 判断手机号是否已经存在
*
* @param beforeMobile
* @param afterMobile
* @return
*/
boolean isExistedByMobile(String beforeMobile, String afterMobile); boolean isExistedByMobile(String beforeMobile, String afterMobile);
} }
...@@ -5,8 +5,37 @@ import com.wwdz.ch.db.domain.UserItemsRelation; ...@@ -5,8 +5,37 @@ import com.wwdz.ch.db.domain.UserItemsRelation;
import java.util.List; import java.util.List;
public interface UserItemsRelationDao { public interface UserItemsRelationDao {
/**
* 插入新记录
*
* @param record
* @return
*/
int insert(UserItemsRelation record); int insert(UserItemsRelation record);
/**
* 通过用户id查询列表
*
* @param userId
* @param userIds
* @return
*/
List<UserItemsRelation> listByUserIds(Long userId, List<Long> userIds); List<UserItemsRelation> listByUserIds(Long userId, List<Long> userIds);
/**
* 判断是否已存在用户id和藏品id对应的记录
*
* @param userId
* @param itemId
* @return
*/
boolean isExisted(Long userId, Long itemId); boolean isExisted(Long userId, Long itemId);
/**
* 通过藏品id获取单条记录
*
* @param itemId
* @return
*/
UserItemsRelation find(Long itemId); UserItemsRelation find(Long itemId);
} }
package com.wwdz.ch.db.impl;
import com.wwdz.ch.db.dao.KeywordDao;
import com.wwdz.ch.db.domain.Keyword;
import com.wwdz.ch.db.domain.KeywordExample;
import com.wwdz.ch.db.mapper.KeywordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class KeywordDaoImpl implements KeywordDao {
@Autowired
private KeywordMapper keywordMapper;
@Override
public List<Keyword> findList() {
KeywordExample example = new KeywordExample();
example.or().andDeletedEqualTo(false);
return keywordMapper.selectByExample(example);
}
}
...@@ -704,9 +704,7 @@ ...@@ -704,9 +704,7 @@
<select id="selectNameByExample" parameterType="com.wwdz.ch.db.domain.ItemExample" resultMap="StringResultMap"> <select id="selectNameByExample" parameterType="com.wwdz.ch.db.domain.ItemExample" resultMap="StringResultMap">
select select
<if test="distinct">
distinct distinct
</if>
name name
from item from item
<if test="_parameter != null"> <if test="_parameter != null">
......
...@@ -31,7 +31,8 @@ public class WebMvcConfiguration implements WebMvcConfigurer { ...@@ -31,7 +31,8 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/*.html", "/**/*.html", "/**/*.css", "/**/*.js" .excludePathPatterns("/*.html", "/**/*.html", "/**/*.css", "/**/*.js"
, "/wx/user/loginByWx", "/wx/user/loginByMobile", "/wx/user/loginRegCaptcha", "/wx/user/updateRegCaptcha" , "/wx/user/loginByWx", "/wx/user/loginByMobile", "/wx/user/loginRegCaptcha", "/wx/user/updateRegCaptcha"
, "/wx/item/page", "/wx/item/info", "/wx/item/findNames", "/wx/item/recommend" , "/wx/item/page", "/wx/item/info", "/wx/item/findNames"
, "/wx/favorites/info", "/wx/favorites/itemList"); , "/wx/favorites/info", "/wx/favorites/itemList"
, "/wx/keyword/recommend");
} }
} }
...@@ -122,6 +122,12 @@ public class CategoryServiceImpl implements CategoryService { ...@@ -122,6 +122,12 @@ public class CategoryServiceImpl implements CategoryService {
return root.getChild(); return root.getChild();
} }
/**
* 实体转换
*
* @param category
* @return
*/
private CategoryResponseVo toCategoryResponseVo(Category category) { private CategoryResponseVo toCategoryResponseVo(Category category) {
CategoryResponseVo vo = new CategoryResponseVo(); CategoryResponseVo vo = new CategoryResponseVo();
vo.setCid(category.getId()); vo.setCid(category.getId());
......
...@@ -255,6 +255,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -255,6 +255,7 @@ public class FavoritesServiceImpl implements FavoritesService {
vo.setName(item.getName()); vo.setName(item.getName());
vo.setImages(item.getImages()); vo.setImages(item.getImages());
vo.setDetail(item.getDetail()); vo.setDetail(item.getDetail());
vo.setFavoritesId(dto.getId());
// 设置价格 // 设置价格
vo.setPrice(getPrice(item.getPrice())); vo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的 // 设置是否收藏或是否是自己发布的
...@@ -290,6 +291,13 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -290,6 +291,13 @@ public class FavoritesServiceImpl implements FavoritesService {
if (CollectionUtils.isNotEmpty(favoritesItemsList)) { if (CollectionUtils.isNotEmpty(favoritesItemsList)) {
return Result.failed("收藏册内有藏品,请先移除藏品"); return Result.failed("收藏册内有藏品,请先移除藏品");
} }
Favorites favorites = favoritesDao.info(dto.getId());
if (Objects.isNull(favorites)) {
return Result.failed("数据异常,收藏册不存在");
}
if (1 == favorites.getSort()) {
return Result.failed("无法删除默认收藏册");
}
// 删除收藏册 // 删除收藏册
favoritesDao.delete(dto.getId(), null); favoritesDao.delete(dto.getId(), null);
...@@ -427,19 +435,18 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -427,19 +435,18 @@ public class FavoritesServiceImpl implements FavoritesService {
} }
} }
/**
* 获取展示图片
*
* @param item
* @return
*/
private Map<String, Object> getImage(Item item) { private Map<String, Object> getImage(Item item) {
Map<String, Object> homePageMap = new HashMap<>(); Map<String, Object> homePageMap = new HashMap<>();
homePageMap.put("url", ""); homePageMap.put("url", "");
homePageMap.put("type", 2); homePageMap.put("type", 2);
homePageMap.put("width", "0"); homePageMap.put("width", "0");
homePageMap.put("height", "0"); homePageMap.put("height", "0");
if (StringUtils.isNotBlank(item.getTopImage())) {
if (item.getTopImage().contains("_")) {
homePageMap = getImageMap(item.getTopImage());
homePageMap.put("url", item.getTopImage());
homePageMap.put("type", 2);
}
} else {
if (StringUtils.isNotBlank(item.getImages())) { if (StringUtils.isNotBlank(item.getImages())) {
String[] image = item.getImages().split(";"); String[] image = item.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
...@@ -449,7 +456,6 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -449,7 +456,6 @@ public class FavoritesServiceImpl implements FavoritesService {
homePageMap.put("type", 2); homePageMap.put("type", 2);
} }
} }
}
if (StringUtils.isNotBlank(item.getVideos())) { if (StringUtils.isNotBlank(item.getVideos())) {
String[] vedioImage = item.getVideos().split(";"); String[] vedioImage = item.getVideos().split(";");
if (vedioImage[0].contains(",")) { if (vedioImage[0].contains(",")) {
...@@ -462,6 +468,12 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -462,6 +468,12 @@ public class FavoritesServiceImpl implements FavoritesService {
return homePageMap; return homePageMap;
} }
/**
* 获取图片的长宽
*
* @param image
* @return
*/
private Map<String, Object> getImageMap(String image) { private Map<String, Object> getImageMap(String image) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_"); String[] _image = image.split("_");
...@@ -472,6 +484,13 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -472,6 +484,13 @@ public class FavoritesServiceImpl implements FavoritesService {
return map; return map;
} }
/**
* 获取藏品的收藏数
*
* @param itemId
* @param sourceType
* @return
*/
private String getCollectCount(Long itemId, Integer sourceType) { private String getCollectCount(Long itemId, Integer sourceType) {
String countString = ""; String countString = "";
// 设置收藏数 // 设置收藏数
...@@ -487,6 +506,13 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -487,6 +506,13 @@ public class FavoritesServiceImpl implements FavoritesService {
return countString; return countString;
} }
/**
* 获取格式化后的金额
*
* @param price
* @return
*/
private String getPrice(Long price) { private String getPrice(Long price) {
String priceString = ""; String priceString = "";
if (price % 100 == 0) { if (price % 100 == 0) {
...@@ -497,30 +523,28 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -497,30 +523,28 @@ public class FavoritesServiceImpl implements FavoritesService {
return StringUtil.formatAmount(priceString); return StringUtil.formatAmount(priceString);
} }
/**
* 获取收藏册封面图
*
* @param id
* @return
*/
private List<String> getFavoritesImage(Long id) { private List<String> getFavoritesImage(Long id) {
List<String> images = new ArrayList<>(); List<String> images = new ArrayList<>();
List<FavoritesItemsDto> favoritesItemsDtos = favoritesItemsRelationDao.queryItemImages(id); List<FavoritesItemsDto> favoritesItemsDtos = favoritesItemsRelationDao.queryItemImages(id);
if (CollectionUtils.isNotEmpty(favoritesItemsDtos)) { if (CollectionUtils.isNotEmpty(favoritesItemsDtos)) {
if (favoritesItemsDtos.size() <= 4) { if (favoritesItemsDtos.size() <= 4) {
for (FavoritesItemsDto favoritesItemsDto : favoritesItemsDtos) { for (FavoritesItemsDto favoritesItemsDto : favoritesItemsDtos) {
if (StringUtils.isNotBlank(favoritesItemsDto.getTopImage())) {
images.add(favoritesItemsDto.getTopImage());
} else {
String[] image = favoritesItemsDto.getImages().split(";"); String[] image = favoritesItemsDto.getImages().split(";");
images.add(image[0]); images.add(image[0]);
} }
}
} else { } else {
for (int i = 0; i < 4; i ++) { for (int i = 0; i < 4; i ++) {
if (StringUtils.isNotBlank(favoritesItemsDtos.get(i).getTopImage())) {
images.add(favoritesItemsDtos.get(i).getTopImage());
} else {
String[] image = favoritesItemsDtos.get(i).getImages().split(";"); String[] image = favoritesItemsDtos.get(i).getImages().split(";");
images.add(image[0]); images.add(image[0]);
} }
} }
} }
}
return images; return images;
} }
} }
...@@ -136,6 +136,8 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -136,6 +136,8 @@ public class FootPrintServiceImpl implements FootPrintService {
monthVo.setTimeType(4); monthVo.setTimeType(4);
monthVo.setItems(monthList); monthVo.setItems(monthList);
result.add(monthVo); result.add(monthVo);
logger.info("【请求结束】用户足迹列表查询成功");
return Result.success(result); return Result.success(result);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询用户足迹列表失败", e); logger.error("查询用户足迹列表失败", e);
...@@ -253,9 +255,11 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -253,9 +255,11 @@ public class FootPrintServiceImpl implements FootPrintService {
result.add(monthVo); result.add(monthVo);
map.put("dataList", result); map.put("dataList", result);
logger.info("【请求结束】用户足迹分页查询成功");
return Result.success(map); return Result.success(map);
} catch (Exception e) { } catch (Exception e) {
logger.error("分页查询用户足迹列表失败", e); logger.error("用户足迹分页查询", e);
return Result.failed("查询失败"); return Result.failed("查询失败");
} }
} }
...@@ -265,26 +269,26 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -265,26 +269,26 @@ public class FootPrintServiceImpl implements FootPrintService {
public Result delete(FootPrintRequestDto dto) { public Result delete(FootPrintRequestDto dto) {
try { try {
footPrintDao.delete(dto.getIds()); footPrintDao.delete(dto.getIds());
logger.info("【请求结束】用户足迹删除成功");
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("删除用户足迹失败", e); logger.error("用户足迹删除失败", e);
return Result.failed("删除足迹失败"); return Result.failed("删除足迹失败");
} }
} }
/**
* 获取展示图片
*
* @param item
* @return
*/
private Map<String, Object> getImage(Item item) { private Map<String, Object> getImage(Item item) {
Map<String, Object> homePageMap = new HashMap<>(); Map<String, Object> homePageMap = new HashMap<>();
homePageMap.put("url", ""); homePageMap.put("url", "");
homePageMap.put("type", 2); homePageMap.put("type", 2);
homePageMap.put("width", "0"); homePageMap.put("width", "0");
homePageMap.put("height", "0"); homePageMap.put("height", "0");
if (StringUtils.isNotBlank(item.getTopImage())) {
if (item.getTopImage().contains("_")) {
homePageMap = getImageMap(item.getTopImage());
homePageMap.put("url", item.getTopImage());
homePageMap.put("type", 2);
}
} else {
if (StringUtils.isNotBlank(item.getImages())) { if (StringUtils.isNotBlank(item.getImages())) {
String[] image = item.getImages().split(";"); String[] image = item.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
...@@ -294,7 +298,6 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -294,7 +298,6 @@ public class FootPrintServiceImpl implements FootPrintService {
homePageMap.put("type", 2); homePageMap.put("type", 2);
} }
} }
}
if (StringUtils.isNotBlank(item.getVideos())) { if (StringUtils.isNotBlank(item.getVideos())) {
String[] vedioImage = item.getVideos().split(";"); String[] vedioImage = item.getVideos().split(";");
if (vedioImage[0].contains(",")) { if (vedioImage[0].contains(",")) {
...@@ -307,6 +310,12 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -307,6 +310,12 @@ public class FootPrintServiceImpl implements FootPrintService {
return homePageMap; return homePageMap;
} }
/**
* 获取图片的长宽
*
* @param image
* @return
*/
private Map<String, Object> getImageMap(String image) { private Map<String, Object> getImageMap(String image) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_"); String[] _image = image.split("_");
...@@ -317,6 +326,13 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -317,6 +326,13 @@ public class FootPrintServiceImpl implements FootPrintService {
return map; return map;
} }
/**
* 获取藏品的收藏数
*
* @param itemId
* @param sourceType
* @return
*/
private String getCollectCount(Long itemId, Integer sourceType) { private String getCollectCount(Long itemId, Integer sourceType) {
String countString = ""; String countString = "";
// 设置收藏数 // 设置收藏数
...@@ -332,6 +348,12 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -332,6 +348,12 @@ public class FootPrintServiceImpl implements FootPrintService {
return countString; return countString;
} }
/**
* 获取格式化后的金额
*
* @param price
* @return
*/
private String getPrice(Long price) { private String getPrice(Long price) {
String priceString = ""; String priceString = "";
if (price % 100 == 0) { if (price % 100 == 0) {
......
...@@ -81,27 +81,6 @@ public class ItemServiceImpl implements ItemService { ...@@ -81,27 +81,6 @@ public class ItemServiceImpl implements ItemService {
} }
} }
@Override
public Result recommend() {
try {
List<Map<String, Object>> list = favoritesItemsRelationDao.findItemIdByCount();
if (CollectionUtils.isEmpty(list)) {
return Result.success();
}
Random random = new Random();
int index = random.nextInt(20);
Long itemId = (Long) list.get(index).get("item_id");
Item item = itemDao.findDetails(itemId);
Map<String, Object> map = new HashMap<>();
map.put("name", item.getName());
return Result.success(map);
} catch (Exception e) {
logger.error("搜索推荐失败", e);
return Result.failed("搜索推荐失败");
}
}
@Override @Override
public Result page(ItemRequestDto dto) { public Result page(ItemRequestDto dto) {
try { try {
...@@ -547,19 +526,18 @@ public class ItemServiceImpl implements ItemService { ...@@ -547,19 +526,18 @@ public class ItemServiceImpl implements ItemService {
return null; return null;
} }
/**
* 获取展示图片
*
* @param es
* @return
*/
private Map<String, Object> getImage(ItemOfEs es) { private Map<String, Object> getImage(ItemOfEs es) {
Map<String, Object> homePageMap = new HashMap<>(); Map<String, Object> homePageMap = new HashMap<>();
homePageMap.put("url", ""); homePageMap.put("url", "");
homePageMap.put("type", 2); homePageMap.put("type", 2);
homePageMap.put("width", "0"); homePageMap.put("width", "0");
homePageMap.put("height", "0"); homePageMap.put("height", "0");
if (StringUtils.isNotBlank(es.getTopImage())) {
if (es.getTopImage().contains("_")) {
homePageMap = getImageMap(es.getTopImage());
homePageMap.put("url", es.getTopImage());
homePageMap.put("type", 2);
}
} else {
if (StringUtils.isNotBlank(es.getImages())) { if (StringUtils.isNotBlank(es.getImages())) {
String[] image = es.getImages().split(";"); String[] image = es.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
...@@ -569,7 +547,6 @@ public class ItemServiceImpl implements ItemService { ...@@ -569,7 +547,6 @@ public class ItemServiceImpl implements ItemService {
homePageMap.put("type", 2); homePageMap.put("type", 2);
} }
} }
}
if (StringUtils.isNotBlank(es.getVideos())) { if (StringUtils.isNotBlank(es.getVideos())) {
String[] vedioImage = es.getVideos().split(";"); String[] vedioImage = es.getVideos().split(";");
if (vedioImage[0].contains(",")) { if (vedioImage[0].contains(",")) {
...@@ -582,6 +559,12 @@ public class ItemServiceImpl implements ItemService { ...@@ -582,6 +559,12 @@ public class ItemServiceImpl implements ItemService {
return homePageMap; return homePageMap;
} }
/**
* 获取图片的长宽
*
* @param image
* @return
*/
private Map<String, Object> getImageMap(String image) { private Map<String, Object> getImageMap(String image) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_"); String[] _image = image.split("_");
...@@ -592,6 +575,13 @@ public class ItemServiceImpl implements ItemService { ...@@ -592,6 +575,13 @@ public class ItemServiceImpl implements ItemService {
return map; return map;
} }
/**
* 获取藏品的收藏数
*
* @param itemId
* @param sourceType
* @return
*/
private String getCollectCount(Long itemId, Integer sourceType) { private String getCollectCount(Long itemId, Integer sourceType) {
String countString = ""; String countString = "";
// 设置收藏数 // 设置收藏数
...@@ -607,6 +597,12 @@ public class ItemServiceImpl implements ItemService { ...@@ -607,6 +597,12 @@ public class ItemServiceImpl implements ItemService {
return countString; return countString;
} }
/**
* 获取格式化后的金额
*
* @param price
* @return
*/
private String getPrice(Long price) { private String getPrice(Long price) {
String priceString = ""; String priceString = "";
if (price % 100 == 0) { if (price % 100 == 0) {
......
package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.KeywordDao;
import com.wwdz.ch.db.domain.Keyword;
import com.wwdz.ch.wx.service.KeywordService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class KeywordServiceImpl implements KeywordService {
private static final Logger logger = LoggerFactory.getLogger(KeywordServiceImpl.class);
@Autowired
private KeywordDao keywordDao;
@Override
public Result recommend() {
try {
List<String> result = new ArrayList<>();
List<Keyword> list = keywordDao.findList();
if (CollectionUtils.isNotEmpty(list)) {
result = list.stream().map(Keyword::getKeyword).collect(Collectors.toList());
}
logger.info("【请求结束】搜索词推荐成功");
return Result.success(result);
} catch (Exception e) {
logger.error("查询搜索词推荐失败", e);
return Result.failed("查询搜素词推荐失败");
}
}
}
...@@ -213,6 +213,9 @@ public class UserServiceImpl implements UserService { ...@@ -213,6 +213,9 @@ public class UserServiceImpl implements UserService {
public Result loginByMobile(UserRequestDto dto, HttpServletRequest request) { public Result loginByMobile(UserRequestDto dto, HttpServletRequest request) {
try { try {
String mobileCode = CaptchaCodeManager.getCachedCaptcha(CacheCodeConstants.SmsTypeEnum.LOGIN.getCode() + dto.getMobile()); String mobileCode = CaptchaCodeManager.getCachedCaptcha(CacheCodeConstants.SmsTypeEnum.LOGIN.getCode() + dto.getMobile());
if (StringUtils.isBlank(mobileCode)) {
return Result.failed("验证码已过期");
}
if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) { if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) {
return Result.failed("验证码不正确"); return Result.failed("验证码不正确");
} }
...@@ -390,6 +393,9 @@ public class UserServiceImpl implements UserService { ...@@ -390,6 +393,9 @@ public class UserServiceImpl implements UserService {
return Result.failed("原手机号码不正确"); return Result.failed("原手机号码不正确");
} }
String mobileCode = CaptchaCodeManager.getCachedCaptcha(CacheCodeConstants.SmsTypeEnum.UPDATE.getCode() + dto.getAfterMobile()); String mobileCode = CaptchaCodeManager.getCachedCaptcha(CacheCodeConstants.SmsTypeEnum.UPDATE.getCode() + dto.getAfterMobile());
if (StringUtils.isBlank(mobileCode)) {
return Result.failed("验证码已过期");
}
if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) { if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) {
return Result.failed("验证码不正确"); return Result.failed("验证码不正确");
} }
......
package com.wwdz.ch.wx.manager;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import com.wwdz.ch.wx.dao.CaptchaItem;
/**
* 缓存系统中的验证码
*/
public class CaptchaCodeManager {
private static Map<String, CaptchaItem> captchaCodeCache = new HashMap<>();
/**
* 添加到缓存
*
* @param phoneNumber
* 电话号码
* @param code
* 验证码
*/
public static boolean addToCache(String phoneNumber, String code) {
// 已经发过验证码且验证码还未过期
if (captchaCodeCache.get(phoneNumber) != null) {
if (captchaCodeCache.get(phoneNumber).getExpireTime().isAfter(LocalDateTime.now())) {
return false;
} else {
// 存在但是已过期,删掉
captchaCodeCache.remove(phoneNumber);
}
}
CaptchaItem captchaItem = new CaptchaItem();
captchaItem.setPhoneNumber(phoneNumber);
captchaItem.setCode(code);
// 有效期为1分钟
captchaItem.setExpireTime(LocalDateTime.now().plusMinutes(1));
captchaCodeCache.put(phoneNumber, captchaItem);
return true;
}
/**
* 获取缓存的验证码
*
* @param phoneNumber
* 关联的电话号码
* @return 验证码
*/
public static String getCachedCaptcha(String phoneNumber) {
// 没有这个电话记录
if (captchaCodeCache.get(phoneNumber) == null)
return null;
// 有电话记录但是已经过期
if (captchaCodeCache.get(phoneNumber).getExpireTime().isBefore(LocalDateTime.now())) {
return null;
}
return captchaCodeCache.get(phoneNumber).getCode();
}
}
...@@ -29,6 +29,7 @@ public class UserTokenManager { ...@@ -29,6 +29,7 @@ public class UserTokenManager {
private static final String TOKEN_ID_PREFIX = "token_id_prefix:"; private static final String TOKEN_ID_PREFIX = "token_id_prefix:";
private static Map<String, UserToken> tokenMap = new HashMap<>(); private static Map<String, UserToken> tokenMap = new HashMap<>();
private static Map<Long, UserToken> idMap = new HashMap<>(); private static Map<Long, UserToken> idMap = new HashMap<>();
private static long SURVIVAL_TIME = 86400;
public Long getUserId(String token) { public Long getUserId(String token) {
String key = TOKEN_PREFIX + token; String key = TOKEN_PREFIX + token;
...@@ -96,9 +97,9 @@ public class UserTokenManager { ...@@ -96,9 +97,9 @@ public class UserTokenManager {
userToken.setExpireTime(expire); userToken.setExpireTime(expire);
userToken.setUserId(id); userToken.setUserId(id);
String data = gson.toJson(userToken); String data = gson.toJson(userToken);
redisUtil.set(key, data); redisUtil.set(key, data, SURVIVAL_TIME);
String idKey = TOKEN_ID_PREFIX + id; String idKey = TOKEN_ID_PREFIX + id;
redisUtil.set(idKey, data); redisUtil.set(idKey, data, SURVIVAL_TIME);
return userToken; return userToken;
} }
......
...@@ -5,25 +5,99 @@ import com.wwdz.ch.wx.entity.request.ItemRequestDto; ...@@ -5,25 +5,99 @@ import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.db.dto.request.FavoritesRequestDto; import com.wwdz.ch.db.dto.request.FavoritesRequestDto;
public interface FavoritesService { public interface FavoritesService {
/**
* 新增默认收藏册
*
* @param dto
* @return
*/
Result addDefault(FavoritesRequestDto dto); Result addDefault(FavoritesRequestDto dto);
/**
* 收藏册分页
*
* @param dto
* @return
*/
Result page(FavoritesRequestDto dto); Result page(FavoritesRequestDto dto);
/**
* 收藏册列表
*
* @param dto
* @return
*/
Result list(FavoritesRequestDto dto); Result list(FavoritesRequestDto dto);
/**
* 新增收藏册
*
* @param dto
* @return
*/
Result add(FavoritesRequestDto dto); Result add(FavoritesRequestDto dto);
/**
* 更新收藏册
*
* @param dto
* @return
*/
Result update(FavoritesRequestDto dto); Result update(FavoritesRequestDto dto);
/**
* 收藏册基本详情
*
* @param dto
* @return
*/
Result info(FavoritesRequestDto dto); Result info(FavoritesRequestDto dto);
/**
* 收藏册下藏品列表
*
* @param dto
* @return
*/
Result itemList(FavoritesRequestDto dto); Result itemList(FavoritesRequestDto dto);
/**
* 单个删除收藏册
*
* @param dto
* @return
*/
Result delete(FavoritesRequestDto dto); Result delete(FavoritesRequestDto dto);
/**
* 批量删除收藏册
*
* @param dto
* @return
*/
Result batchDelete(FavoritesRequestDto dto); Result batchDelete(FavoritesRequestDto dto);
/**
* 收藏
*
* @param dto
* @return
*/
Result addItem(ItemRequestDto dto); Result addItem(ItemRequestDto dto);
/**
* 取消收藏
*
* @param dto
* @return
*/
Result removeItem(ItemRequestDto dto); Result removeItem(ItemRequestDto dto);
/**
* 移动藏品
*
* @param dto
* @return
*/
Result moveItem(ItemRequestDto dto); Result moveItem(ItemRequestDto dto);
} }
...@@ -4,7 +4,27 @@ import com.wwdz.ch.core.type.Result; ...@@ -4,7 +4,27 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.FootPrintRequestDto; import com.wwdz.ch.wx.entity.request.FootPrintRequestDto;
public interface FootPrintService { public interface FootPrintService {
/**
* 用户足迹列表查询
*
* @param dto
* @return
*/
Result listAll(FootPrintRequestDto dto); Result listAll(FootPrintRequestDto dto);
/**
* 用户足迹分页查询
*
* @param dto
* @return
*/
Result page(FootPrintRequestDto dto); Result page(FootPrintRequestDto dto);
/**
* 用户足迹删除
*
* @param dto
* @return
*/
Result delete(FootPrintRequestDto dto); Result delete(FootPrintRequestDto dto);
} }
...@@ -7,25 +7,101 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -7,25 +7,101 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
public interface ItemService { public interface ItemService {
/**
* 搜索用藏品名称联想
*
* @param dto
* @return
*/
Result nameList(ItemRequestDto dto); Result nameList(ItemRequestDto dto);
Result recommend();
/**
* 藏品分页
*
* @param dto
* @return
*/
Result page(ItemRequestDto dto); Result page(ItemRequestDto dto);
/**
* 藏品列表
*
* @param dto
* @return
*/
Result list(ItemRequestDto dto); Result list(ItemRequestDto dto);
/**
* 新增藏品
*
* @param dto
* @return
*/
Result add(ItemRequestDto dto); Result add(ItemRequestDto dto);
/**
* 藏品详情
*
* @param dto
* @return
*/
Result info(ItemRequestDto dto); Result info(ItemRequestDto dto);
/**
* 收藏(仅首页使用)
*
* @param dto
* @return
*/
Result collect(ItemRequestDto dto); Result collect(ItemRequestDto dto);
/**
* 取消收藏(仅首页使用)
*
* @param dto
* @return
*/
Result cancel(ItemRequestDto dto); Result cancel(ItemRequestDto dto);
/**
* 更新藏品
*
* @param dto
* @return
*/
Result update(ItemRequestDto dto); Result update(ItemRequestDto dto);
/**
* 获取微信小程序小程序码
*
* @param page
* @param scene
* @param response
* @return
*/
Result getWxacode(String page, String scene, HttpServletResponse response); Result getWxacode(String page, String scene, HttpServletResponse response);
/**
* 获取微信小程序短链接
*
* @param pageUrl
* @return
*/
Result getWxLink(String pageUrl); Result getWxLink(String pageUrl);
/**
* 上传图片
*
* @param file
* @return
*/
Result uploadImage(MultipartFile file); Result uploadImage(MultipartFile file);
/**
* 上传视频
*
* @param file
* @return
*/
Result uploadVedio(MultipartFile file); Result uploadVedio(MultipartFile file);
} }
package com.wwdz.ch.wx.service;
import com.wwdz.ch.core.type.Result;
public interface KeywordService {
Result recommend();
}
...@@ -6,19 +6,69 @@ import com.wwdz.ch.wx.entity.request.UserRequestDto; ...@@ -6,19 +6,69 @@ import com.wwdz.ch.wx.entity.request.UserRequestDto;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
public interface UserService { public interface UserService {
/**
* 微信登录
*
* @param dto
* @param request
* @return
*/
Result loginByWx(UserRequestDto dto, HttpServletRequest request); Result loginByWx(UserRequestDto dto, HttpServletRequest request);
/**
* 发送手机验证码
*
* @param dto
* @return
*/
Result regCaptcha(UserRequestDto dto); Result regCaptcha(UserRequestDto dto);
/**
* 手机号登录
*
* @param dto
* @param request
* @return
*/
Result loginByMobile(UserRequestDto dto, HttpServletRequest request); Result loginByMobile(UserRequestDto dto, HttpServletRequest request);
/**
* 修改个性签名
*
* @param dto
* @return
*/
Result updateProfile(UserRequestDto dto); Result updateProfile(UserRequestDto dto);
/**
* 修改背景图片
*
* @param dto
* @return
*/
Result updateBackground(UserRequestDto dto); Result updateBackground(UserRequestDto dto);
/**
* 修改昵称
*
* @param dto
* @return
*/
Result updateNickname(UserRequestDto dto); Result updateNickname(UserRequestDto dto);
/**
* 修改头像
*
* @param dto
* @return
*/
Result updateAvatar(UserRequestDto dto); Result updateAvatar(UserRequestDto dto);
/**
* 修改手机号
*
* @param dto
* @return
*/
Result updateMobile(UserRequestDto dto); Result updateMobile(UserRequestDto dto);
} }
...@@ -5,8 +5,35 @@ import com.wwdz.ch.wx.entity.request.UserRequestDto; ...@@ -5,8 +5,35 @@ import com.wwdz.ch.wx.entity.request.UserRequestDto;
import java.io.InputStream; import java.io.InputStream;
public interface WxLoginService { public interface WxLoginService {
/**
* 获取微信用户手机号
*
* @param dto
* @return
*/
String getPhone(UserRequestDto dto); String getPhone(UserRequestDto dto);
/**
* 获取微信用户授权access_token
*
* @return
*/
String getAccessToken(); String getAccessToken();
/**
* 获取微信小程序小程序码图片流
*
* @param path
* @param scene
* @return
*/
InputStream getWxacodeStream(String path, String scene); InputStream getWxacodeStream(String path, String scene);
/**
* 获取微信小程序短链接
*
* @param pageUrl
* @return
*/
String getLink (String pageUrl); String getLink (String pageUrl);
} }
...@@ -21,7 +21,7 @@ public class StringUtil { ...@@ -21,7 +21,7 @@ public class StringUtil {
} }
/** /**
* 格式化金额 * 格式化金额(国际格式)
* *
* @param amount * @param amount
* @return * @return
......
package com.wwdz.ch.wx.web; package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.FootPrintRequestDto; import com.wwdz.ch.wx.entity.request.FootPrintRequestDto;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
import com.wwdz.ch.wx.service.FootPrintService; import com.wwdz.ch.wx.service.FootPrintService;
import com.xxdxxs.utils.JsonUtils; import org.apache.commons.collections.CollectionUtils;
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;
...@@ -15,9 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -15,9 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays; import java.util.Objects;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 用户访问足迹服务 * 用户访问足迹服务
...@@ -31,42 +28,26 @@ public class WxFootprintController { ...@@ -31,42 +28,26 @@ public class WxFootprintController {
private FootPrintService footPrintService; private FootPrintService footPrintService;
@PostMapping("/page") @PostMapping("/page")
public Result page(@RequestBody KlDataRequestDto klDataRequestDto) { public Result page(@RequestBody FootPrintRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】用户足迹列表查询,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】用户足迹列表查询,请求参数,kl_data:{}", json); if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
String userId = JsonUtils.getValueByPath(json, "userId");
String page = JsonUtils.getValueByPath(json, "page");
String size = JsonUtils.getValueByPath(json, "size");
if (StringUtils.isBlank(userId)) {
return Result.failed("用户id不能为空"); return Result.failed("用户id不能为空");
} }
if (StringUtils.isBlank(page)) { if (Objects.isNull(dto.getPage()) || dto.getPage() <= 0) {
return Result.failed("当前页不能为空"); return Result.failed("当前页不能为空");
} }
if (StringUtils.isBlank(size)) { if (Objects.isNull(dto.getSize()) || dto.getSize() <= 0) {
return Result.failed("页面大小不能为空"); return Result.failed("页面大小不能为空");
} }
FootPrintRequestDto dto = new FootPrintRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setPage(Integer.parseInt(page));
dto.setSize(Integer.parseInt(size));
return footPrintService.page(dto); return footPrintService.page(dto);
} }
@PostMapping("/del") @PostMapping("/del")
public Result delete(@RequestBody KlDataRequestDto klDataRequestDto) { public Result delete(@RequestBody FootPrintRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】用户足迹删除,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】收藏册收藏,请求参数,kl_data:{}", json); if (CollectionUtils.isEmpty(dto.getIds())) {
String ids = JsonUtils.getValueByPath(json, "ids");
if (StringUtils.isBlank(ids)) {
return Result.failed("收藏册id不能为空"); return Result.failed("收藏册id不能为空");
} }
List<Long> idss = Arrays.stream(ids.substring(1, ids.length() - 1).split(","))
.map(Long::valueOf).collect(Collectors.toList());
FootPrintRequestDto dto = new FootPrintRequestDto();
dto.setIds(idss);
return footPrintService.delete(dto); return footPrintService.delete(dto);
} }
......
...@@ -45,12 +45,6 @@ public class WxItemController { ...@@ -45,12 +45,6 @@ public class WxItemController {
return itemService.nameList(dto); return itemService.nameList(dto);
} }
@ApiOperation(value = "推荐词汇")
@PostMapping("/recommend")
public Result recommend() {
return itemService.recommend();
}
@ApiOperation(value = "分页查询") @ApiOperation(value = "分页查询")
@PostMapping("/page") @PostMapping("/page")
public Result page(@RequestBody KlDataRequestDto klDataRequestDto) { public Result page(@RequestBody KlDataRequestDto klDataRequestDto) {
......
package com.wwdz.ch.wx.web;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.service.KeywordService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wx/keyword")
public class WxKeywordController {
private static final Logger logger = LoggerFactory.getLogger(WxKeywordController.class);
@Autowired
private KeywordService keywordService;
@ApiOperation(value = "搜索词推荐")
@PostMapping("/recommend")
public Result recommend() {
logger.info("【请求开始】搜索词推荐");
return keywordService.recommend();
}
}
package com.wwdz.ch.wx.web; package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.constant.CacheCodeConstants; import com.wwdz.ch.wx.constant.CacheCodeConstants;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto; import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
...@@ -98,127 +99,83 @@ public class WxUserController { ...@@ -98,127 +99,83 @@ public class WxUserController {
@ApiOperation(value = "修改个性签名") @ApiOperation(value = "修改个性签名")
@PostMapping("/updateProfile") @PostMapping("/updateProfile")
public Result updateProfile(@RequestBody KlDataRequestDto klDataRequestDto) { public Result updateProfile(@RequestBody UserRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】修改个性签名,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】修改个性签名,请求参数,kl_data:{}", json); if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
String userId = JsonUtils.getValueByPath(json, "userId");
String profile = JsonUtils.getValueByPath(json, "profile");
if (StringUtils.isBlank(userId)) {
return Result.failed("用户id不能为空"); return Result.failed("用户id不能为空");
} }
if (StringUtils.isBlank(profile)) { if (StringUtils.isBlank(dto.getProfile())) {
return Result.failed("个性签名不能为空"); dto.setProfile("");
} }
UserRequestDto dto = new UserRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setProfile(profile);
return userService.updateProfile(dto); return userService.updateProfile(dto);
} }
@ApiOperation(value = "修改背景") @ApiOperation(value = "修改背景")
@PostMapping("/updateBackground") @PostMapping("/updateBackground")
public Result updateBackground(@RequestBody KlDataRequestDto klDataRequestDto) { public Result updateBackground(@RequestBody UserRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】修改背景,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】修改背景,请求参数,kl_data:{}", json); if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
String userId = JsonUtils.getValueByPath(json, "userId");
String background = JsonUtils.getValueByPath(json, "background");
if (StringUtils.isBlank(userId)) {
return Result.failed("用户id不能为空"); return Result.failed("用户id不能为空");
} }
if (StringUtils.isBlank(background)) { if (StringUtils.isBlank(dto.getBackground())) {
return Result.failed("背景图片路径不能为空"); dto.setBackground("");
} }
UserRequestDto dto = new UserRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setBackground(background);
return userService.updateBackground(dto); return userService.updateBackground(dto);
} }
@ApiOperation(value = "修改昵称") @ApiOperation(value = "修改昵称")
@PostMapping("/updateNickname") @PostMapping("/updateNickname")
public Result updateNickname(@RequestBody KlDataRequestDto klDataRequestDto) { public Result updateNickname(@RequestBody UserRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】修改昵称,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】修改昵称,请求参数,kl_data:{}", json); if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
String userId = JsonUtils.getValueByPath(json, "userId");
String nickname = JsonUtils.getValueByPath(json, "nickname");
if (Objects.isNull(userId)) {
return Result.failed("用户id不能为空"); return Result.failed("用户id不能为空");
} }
if (StringUtils.isBlank(nickname)) { if (StringUtils.isBlank(dto.getNickname())) {
return Result.failed("昵称不能为空"); return Result.failed("昵称不能为空");
} }
UserRequestDto dto = new UserRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setNickname(nickname);
return userService.updateNickname(dto); return userService.updateNickname(dto);
} }
@ApiOperation(value = "修改头像") @ApiOperation(value = "修改头像")
@PostMapping("/updateAvatar") @PostMapping("/updateAvatar")
public Result updateAvatar(@RequestBody KlDataRequestDto klDataRequestDto) { public Result updateAvatar(@RequestBody UserRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】修改头像,请求参数:{}", JSON.toJSONString(true));
logger.info("【请求开始】修改头像,请求参数,kl_data:{}", json); if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
String userId = JsonUtils.getValueByPath(json, "userId");
String avatarUrl = JsonUtils.getValueByPath(json, "avatarUrl");
if (Objects.isNull(userId)) {
return Result.failed("用户id不能为空"); return Result.failed("用户id不能为空");
} }
if (StringUtils.isBlank(avatarUrl)) { if (StringUtils.isBlank(dto.getAvatarUrl())) {
return Result.failed("头像图片路径不能为空"); return Result.failed("请上传头像");
} }
UserRequestDto dto = new UserRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setAvatarUrl(avatarUrl);
return userService.updateAvatar(dto); return userService.updateAvatar(dto);
} }
@ApiOperation(value = "修改手机验证码") @ApiOperation(value = "修改手机验证码")
@PostMapping("/updateRegCaptcha") @PostMapping("/updateRegCaptcha")
public Object updateRegCaptcha(@RequestBody KlDataRequestDto klDataRequestDto) { public Object updateRegCaptcha(@RequestBody UserRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】请求修改手机验证码,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】请求修改手机验证码,请求参数,kl_data:{}", json); if (StringUtils.isBlank(dto.getMobile())) {
String mobile = JsonUtils.getValueByPath(json, "mobile");
if (StringUtils.isBlank(mobile)) {
return Result.failed("手机号不能为空"); return Result.failed("手机号不能为空");
} }
UserRequestDto dto = new UserRequestDto();
dto.setMobile(mobile);
dto.setSmsType(CacheCodeConstants.SmsTypeEnum.UPDATE.getCode()); dto.setSmsType(CacheCodeConstants.SmsTypeEnum.UPDATE.getCode());
return userService.regCaptcha(dto); return userService.regCaptcha(dto);
} }
@ApiOperation(value = "修改手机号") @ApiOperation(value = "修改手机号")
@PostMapping("/updateMobile") @PostMapping("/updateMobile")
public Result updateMobile(@RequestBody KlDataRequestDto klDataRequestDto) { public Result updateMobile(@RequestBody UserRequestDto dto) {
String json = klDataRequestDto.getKl_data(); logger.info("【请求开始】修改手机号,请求参数:{}", JSON.toJSONString(dto));
logger.info("【请求开始】修改手机号,请求参数,kl_data:{}", json); if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
String userId = JsonUtils.getValueByPath(json, "userId");
String beforeMobile = JsonUtils.getValueByPath(json, "beforeMobile");
String afterMobile = JsonUtils.getValueByPath(json, "afterMobile");
String smsCode = JsonUtils.getValueByPath(json, "smsCode");
if (Objects.isNull(userId)) {
return Result.failed("用户id不能为空"); return Result.failed("用户id不能为空");
} }
if (StringUtils.isBlank(beforeMobile)) { if (StringUtils.isBlank(dto.getBeforeMobile())) {
return Result.failed("原手机号不能为空"); return Result.failed("原手机号不能为空");
} }
if (StringUtils.isBlank(afterMobile)) { if (StringUtils.isBlank(dto.getAfterMobile())) {
return Result.failed("新手机号不能为空"); return Result.failed("新绑定手机号不能为空");
} }
if (StringUtils.isBlank(smsCode)) { if (StringUtils.isBlank(dto.getSmsCode())) {
return Result.failed("验证码不能为空"); return Result.failed("验证码不能为空");
} }
UserRequestDto dto = new UserRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setBeforeMobile(beforeMobile);
dto.setAfterMobile(afterMobile);
dto.setSmsCode(smsCode);
return userService.updateMobile(dto); return userService.updateMobile(dto);
} }
} }
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