Commit 18ea215a authored by muhong's avatar muhong

修改 小程序去除kl_data

parent 776c8d18
......@@ -261,7 +261,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 设置是否收藏或是否是自己发布的
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);
}
......
......@@ -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,27 +69,25 @@ 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);
List<ItemOfEs> list = itemEsDao.getCuewords(esSearchRequestDto);
if (CollectionUtils.isNotEmpty(list)) {
names = list.stream()
.map(ItemOfEs::getName).collect(Collectors.toList());
for (String name : names) {
// 处理特殊字符
name = name.replaceAll("\\s*|\r|\n|\t", "");
name = name.replaceAll("/P", "");
name = name.replaceAll(",", "");
// 超过15个字的15个字符
if (name.length() > 15) {
int index = name.indexOf(dto.getName());
if (index + dto.getName().length() > 15) {
name = name.substring(index + dto.getName().length() - 15, index + dto.getName().length());
} else {
name = name.substring(0, 15);
}
EsSearchRequestDto esSearchRequestDto = new EsSearchRequestDto();
esSearchRequestDto.setContent(dto.getName());
esSearchRequestDto.setSize(16);
List<ItemOfEs> list = itemEsDao.getCuewords(esSearchRequestDto);
if (CollectionUtils.isNotEmpty(list)) {
names = list.stream()
.map(ItemOfEs::getName).collect(Collectors.toList());
for (String name : names) {
// 处理特殊字符
name = name.replaceAll("\\s*|\r|\n|\t", "");
name = name.replaceAll("/P", "");
name = name.replaceAll(",", "");
// 超过15个字的15个字符
if (name.length() > 15) {
int index = name.indexOf(dto.getName());
if (index + dto.getName().length() > 15) {
name = name.substring(index + dto.getName().length() - 15, index + dto.getName().length());
} else {
name = name.substring(0, 15);
}
}
}
......@@ -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,7 +220,8 @@ public class ItemServiceImpl implements ItemService {
try {
Item item = itemDao.findById(dto.getId());
if (Objects.isNull(item)) {
if (!dto.getUserId().equals(0L)) {
//TODO 足迹如果删除如何处理
if (Objects.nonNull(dto.getUserId()) && !dto.getUserId().equals(0L)) {
// 如果当前用户已收藏该藏品,则删除收藏关联
favoritesItemsRelationDao.deleteByUserIdItemId(dto.getUserId(), dto.getId());
}
......@@ -263,7 +261,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 +309,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 +351,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());
......
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);
}
......
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