Commit 722af32a authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/master'

parents 2276b9d2 388b622e
......@@ -35,6 +35,14 @@ public interface CategoryDao {
*/
List<Category> queryByName(String name);
/**
* 判断是否存在子类目
*
* @param id
* @return
*/
boolean isExistedChild(Integer id);
List<Category> querySelective(String id, String name, Integer page, Integer size, String sort, String order);
int updateById(Category category);
......
package com.wwdz.ch.db.dao;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.domain.Footprint;
import java.util.List;
......@@ -21,7 +22,7 @@ public interface FootPrintDao {
* @param size
* @return
*/
List<Footprint> pageByUserId(Long userId, Integer page, Integer size);
PageInfo<Footprint> pageByUserId(Long userId, Integer page, Integer size);
/**
* 通过用户id统计记录数
......
......@@ -64,6 +64,13 @@ public class CategoryDaoImpl implements CategoryDao {
return categoryMapper.selectByExample(example);
}
@Override
public boolean isExistedChild (Integer id) {
CategoryExample example = new CategoryExample();
example.or().andPidEqualTo(id).andIsDeletedEqualTo(false);
return categoryMapper.countByExample(example) > 0;
}
public List<Category> querySelective(String id, String name, Integer page, Integer size, String sort,
String order) {
CategoryExample example = new CategoryExample();
......
package com.wwdz.ch.db.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.dao.FootPrintDao;
import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.FootprintExample;
......@@ -27,14 +28,15 @@ public class FootPrintDaoImpl implements FootPrintDao {
}
@Override
public List<Footprint> pageByUserId(Long userId, Integer page, Integer size) {
public PageInfo<Footprint> pageByUserId(Long userId, Integer page, Integer size) {
FootprintExample example = new FootprintExample();
FootprintExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andDeletedEqualTo(false);
example.orderBy("update_time desc");
PageHelper.startPage(page, size);
return footprintMapper.selectByExample(example);
List<Footprint> list = footprintMapper.selectByExample(example);
return new PageInfo<>(list);
}
@Override
......
......@@ -21,6 +21,12 @@ public class CacheCodeConstants {
*/
public static final String USER_UPDATE_SMS_KEY = "cjxc:wx:user:sms:update:{0}";
/**
* 缓存用户信息
* <p>{0}:用户id</p>
*/
public static final String USER_INFO_KEY = "cjxc:wx:user:info:{0}";
/**
* 短信验证码类型枚举
*/
......
......@@ -34,4 +34,5 @@ public class ItemRequestDto implements Entity {
private Integer page;
private Integer size;
private String path;
private Integer type;
}
......@@ -23,6 +23,7 @@ public class ItemResponseVo implements Entity {
private String createTime;
private String videos;
private Map<String, Object> homePageImage;
private Integer isDeleted;
private Boolean isDeleted;
private String itemNickname;
private Integer timeType;
}
......@@ -82,7 +82,17 @@ public class CategoryServiceImpl implements CategoryService {
return Result.success(new ArrayList<>());
}
try {
return Result.success(categoryDao.queryByName(dto.getName()));
List<Category> result = new ArrayList<>();
List<Category> list = categoryDao.queryByName(dto.getName());
// 筛选叶子节点
if (CollectionUtils.isNotEmpty(list)) {
for (Category category : list) {
if (!categoryDao.isExistedChild(category.getId())) {
result.add(category);
}
}
}
return Result.success(result);
} catch (Exception e) {
logger.error("搜索分类失败", e);
return Result.failed("搜索分类失败");
......
......@@ -241,27 +241,19 @@ public class FavoritesServiceImpl implements FavoritesService {
ItemResponseVo vo = new ItemResponseVo();
Item item = itemDao.findDetails(relation.getItemId());
if (item.getIsDeleted()) {
vo.setId(relation.getItemId());
vo.setHomePageImage(getImage(item));
vo.setIsDeleted(1);
agentTranceResponseVo.setDetail(vo);
list.add(agentTranceResponseVo);
continue;
}
vo.setIsDeleted(0);
// 设置基本信息
vo.setId(relation.getItemId());
vo.setName(item.getName());
vo.setImages(item.getImages());
vo.setDetail(item.getDetail());
vo.setFavoritesId(dto.getId());
vo.setIsDeleted(item.getIsDeleted());
// 设置价格
vo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的
vo.setIsCollected(0);
vo.setIsMine(0);
if (dto.getUserId() != 0L) {
if (Objects.nonNull(dto.getUserId()) && dto.getUserId() != 0L) {
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), relation.getItemId()) ? 1 : 0);
vo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), item.getId()) ? 1 : 0);
}
......
package com.wwdz.ch.wx.impl;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.FavoritesItemsRelationDao;
......@@ -9,7 +10,7 @@ import com.wwdz.ch.db.dao.UserItemsRelationDao;
import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.wx.entity.request.FootPrintRequestDto;
import com.wwdz.ch.wx.entity.vo.FootPrintResponseVo;
import com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo;
import com.wwdz.ch.wx.entity.vo.ItemResponseVo;
import com.wwdz.ch.wx.service.FootPrintService;
import com.wwdz.ch.wx.util.StringUtil;
......@@ -37,130 +38,24 @@ public class FootPrintServiceImpl implements FootPrintService {
@Autowired
private UserItemsRelationDao userItemsRelationDao;
@Override
public Result listAll(FootPrintRequestDto dto) {
try {
List<FootPrintResponseVo> result = new ArrayList<>();
List<Footprint> list = footPrintDao.listByUserId(dto.getUserId());
if (CollectionUtils.isEmpty(list)) {
return Result.success(result);
}
// 现在
Date now = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String todayFormat = simpleDateFormat.format(new Date()) + " 00:00:00";
// 今天
Date today = DateUtils.parseString(todayFormat);
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
calendar.add(Calendar.DATE, -1);
// 昨天
Date yesterday = calendar.getTime();
// 一周内
calendar.setTime(now);
calendar.add(Calendar.DATE, -7);
Date week = calendar.getTime();
// 一月内
calendar.setTime(now);
calendar.add(Calendar.MONTH, -1);
Date month = calendar.getTime();
List<ItemResponseVo> todayList = new ArrayList<>();
List<ItemResponseVo> yesterdayList = new ArrayList<>();
List<ItemResponseVo> weekList = new ArrayList<>();
List<ItemResponseVo> monthList = new ArrayList<>();
for (Footprint footprint : list) {
ItemResponseVo itemResponseVo = new ItemResponseVo();
Item item = itemDao.findDetails(footprint.getItemId());
if (item.getIsDeleted()) {
itemResponseVo.setId(item.getId());
itemResponseVo.setHomePageImage(getImage(item));
itemResponseVo.setIsDeleted(1);
if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(yesterday) >= 0 && footprint.getAddTime().compareTo(today) <= 0) {
yesterdayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(week) >= 0 && footprint.getAddTime().compareTo(yesterday) <= 0) {
weekList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(month) >= 0 && footprint.getAddTime().compareTo(week) <= 0) {
monthList.add(itemResponseVo);
}
continue;
}
itemResponseVo.setIsDeleted(0);
// 设置基本信息
itemResponseVo.setId(footprint.getId());
itemResponseVo.setItemId(item.getId());
itemResponseVo.setName(item.getName());
itemResponseVo.setImages(item.getImages());
itemResponseVo.setDetail(item.getDetail());
// 设置价格
itemResponseVo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的
itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0);
itemResponseVo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), item.getId()) ? 1 : 0);
// 设置收藏数
itemResponseVo.setCollectCount(getCollectCount(item.getId(), item.getSourceType()));
// 设置图片或视频
itemResponseVo.setHomePageImage(getImage(item));
if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(yesterday) >= 0 && footprint.getAddTime().compareTo(today) <= 0) {
yesterdayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(week) >= 0 && footprint.getAddTime().compareTo(yesterday) <= 0) {
weekList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(month) >= 0 && footprint.getAddTime().compareTo(week) <= 0) {
monthList.add(itemResponseVo);
}
}
FootPrintResponseVo todayVo = new FootPrintResponseVo();
todayVo.setTimeType(1);
todayVo.setItems(todayList);
result.add(todayVo);
FootPrintResponseVo yesterdayVo = new FootPrintResponseVo();
yesterdayVo.setTimeType(2);
yesterdayVo.setItems(yesterdayList);
result.add(yesterdayVo);
FootPrintResponseVo weekVo = new FootPrintResponseVo();
weekVo.setTimeType(3);
weekVo.setItems(weekList);
result.add(weekVo);
FootPrintResponseVo monthVo = new FootPrintResponseVo();
monthVo.setTimeType(4);
monthVo.setItems(monthList);
result.add(monthVo);
logger.info("【请求结束】用户足迹列表查询成功");
return Result.success(result);
} catch (Exception e) {
logger.error("查询用户足迹列表失败", e);
return Result.failed("查询用户足迹列表失败");
}
}
@Override
public Result page(FootPrintRequestDto dto) {
try {
Map<String, Object> map = new HashMap<>();
map.put("pageNum", dto.getPage());
map.put("pageSize", dto.getSize());
map.put("total", 0);
map.put("list", new ArrayList<>());
List<FootPrintResponseVo> result = new ArrayList<>();
List<Footprint> list = footPrintDao.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize());
if (CollectionUtils.isEmpty(list)) {
return Result.success(map);
PageInfo<AgentTranceResponseVo> result = new PageInfo<>();
result.setPageNum(dto.getPage());
result.setPageSize(dto.getSize());
result.setTotal(0L);
result.setList(new ArrayList<>());
result.setHasNextPage(false);
PageInfo<Footprint> page = footPrintDao.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize());
if (CollectionUtils.isEmpty(page.getList())) {
return Result.success(result);
}
map.put("total", footPrintDao.countByUserId(dto.getUserId()));
result.setTotal(page.getTotal());
result.setHasNextPage(page.isHasNextPage());
List<AgentTranceResponseVo> resultList = new ArrayList<>();
// 现在
Date now = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
......@@ -180,38 +75,16 @@ public class FootPrintServiceImpl implements FootPrintService {
calendar.setTime(now);
calendar.add(Calendar.MONTH, -1);
Date month = calendar.getTime();
List<ItemResponseVo> todayList = new ArrayList<>();
List<ItemResponseVo> yesterdayList = new ArrayList<>();
List<ItemResponseVo> weekList = new ArrayList<>();
List<ItemResponseVo> monthList = new ArrayList<>();
for (Footprint footprint : list) {
for (Footprint footprint : page.getList()) {
ItemResponseVo itemResponseVo = new ItemResponseVo();
Item item = itemDao.findDetails(footprint.getItemId());
if (item.getIsDeleted()) {
itemResponseVo.setId(item.getId());
itemResponseVo.setHomePageImage(getImage(item));
itemResponseVo.setIsDeleted(1);
if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(yesterday) >= 0 && footprint.getAddTime().compareTo(today) <= 0) {
yesterdayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(week) >= 0 && footprint.getAddTime().compareTo(yesterday) <= 0) {
weekList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(month) >= 0 && footprint.getAddTime().compareTo(week) <= 0) {
monthList.add(itemResponseVo);
}
continue;
}
itemResponseVo.setIsDeleted(0);
// 设置基本信息
itemResponseVo.setId(footprint.getId());
itemResponseVo.setItemId(item.getId());
itemResponseVo.setName(item.getName());
itemResponseVo.setImages(item.getImages());
itemResponseVo.setDetail(item.getDetail());
itemResponseVo.setIsDeleted(item.getIsDeleted());
// 设置价格
itemResponseVo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的
......@@ -222,42 +95,29 @@ public class FootPrintServiceImpl implements FootPrintService {
// 设置图片或视频
itemResponseVo.setHomePageImage(getImage(item));
// 设置日期类型
if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo);
}
if (footprint.getAddTime().compareTo(yesterday) >= 0 && footprint.getAddTime().compareTo(today) <= 0) {
yesterdayList.add(itemResponseVo);
itemResponseVo.setTimeType(1);
}
if (footprint.getAddTime().compareTo(week) >= 0 && footprint.getAddTime().compareTo(yesterday) <= 0) {
weekList.add(itemResponseVo);
if (footprint.getAddTime().compareTo(yesterday) >= 0 && footprint.getAddTime().compareTo(today) < 0) {
itemResponseVo.setTimeType(2);
}
if (footprint.getAddTime().compareTo(month) >= 0 && footprint.getAddTime().compareTo(week) <= 0) {
monthList.add(itemResponseVo);
if (footprint.getAddTime().compareTo(week) >= 0 && footprint.getAddTime().compareTo(yesterday) < 0) {
itemResponseVo.setTimeType(3);
}
if (footprint.getAddTime().compareTo(month) >= 0 && footprint.getAddTime().compareTo(week) < 0) {
itemResponseVo.setTimeType(4);
}
FootPrintResponseVo todayVo = new FootPrintResponseVo();
todayVo.setTimeType(1);
todayVo.setItems(todayList);
result.add(todayVo);
FootPrintResponseVo yesterdayVo = new FootPrintResponseVo();
yesterdayVo.setTimeType(2);
yesterdayVo.setItems(yesterdayList);
result.add(yesterdayVo);
FootPrintResponseVo weekVo = new FootPrintResponseVo();
weekVo.setTimeType(3);
weekVo.setItems(weekList);
result.add(weekVo);
FootPrintResponseVo monthVo = new FootPrintResponseVo();
monthVo.setTimeType(4);
monthVo.setItems(monthList);
result.add(monthVo);
map.put("dataList", result);
AgentTranceResponseVo agentTranceResponseVo = new AgentTranceResponseVo();
agentTranceResponseVo.setAgentTraceInfo_("");
agentTranceResponseVo.setViewType(1);
agentTranceResponseVo.setDetail(itemResponseVo);
resultList.add(agentTranceResponseVo);
}
result.setList(resultList);
logger.info("【请求结束】用户足迹分页查询成功");
return Result.success(map);
return Result.success(result);
} catch (Exception e) {
logger.error("用户足迹分页查询", e);
return Result.failed("查询失败");
......
......@@ -37,7 +37,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.System;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
......@@ -70,7 +69,6 @@ public class ItemServiceImpl implements ItemService {
public Result nameList(ItemRequestDto dto) {
try {
List<String> names = new ArrayList<>();
if (StringUtils.isNotBlank(dto.getName())) {
EsSearchRequestDto esSearchRequestDto = new EsSearchRequestDto();
esSearchRequestDto.setContent(dto.getName());
esSearchRequestDto.setSize(16);
......@@ -94,7 +92,6 @@ public class ItemServiceImpl implements ItemService {
}
}
}
}
return Result.success(names);
} catch (Exception e) {
logger.error("查询藏品名称联想失败", e);
......@@ -141,7 +138,7 @@ public class ItemServiceImpl implements ItemService {
// 设置是否收藏和是否是自己发布的
vo.setIsCollected(0);
vo.setIsMine(0);
if (!dto.getUserId().equals(0L)) {
if (Objects.nonNull(dto.getUserId()) && !dto.getUserId().equals(0L)) {
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), es.getId()) ? 1 : 0);
vo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), es.getId()) ? 1 : 0);
}
......@@ -223,10 +220,12 @@ public class ItemServiceImpl implements ItemService {
try {
Item item = itemDao.findById(dto.getId());
if (Objects.isNull(item)) {
if (!dto.getUserId().equals(0L)) {
if (Objects.nonNull(dto.getType()) && dto.getType().equals(1)) {
if (Objects.nonNull(dto.getUserId()) && !dto.getUserId().equals(0L)) {
// 如果当前用户已收藏该藏品,则删除收藏关联
favoritesItemsRelationDao.deleteByUserIdItemId(dto.getUserId(), dto.getId());
}
}
return Result.failed(ResultCode.INVALID_DATA.getCode(), "该藏品已经被移除");
}
ItemResponseVo itemResponseVo = new ItemResponseVo();
......@@ -263,7 +262,7 @@ public class ItemServiceImpl implements ItemService {
// 设置是否收藏或是否是自己发布的
itemResponseVo.setIsCollected(0);
itemResponseVo.setIsMine(0);
if (!dto.getUserId().equals(0L)) {
if (Objects.nonNull(dto.getUserId()) && !dto.getUserId().equals(0L)) {
FavoritesItemsRelation favoritesItemsRelation = favoritesItemsRelationDao.selectByUserIdItemId(dto.getUserId(), item.getId());
if (Objects.nonNull(favoritesItemsRelation)) {
itemResponseVo.setIsCollected(1);
......@@ -311,7 +310,7 @@ public class ItemServiceImpl implements ItemService {
@Override
public Result collect(ItemRequestDto dto) {
try {
if (dto.getUserId().equals(0L)) {
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("您尚未登录,请先登录");
}
Item item = itemDao.findById(dto.getId());
......@@ -353,7 +352,7 @@ public class ItemServiceImpl implements ItemService {
@Override
public Result cancel(ItemRequestDto dto) {
try {
if (dto.getUserId().equals(0L)) {
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("您尚未登录,请先登录");
}
Item item = itemDao.findById(dto.getId());
......
......@@ -426,4 +426,32 @@ public class UserServiceImpl implements UserService {
return Result.failed("修改手机号失败");
}
}
@Override
public Result userInfo(HttpServletRequest request) {
try {
String token = request.getHeader("Authorization");
if (StringUtils.isBlank(token)) {
logger.info("获取登录用户的token失败");
return Result.failed("查询不到当前登录用户信息");
}
Long userId = userTokenManager.getUserId(token);
if (Objects.isNull(userId)) {
logger.info("获取登录用户的userId失败");
return Result.failed("查询不到当前登录用户信息");
}
User user = null;
// String key = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, dto.getUserId().toString());
// if (redisUtil.hasKey(key)) {
// user = (User) redisUtil.get(key);
// } else {
user = userDao.queryById(userId);
// }
logger.info("【请求结束】查询用户信息成功");
return Result.success(user);
} catch (Exception e) {
logger.error("查询用户信息失败", e);
return Result.failed("查询用户信息失败");
}
}
}
......@@ -4,14 +4,6 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.FootPrintRequestDto;
public interface FootPrintService {
/**
* 用户足迹列表查询
*
* @param dto
* @return
*/
Result listAll(FootPrintRequestDto dto);
/**
* 用户足迹分页查询
*
......
......@@ -71,4 +71,11 @@ public interface UserService {
* @return
*/
Result updateMobile(UserRequestDto dto);
/**
* 查询用户信息
*
* @return
*/
Result userInfo(HttpServletRequest request);
}
package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.CategoryRequestDto;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
import com.wwdz.ch.wx.service.CategoryService;
import com.xxdxxs.utils.JsonUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
@RestController
@RequestMapping("/wx/category")
public class WxCategoryController {
......@@ -25,41 +25,27 @@ public class WxCategoryController {
@ApiOperation(value = "分类分页")
@PostMapping(value = "/top")
public Result top(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】查询分类列表,请求参数,kl_data:{}", json);
String level = JsonUtils.getValueByPath(json, "level");
String page = JsonUtils.getValueByPath(json, "page");
String size = JsonUtils.getValueByPath(json, "size");
if (StringUtils.isBlank(level)) {
public Result top(@RequestBody CategoryRequestDto dto) {
logger.info("【请求开始】查询分类列表,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getLevel())) {
return Result.failed("分类级别不能为空");
}
if (StringUtils.isBlank(page)) {
if (Objects.isNull(dto.getPage())) {
return Result.failed("当前页不能为空");
}
if (StringUtils.isBlank(size)) {
if (Objects.isNull(dto.getSize())) {
return Result.failed("页面大小不能为空");
}
CategoryRequestDto dto = new CategoryRequestDto();
dto.setLevel(Integer.parseInt(level));
dto.setPage(Integer.parseInt(page));
dto.setSize(Integer.parseInt(size));
return categoryService.top(dto);
}
@ApiOperation(value = "子分类")
@PostMapping(value = "/child")
public Result child(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】查询子分类列表,请求参数,kl_data:{}", json);
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(id)) {
public Result child(@RequestBody CategoryRequestDto dto) {
logger.info("【请求开始】查询子分类列表,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("分类id不能为空");
}
CategoryRequestDto dto = new CategoryRequestDto();
dto.setId(Integer.parseInt(id));
return categoryService.child(dto);
}
......
package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.FavoritesRequestDto;
import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
import com.wwdz.ch.wx.service.FavoritesService;
import com.xxdxxs.utils.JsonUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -16,9 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Objects;
@RestController
@RequestMapping("/wx/favorites")
......@@ -30,255 +28,159 @@ public class WxFavoritesController {
@ApiOperation(value = "分页查询")
@PostMapping("/page")
public Result page(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册分页查询,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String page = JsonUtils.getValueByPath(json, "page");
String size = JsonUtils.getValueByPath(json, "size");
if (StringUtils.isBlank(userId)) {
public Result page(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册分页查询,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(page)) {
if (Objects.isNull(dto.getPage())) {
return Result.failed("当前页不能为空");
}
if (StringUtils.isBlank(size)) {
if (Objects.isNull(dto.getSize())) {
return Result.failed("页面大小不能为空");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setPage(Integer.parseInt(page));
dto.setSize(Integer.parseInt(size));
return favoritesService.page(dto);
}
@ApiOperation(value = "列表查询")
@PostMapping("/list")
public Result list(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册分页查询,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
if (StringUtils.isBlank(userId)) {
public Result list(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册分页查询,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setUserId(Long.parseLong(userId));
return favoritesService.list(dto);
}
@ApiOperation(value = "新增")
@PostMapping("/add")
public Result add(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册新增,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String title = JsonUtils.getValueByPath(json, "title");
String description = JsonUtils.getValueByPath(json, "description");
if (StringUtils.isBlank(userId)) {
public Result add(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册新增,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(title)) {
if (StringUtils.isBlank(dto.getTitle())) {
return Result.failed("标题不能为空");
}
if (title.length() > 20) {
if (dto.getTitle().length() > 20) {
return Result.failed("标题的字数不能大于20字");
}
if (StringUtils.isNotBlank(description) && description.length() > 200) {
if (StringUtils.isNotBlank(dto.getDescription()) && dto.getDescription().length() > 200) {
return Result.failed("描述的字数不能大于200字");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setTitle(title);
dto.setDescription(description);
return favoritesService.add(dto);
}
@ApiOperation(value = "修改")
@PostMapping("/update")
public Result update(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册修改,请求参数,kl_data:{}", json);
String id = JsonUtils.getValueByPath(json, "id");
String userId = JsonUtils.getValueByPath(json, "userId");
String title = JsonUtils.getValueByPath(json, "title");
String description = JsonUtils.getValueByPath(json, "description");
if (StringUtils.isBlank(id)) {
public Result update(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册修改,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("id不能为空");
}
if (StringUtils.isBlank(userId)) {
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(title)) {
if (StringUtils.isBlank(dto.getTitle())) {
return Result.failed("标题不能为空");
}
if (title.length() > 20) {
if (dto.getTitle().length() > 20) {
return Result.failed("标题的字数不能大于20字");
}
if (StringUtils.isNotBlank(description) && description.length() > 200) {
if (StringUtils.isNotBlank(dto.getDescription()) && dto.getDescription().length() > 200) {
return Result.failed("描述的字数不能大于200字");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setId(Long.parseLong(id));
dto.setUserId(Long.parseLong(userId));
dto.setTitle(title);
dto.setDescription(description);
return favoritesService.update(dto);
}
@ApiOperation(value = "详情")
@PostMapping("/info")
public Result info(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册详情查询,请求参数,kl_data:{}", json);
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(id)) {
public Result info(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册详情查询,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("收藏册id不能为空");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setId(Long.parseLong(id));
return favoritesService.info(dto);
}
@ApiOperation(value = "收藏册下藏品列表")
@PostMapping("/itemList")
public Result itemList(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册下藏品列表分页查询,请求参数,kl_data:{}", json);
String id = JsonUtils.getValueByPath(json, "id");
String userId = JsonUtils.getValueByPath(json, "userId");
String page = JsonUtils.getValueByPath(json, "page");
String size = JsonUtils.getValueByPath(json, "size");
if (StringUtils.isBlank(id)) {
public Result itemList(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册下藏品列表分页查询,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("收藏册id不能为空");
}
if (StringUtils.isBlank(page)) {
if (Objects.isNull(dto.getPage())) {
return Result.failed("当前页不能为空");
}
if (StringUtils.isBlank(size)) {
if (Objects.isNull(dto.getSize())) {
return Result.failed("页面大小不能为空");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setId(Long.parseLong(id));
dto.setUserId(0L);
if (StringUtils.isNotBlank(userId)) {
dto.setUserId(Long.parseLong(userId));
}
dto.setPage(Integer.parseInt(page));
dto.setSize(Integer.parseInt(size));
return favoritesService.itemList(dto);
}
@ApiOperation(value = "单个删除")
@PostMapping("/delete")
public Result delete(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册单个删除,请求参数,kl_data:{}", json);
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(id)) {
public Result delete(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册单个删除,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("收藏册id不能为空");
}
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setId(Long.parseLong(id));
return favoritesService.delete(dto);
}
@ApiOperation(value = "批量删除")
@PostMapping("/batchDelete")
public Result batchDelete(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册批量删除,请求参数,kl_data:{}", json);
String ids = JsonUtils.getValueByPath(json, "ids");
if (StringUtils.isBlank(ids)) {
public Result batchDelete(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏册批量删除,请求参数:{}", JSON.toJSONString(dto));
if (CollectionUtils.isEmpty(dto.getIds())) {
return Result.failed("收藏册id不能为空");
}
List<Long> idss = Arrays.stream(ids.substring(1, ids.length() - 1).split(","))
.map(Long::valueOf).collect(Collectors.toList());
FavoritesRequestDto dto = new FavoritesRequestDto();
dto.setIds(idss);
return favoritesService.batchDelete(dto);
}
@ApiOperation(value = "收藏")
@PostMapping("/addItem")
public Result addItem(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册收藏,请求参数,kl_data:{}", json);
String favoritesId = JsonUtils.getValueByPath(json, "favoritesId");
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(favoritesId)) {
public Result addItem(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】收藏册收藏,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getFavoritesId())) {
return Result.failed("收藏册id不能为空");
}
if (StringUtils.isBlank(id)) {
if (Objects.isNull(dto.getId())) {
return Result.failed("请选择藏品");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setFavoritesId(Long.parseLong(favoritesId));
dto.setId(Long.parseLong(id));
return favoritesService.addItem(dto);
}
@ApiOperation(value = "取消收藏")
@PostMapping("/removeItem")
public Result removeItem(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册取消收藏,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String favoritesId = JsonUtils.getValueByPath(json, "favoritesId");
String itemIds = JsonUtils.getValueByPath(json, "itemIds");
if (StringUtils.isBlank(userId)) {
public Result removeItem(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】收藏册取消收藏,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(favoritesId)) {
if (Objects.isNull(dto.getFavoritesId())) {
return Result.failed("收藏册id不能为空");
}
if (StringUtils.isBlank(itemIds)) {
if (CollectionUtils.isEmpty(dto.getItemIds())) {
return Result.failed("请选择藏品");
}
List<Long> itemIdss = Arrays.stream(itemIds.substring(1, itemIds.length() - 1).split(","))
.map(Long::valueOf).collect(Collectors.toList());
ItemRequestDto dto = new ItemRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setFavoritesId(Long.parseLong(favoritesId));
dto.setItemIds(itemIdss);
return favoritesService.removeItem(dto);
}
@ApiOperation(value = "移动藏品")
@PostMapping("/moveItem")
public Result moveItem(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】收藏册移动藏品,请求参数,kl_data:{}", json);
String beforeFavoritesId = JsonUtils.getValueByPath(json, "beforeFavoritesId");
String afterFavoritesId = JsonUtils.getValueByPath(json, "afterFavoritesId");
String itemIds = JsonUtils.getValueByPath(json, "itemIds");
if (StringUtils.isBlank(beforeFavoritesId)) {
public Result moveItem(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】收藏册移动藏品,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getBeforeFavoritesId())) {
return Result.failed("原收藏册不能为空");
}
if (StringUtils.isBlank(afterFavoritesId)) {
if (Objects.isNull(dto.getAfterFavoritesId())) {
return Result.failed("现收藏册不能为空");
}
if (StringUtils.isBlank(itemIds)) {
if (CollectionUtils.isEmpty(dto.getItemIds())) {
return Result.failed("请选择藏品");
}
List<Long> itemIdss = Arrays.stream(itemIds.substring(1, itemIds.length() - 1).split(","))
.map(Long::valueOf).collect(Collectors.toList());
ItemRequestDto dto = new ItemRequestDto();
dto.setBeforeFavoritesId(Long.parseLong(beforeFavoritesId));
dto.setAfterFavoritesId(Long.parseLong(afterFavoritesId));
dto.setItemIds(itemIdss);
return favoritesService.moveItem(dto);
}
}
package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
import com.wwdz.ch.wx.service.ItemService;
import com.wwdz.ch.wx.service.WxLoginService;
import com.xxdxxs.utils.JsonUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -32,43 +31,24 @@ public class WxItemController {
@ApiOperation(value = "藏品名称联想")
@PostMapping("/findNames")
public Result findNames(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】藏品名称联想,请求参数,kl_data:{}", json);
String name = JsonUtils.getValueByPath(json, "name");
if (StringUtils.isBlank(name)) {
public Result findNames(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】藏品名称联想,请求参数:{}", JSON.toJSONString(dto));
if (StringUtils.isBlank(dto.getName())) {
return Result.success(new ArrayList<>());
}
ItemRequestDto dto = new ItemRequestDto();
dto.setName(name);
return itemService.nameList(dto);
}
@ApiOperation(value = "分页查询")
@PostMapping("/page")
public Result page(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】藏品列表首页,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String name = JsonUtils.getValueByPath(json, "name");
String page = JsonUtils.getValueByPath(json, "page");
String size = JsonUtils.getValueByPath(json, "size");
if (StringUtils.isBlank(page)) {
public Result page(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】藏品列表首页,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getPage())) {
return Result.failed("当前页不能为空");
}
if (StringUtils.isBlank(size)) {
if (Objects.isNull(dto.getSize())) {
return Result.failed("页面大小不能为空");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setUserId(0L);
if (StringUtils.isNotBlank(userId)) {
dto.setUserId(Long.parseLong(userId));
}
dto.setPage(Integer.parseInt(page));
dto.setSize(Integer.parseInt(size));
dto.setName(name);
return itemService.page(dto);
}
......@@ -80,154 +60,82 @@ public class WxItemController {
@ApiOperation(value = "新增")
@PostMapping("/add")
public Result add(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】藏品发布,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String cid = JsonUtils.getValueByPath(json, "cid");
String name = JsonUtils.getValueByPath(json, "name");
String detail = JsonUtils.getValueByPath(json, "detail");
String images = JsonUtils.getValueByPath(json, "images");
String videos = JsonUtils.getValueByPath(json, "videos");
String favoritesId = JsonUtils.getValueByPath(json, "favoritesId");
String price = JsonUtils.getValueByPath(json, "price");
if (StringUtils.isBlank(userId)) {
public Result add(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】藏品发布,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(cid)) {
if (Objects.isNull(dto.getCid())) {
return Result.failed("分类id不能为空");
}
if (StringUtils.isBlank(name)) {
if (StringUtils.isBlank(dto.getName())) {
return Result.failed("标题不能为空");
}
if (StringUtils.isBlank(images)) {
if (StringUtils.isBlank(dto.getImages())) {
return Result.failed("请至少上传一张图片");
}
if (StringUtils.isBlank(favoritesId)) {
if (Objects.isNull(dto.getFavoritesId())) {
return Result.failed("收藏册id不能为空");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setUserId(Long.parseLong(userId));
dto.setName(name);
dto.setCid(Integer.parseInt(cid));
dto.setDetail(detail);
dto.setFavoritesId(Long.parseLong(favoritesId));
dto.setImages(images);
dto.setVideos(videos);
if (StringUtils.isBlank(price)) {
price = "0";
}
dto.setPrice(price);
dto.setPrice(StringUtils.isBlank(dto.getPrice()) ? "0" : dto.getPrice());
return itemService.add(dto);
}
@ApiOperation(value = "修改")
@PostMapping("/update")
public Result update(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】藏品发布,请求参数,kl_data:{}", json);
String id = JsonUtils.getValueByPath(json, "id");
String userId = JsonUtils.getValueByPath(json, "userId");
String cid = JsonUtils.getValueByPath(json, "cid");
String name = JsonUtils.getValueByPath(json, "name");
String detail = JsonUtils.getValueByPath(json, "detail");
String images = JsonUtils.getValueByPath(json, "images");
String videos = JsonUtils.getValueByPath(json, "videos");
String favoritesId = JsonUtils.getValueByPath(json, "favoritesId");
String price = JsonUtils.getValueByPath(json, "price");
if (StringUtils.isBlank(id)) {
public Result update(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】藏品发布,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("id不能为空");
}
if (StringUtils.isBlank(userId)) {
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(cid)) {
if (Objects.isNull(dto.getCid())) {
return Result.failed("分类id不能为空");
}
if (StringUtils.isBlank(name)) {
if (StringUtils.isBlank(dto.getName())) {
return Result.failed("标题不能为空");
}
if (StringUtils.isBlank(images)) {
if (StringUtils.isBlank(dto.getImages())) {
return Result.failed("请至少上传一张图片");
}
if (StringUtils.isBlank(favoritesId)) {
if (Objects.isNull(dto.getFavoritesId())) {
return Result.failed("收藏册id不能为空");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setId(Long.parseLong(id));
dto.setUserId(Long.parseLong(userId));
dto.setName(name);
dto.setCid(Integer.parseInt(cid));
dto.setDetail(detail);
dto.setFavoritesId(Long.parseLong(favoritesId));
dto.setImages(images);
dto.setVideos(videos);
if (StringUtils.isBlank(price)) {
price = "0";
}
dto.setPrice(price);
dto.setDetail(StringUtils.isBlank(dto.getDetail()) ? "" : dto.getDetail());
dto.setVideos(StringUtils.isBlank(dto.getVideos()) ? "" : dto.getVideos());
dto.setPrice(StringUtils.isBlank(dto.getPrice()) ? "0" : dto.getPrice());
return itemService.update(dto);
}
@ApiOperation(value = "详情")
@PostMapping("/info")
public Result info(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】藏品详情查询,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(id)) {
public Result info(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】藏品详情查询,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("藏品id不能为空");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setUserId(0L);
if (StringUtils.isNotBlank(userId)) {
dto.setUserId(Long.parseLong(userId));
}
dto.setId(Long.parseLong(id));
return itemService.info(dto);
}
@ApiOperation(value = "收藏")
@PostMapping("/collect")
public Result collect(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】首页收藏,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(id)) {
public Result collect(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】首页收藏,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("藏品id不能为空");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setUserId(0L);
if (StringUtils.isNotBlank(userId)) {
dto.setUserId(Long.parseLong(userId));
}
dto.setId(Long.parseLong(id));
return itemService.collect(dto);
}
@ApiOperation(value = "取消收藏")
@PostMapping("/cancel")
public Result cancel(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】首页取消收藏,请求参数,kl_data:{}", json);
String userId = JsonUtils.getValueByPath(json, "userId");
String id = JsonUtils.getValueByPath(json, "id");
if (StringUtils.isBlank(id)) {
public Result cancel(@RequestBody ItemRequestDto dto) {
logger.info("【请求开始】首页取消收藏,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) {
return Result.failed("藏品id不能为空");
}
ItemRequestDto dto = new ItemRequestDto();
dto.setUserId(0L);
if (StringUtils.isNotBlank(userId)) {
dto.setUserId(Long.parseLong(userId));
}
dto.setId(Long.parseLong(id));
return itemService.cancel(dto);
}
......
......@@ -4,10 +4,8 @@ package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.constant.CacheCodeConstants;
import com.wwdz.ch.wx.entity.request.KlDataRequestDto;
import com.wwdz.ch.wx.entity.request.UserRequestDto;
import com.wwdz.ch.wx.service.UserService;
import com.xxdxxs.utils.JsonUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -36,64 +34,43 @@ public class WxUserController {
@ApiOperation(value = "微信登录")
@PostMapping("/loginByWx")
public Result loginByWx(@RequestBody KlDataRequestDto klDataRequestDto, HttpServletRequest request) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】微信登录,请求参数,kl_data:{}", json);
String code = JsonUtils.getValueByPath(json, "code");
if (StringUtils.isBlank(code)) {
public Result loginByWx(@RequestBody UserRequestDto dto, HttpServletRequest request) {
logger.info("【请求开始】微信登录,请求参数:{}", JSON.toJSONString(dto));
if (StringUtils.isBlank(dto.getCode())) {
return Result.failed("授权码不能为空");
}
if (!json.contains("type")) {
if (Objects.isNull(dto.getType())) {
return Result.failed("版本类型不能为空");
}
Integer type = Integer.parseInt(JsonUtils.getValueByPath(json, "type"));
UserRequestDto dto = new UserRequestDto();
dto.setCode(code);
dto.setType(type);
if (type == 2) {
if (!json.contains("encryptedData") || !json.contains("iv")) {
if (dto.getType() == 2) {
if (StringUtils.isBlank(dto.getEncryptedData()) || StringUtils.isBlank(dto.getIv())) {
return Result.failed("encryptedData或iv不能为空");
}
dto.setEncryptedData(JsonUtils.getValueByPath(json, "encryptedData"));
dto.setIv(JsonUtils.getValueByPath(json, "iv"));
}
return userService.loginByWx(dto, request);
}
@ApiOperation(value = "登录手机验证码")
@PostMapping("/loginRegCaptcha")
public Object registerCaptcha(@RequestBody KlDataRequestDto klDataRequestDto) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】请求登录手机验证码,请求参数,kl_data:{}", json);
String mobile = JsonUtils.getValueByPath(json, "mobile");
if (StringUtils.isBlank(mobile)) {
public Object registerCaptcha(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】请求登录手机验证码,请求参数:{}", JSON.toJSONString(dto));
if (StringUtils.isBlank(dto.getMobile())) {
return Result.failed("手机号不能为空");
}
UserRequestDto dto = new UserRequestDto();
dto.setMobile(mobile);
dto.setSmsType(CacheCodeConstants.SmsTypeEnum.LOGIN.getCode());
return userService.regCaptcha(dto);
}
@ApiOperation(value = "手机验证码登录")
@PostMapping("/loginByMobile")
public Result loginByMobile(@RequestBody KlDataRequestDto klDataRequestDto, HttpServletRequest request) {
String json = klDataRequestDto.getKl_data();
logger.info("【请求开始】手机号登录,请求参数,kl_data:{}", json);
String mobile = JsonUtils.getValueByPath(json, "mobile");
String smsCode = JsonUtils.getValueByPath(json, "smsCode");
if (StringUtils.isBlank(mobile)) {
public Result loginByMobile(@RequestBody UserRequestDto dto, HttpServletRequest request) {
logger.info("【请求开始】手机号登录,请求参数,kl_data:{}", JSON.toJSONString(dto));
if (StringUtils.isBlank(dto.getMobile())) {
return Result.failed("手机号不能为空");
}
if (StringUtils.isBlank(smsCode)) {
if (StringUtils.isBlank(dto.getSmsCode())) {
return Result.failed("验证码不能为空");
}
UserRequestDto dto = new UserRequestDto();
dto.setMobile(mobile);
dto.setSmsCode(smsCode);
return userService.loginByMobile(dto, request);
}
......@@ -178,4 +155,11 @@ public class WxUserController {
}
return userService.updateMobile(dto);
}
@ApiOperation(value = "用户信息")
@PostMapping("/userInfo")
public Result userInfo(HttpServletRequest request) {
logger.info("【请求开始】查询用户信息");
return userService.userInfo(request);
}
}
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