Merge branch 'main' of https://git.mowei.com.cn/wyh/surprise into main
commit
f226493d60
|
|
@ -1,5 +1,6 @@
|
|||
package com.mdd.admin.controller.dongtai;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.mdd.admin.aop.Log;
|
||||
import com.mdd.admin.service.IAppTagService;
|
||||
import com.mdd.admin.validate.commons.IdValidate;
|
||||
|
|
@ -9,6 +10,7 @@ import com.mdd.admin.validate.dttag.AppTagSearchValidate;
|
|||
import com.mdd.admin.validate.dttag.AppTagUpdateValidate;
|
||||
import com.mdd.admin.vo.dttag.AppTagDetailVo;
|
||||
import com.mdd.admin.vo.dttag.AppTagListedVo;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
|
|
@ -35,6 +37,16 @@ public class AppTagController {
|
|||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@NotPower
|
||||
@GetMapping("/listTree")
|
||||
@ApiOperation(value="获取菜单列表")
|
||||
public AjaxResult<JSONArray> list() {
|
||||
JSONArray lists = iAppTagService.listTree();
|
||||
return AjaxResult.success(lists);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="动态标签详情")
|
||||
public AjaxResult<AppTagDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.mdd.admin.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.dttag.AppTagCreateValidate;
|
||||
import com.mdd.admin.validate.dttag.AppTagSearchValidate;
|
||||
|
|
@ -58,4 +59,5 @@ public interface IAppTagService {
|
|||
*/
|
||||
void del(Integer id);
|
||||
|
||||
JSONArray listTree();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.mdd.admin.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
|
@ -152,4 +154,23 @@ public class AppTagServiceImpl implements IAppTagService {
|
|||
appTagMapper.delete(new QueryWrapper<AppTag>().eq("id", id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listTree() {
|
||||
QueryWrapper<AppTag> appTagQueryWrapper = new QueryWrapper<>();
|
||||
appTagQueryWrapper.orderByDesc("id");
|
||||
|
||||
List<AppTag> appTags = appTagMapper.selectList(appTagQueryWrapper);
|
||||
List<AppTagListedVo> appTagListedVos = new ArrayList<>();
|
||||
for(AppTag appTag : appTags) {
|
||||
AppTagListedVo appTagListedVo = new AppTagListedVo();
|
||||
BeanUtils.copyProperties(appTag, appTagListedVo);
|
||||
appTagListedVo.setCreateTime(TimeUtils.timestampToDate(appTag.getCreateTime()));
|
||||
appTagListedVo.setUpdateTime(TimeUtils.timestampToDate(appTag.getUpdateTime()));
|
||||
appTagListedVos.add(appTagListedVo);
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(appTagListedVos));
|
||||
return ListUtils.listToTree(jsonArray, "id", "parentId", "children");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ spring:
|
|||
password: 4e14b5378637d9c7 # 数据库密码
|
||||
# Redis配置
|
||||
redis:
|
||||
host: 139.224.213.131 # Redis服务地址
|
||||
port: 7001 # Redis端口
|
||||
host: 101.133.172.2 # Redis服务地址
|
||||
port: 2007 # Redis端口
|
||||
password: 123456 # Redis密码
|
||||
database: 4 # 数据库索引
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package com.mdd.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("动态实体")
|
||||
public class AppDongtai implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(value = "删除时间")
|
||||
private Long deleteTime;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "图片,字符串拼接")
|
||||
private String img;
|
||||
|
||||
@ApiModelProperty(value = "视频url")
|
||||
private String video;
|
||||
|
||||
@ApiModelProperty(value = "提及用户,@的用户,字符串拼接")
|
||||
private String refUser;
|
||||
|
||||
@ApiModelProperty(value = "标签id,字符串拼接")
|
||||
private String tagId;
|
||||
|
||||
@ApiModelProperty(value = "位置")
|
||||
private String location;
|
||||
|
||||
@ApiModelProperty(value = "引用类型,1动态,2,圈子")
|
||||
private Integer refType;
|
||||
|
||||
@ApiModelProperty(value = "引用内容id")
|
||||
private Integer refId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "发布用户")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.mdd.common.mapper;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.AppDongtai;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 动态Mapper
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppDongtaiMapper extends IBaseMapper<AppDongtai> {
|
||||
}
|
||||
|
|
@ -33,13 +33,13 @@ public class SwaggerConfig {
|
|||
}
|
||||
|
||||
private ApiInfo apiInfo(){
|
||||
String author = "FZR";
|
||||
String url = "https://gitee.com/likeadmin/likeadmin_java";
|
||||
String email = "tinyants@163.com";
|
||||
String author = "wyh";
|
||||
String url = "http://wyhdamowang.com";
|
||||
String email = "wyhxjl994@163.com";
|
||||
|
||||
return new ApiInfoBuilder()
|
||||
.title("LikeAdmin【前台】接口文档")
|
||||
.description("likeadmin是一套使用流行的技术栈的快速开发管理后台")
|
||||
.title("惊喜派(app)接口文档")
|
||||
.description("这是一份接口文档")
|
||||
.version(GlobalConfig.version)
|
||||
.contact(new Contact(author, url, email))
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.front.aop.Log;
|
||||
import com.mdd.front.service.IAppDongtaiService;
|
||||
import com.mdd.front.validate.common.IdValidate;
|
||||
import com.mdd.front.validate.AppDongtaiCreateValidate;
|
||||
import com.mdd.front.validate.AppDongtaiUpdateValidate;
|
||||
import com.mdd.front.validate.AppDongtaiSearchValidate;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.AppDongtaiListedVo;
|
||||
import com.mdd.front.vo.AppDongtaiDetailVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/dongtai")
|
||||
@Api(tags = "动态管理")
|
||||
public class AppDongtaiController {
|
||||
|
||||
@Resource
|
||||
IAppDongtaiService iAppDongtaiService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value="动态列表")
|
||||
public AjaxResult<PageResult<AppDongtaiListedVo>> list(@Validated PageValidate pageValidate,
|
||||
@Validated AppDongtaiSearchValidate searchValidate) {
|
||||
PageResult<AppDongtaiListedVo> list = iAppDongtaiService.list(pageValidate, searchValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="动态详情")
|
||||
public AjaxResult<AppDongtaiDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
AppDongtaiDetailVo detail = iAppDongtaiService.detail(id);
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
@Log(title = "动态新增")
|
||||
@PostMapping("/add")
|
||||
@NotLogin
|
||||
@ApiOperation(value="动态新增")
|
||||
public AjaxResult<Object> add(@Validated @RequestBody AppDongtaiCreateValidate createValidate) {
|
||||
iAppDongtaiService.add(createValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
// @Log(title = "动态编辑")
|
||||
// @PostMapping("/edit")
|
||||
// @ApiOperation(value="动态编辑")
|
||||
// public AjaxResult<Object> edit(@Validated @RequestBody AppDongtaiUpdateValidate updateValidate) {
|
||||
// iAppDongtaiService.edit(updateValidate);
|
||||
// return AjaxResult.success();
|
||||
// }
|
||||
|
||||
@Log(title = "动态删除")
|
||||
@PostMapping("/del")
|
||||
@ApiOperation(value="动态删除")
|
||||
public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
|
||||
iAppDongtaiService.del(idValidate.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.front.aop.Log;
|
||||
import com.mdd.front.service.IAppUserService;
|
||||
import com.mdd.front.validate.AppUserCreateValidate;
|
||||
|
|
@ -29,6 +30,7 @@ public class AppUserController {
|
|||
IAppUserService iAppUserService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@NotLogin
|
||||
@ApiOperation(value="用户信息列表")
|
||||
public AjaxResult<PageResult<AppUserListedVo>> list(@Validated PageValidate pageValidate,
|
||||
@Validated AppUserSearchValidate searchValidate) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.mdd.common.exception.OperateException;
|
|||
import com.mdd.common.plugin.storage.StorageDriver;
|
||||
import com.mdd.common.plugin.storage.UploadFilesVo;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import com.mdd.front.aop.aspect.RequestType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -16,6 +17,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
|
|
@ -47,4 +50,25 @@ public class UploadController {
|
|||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
@NotLogin
|
||||
@PostMapping("/video")
|
||||
@ApiOperation(value="上传视频")
|
||||
public AjaxResult<UploadFilesVo> video(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
} catch (Exception e) {
|
||||
throw new OperateException("请选择上传视频!");
|
||||
}
|
||||
|
||||
if (multipartFile == null) {
|
||||
throw new OperateException("请选择上传视频!");
|
||||
}
|
||||
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
UploadFilesVo vo = storageDriver.upload(multipartFile, "video", AlbumEnum.Video.getCode());
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package com.mdd.front.service;
|
||||
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.validate.AppDongtaiCreateValidate;
|
||||
import com.mdd.front.validate.AppDongtaiUpdateValidate;
|
||||
import com.mdd.front.validate.AppDongtaiSearchValidate;
|
||||
import com.mdd.front.vo.AppDongtaiListedVo;
|
||||
import com.mdd.front.vo.AppDongtaiDetailVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
/**
|
||||
* 动态服务接口类
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
public interface IAppDongtaiService {
|
||||
|
||||
/**
|
||||
* 动态列表
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<AppDongtaiListedVo>
|
||||
*/
|
||||
PageResult<AppDongtaiListedVo> list(PageValidate pageValidate, AppDongtaiSearchValidate searchValidate);
|
||||
|
||||
/**
|
||||
* 动态详情
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param id 主键ID
|
||||
* @return AppDongtaiDetailVo
|
||||
*/
|
||||
AppDongtaiDetailVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 动态新增
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
void add(AppDongtaiCreateValidate createValidate);
|
||||
|
||||
/**
|
||||
* 动态编辑
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
void edit(AppDongtaiUpdateValidate updateValidate);
|
||||
|
||||
/**
|
||||
* 动态删除
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param id 主键ID
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,303 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mdd.common.entity.AppFriend;
|
||||
import com.mdd.common.entity.AppUser;
|
||||
import com.mdd.common.entity.dttag.AppTag;
|
||||
import com.mdd.common.mapper.AppFriendMapper;
|
||||
import com.mdd.common.mapper.AppUserMapper;
|
||||
import com.mdd.common.mapper.dttag.AppTagMapper;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import com.mdd.front.LikeFrontThreadLocal;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.service.IAppDongtaiService;
|
||||
import com.mdd.front.validate.AppDongtaiCreateValidate;
|
||||
import com.mdd.front.validate.AppDongtaiUpdateValidate;
|
||||
import com.mdd.front.validate.AppDongtaiSearchValidate;
|
||||
import com.mdd.front.vo.AppDongtaiListedVo;
|
||||
import com.mdd.front.vo.AppDongtaiDetailVo;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.AppDongtai;
|
||||
import com.mdd.common.mapper.AppDongtaiMapper;
|
||||
import com.mdd.common.util.ListUtils;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.common.util.UrlUtils;
|
||||
import com.mdd.front.vo.AppTagVo;
|
||||
import com.mdd.front.vo.AppUserListedVo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 动态实现类
|
||||
*
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Service
|
||||
public class AppDongtaiServiceImpl implements IAppDongtaiService {
|
||||
|
||||
@Resource
|
||||
AppDongtaiMapper appDongtaiMapper;
|
||||
|
||||
@Resource
|
||||
AppTagMapper appTagMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
AppUserMapper appUserMapper;
|
||||
|
||||
@Resource
|
||||
AppFriendMapper appFriendMapper;
|
||||
|
||||
/**
|
||||
* 动态列表
|
||||
*
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<AppDongtaiListedVo>
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Override
|
||||
public PageResult<AppDongtaiListedVo> list(PageValidate pageValidate, AppDongtaiSearchValidate searchValidate) {
|
||||
Integer page = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<AppDongtai> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
//查所有的好友
|
||||
List<AppFriend> friends = new ArrayList<>();
|
||||
QueryWrapper<AppFriend> friendWrapper = new QueryWrapper<>();
|
||||
if (searchValidate.getUserId() != null) {
|
||||
friendWrapper.eq("user_id", searchValidate.getUserId());
|
||||
friends = appFriendMapper.selectList(friendWrapper);
|
||||
}
|
||||
List<Integer> collect = friends.stream().map(item -> item.getFriendId()).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)){
|
||||
return PageResult.pageHelper(new ArrayList<>());
|
||||
}
|
||||
else {
|
||||
queryWrapper.in("user_id", collect);
|
||||
}
|
||||
appDongtaiMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
||||
"=:content:str",
|
||||
"=:img:str",
|
||||
"=:video:str",
|
||||
"=:refUser@ref_user:str",
|
||||
"=:tagId@tag_id:str",
|
||||
"=:location:str",
|
||||
"=:refType@ref_type:int",
|
||||
"=:refId@ref_id:int",
|
||||
});
|
||||
|
||||
IPage<AppDongtai> iPage = appDongtaiMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
List<AppUserListedVo> userList = new LinkedList<>();
|
||||
List<AppTagVo> tagList = new LinkedList<>();
|
||||
List<AppDongtaiListedVo> list = new LinkedList<>();
|
||||
for (AppDongtai item : iPage.getRecords()) {
|
||||
AppDongtaiListedVo vo = new AppDongtaiListedVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
// 处理提及用户,多个和单个
|
||||
if (StringUtils.isNoneBlank(item.getRefUser())) {
|
||||
if (item.getRefUser().contains(",")) {
|
||||
List<Integer> userIds = ListUtils.stringToListAsInt(item.getTagId(), ",");
|
||||
userIds.forEach(id -> {
|
||||
List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getId, id));
|
||||
Assert.notEmpty(appUsers, "用户不存在");
|
||||
boolean b = userList.addAll(appUsers.stream().map(user -> {
|
||||
AppUserListedVo appUserListedVo = new AppUserListedVo();
|
||||
BeanUtils.copyProperties(user, appUserListedVo);
|
||||
appUserListedVo.setCreateTime(TimeUtils.timestampToDate(user.getCreateTime()));
|
||||
appUserListedVo.setUpdateTime(TimeUtils.timestampToDate(user.getUpdateTime()));
|
||||
return appUserListedVo;
|
||||
}).collect(Collectors.toList()));
|
||||
Assert.isTrue(b, "用户不存在");
|
||||
});
|
||||
} else {
|
||||
AppUser appUsers = appUserMapper.selectById(Integer.parseInt(item.getRefUser()));
|
||||
Assert.notNull(appUsers, "用户不存在");
|
||||
AppUserListedVo appUserListedVo = new AppUserListedVo();
|
||||
BeanUtils.copyProperties(appUsers, appUserListedVo);
|
||||
appUserListedVo.setCreateTime(TimeUtils.timestampToDate(appUsers.getCreateTime()));
|
||||
appUserListedVo.setUpdateTime(TimeUtils.timestampToDate(appUsers.getUpdateTime()));
|
||||
userList.add(appUserListedVo);
|
||||
}
|
||||
vo.setUserInfos(userList);
|
||||
}
|
||||
|
||||
if (StringUtils.isNoneBlank(item.getTagId())) {
|
||||
if (item.getTagId().contains(",")) {
|
||||
List<Integer> tagIds = ListUtils.stringToListAsInt(item.getTagId(), ",");
|
||||
tagIds.forEach(id -> {
|
||||
List<AppTag> tags = appTagMapper.selectList(new LambdaQueryWrapper<AppTag>().eq(AppTag::getId, id));
|
||||
Assert.notEmpty(tags, "用户不存在");
|
||||
boolean b = tagList.addAll(tags.stream().map(tag -> {
|
||||
AppTagVo appTagVo = new AppTagVo();
|
||||
BeanUtils.copyProperties(tag, appTagVo);
|
||||
appTagVo.setCreateTime(TimeUtils.timestampToDate(tag.getCreateTime()));
|
||||
appTagVo.setUpdateTime(TimeUtils.timestampToDate(tag.getUpdateTime()));
|
||||
return appTagVo;
|
||||
}).collect(Collectors.toList()));
|
||||
Assert.isTrue(b, "标签不存在");
|
||||
});
|
||||
} else {
|
||||
AppTag appTags = appTagMapper.selectById(Integer.parseInt(item.getTagId()));
|
||||
Assert.notNull(appTags, "标签不存在");
|
||||
AppTagVo appTagVo = new AppTagVo();
|
||||
BeanUtils.copyProperties(appTags, appTagVo);
|
||||
appTagVo.setCreateTime(TimeUtils.timestampToDate(appTags.getCreateTime()));
|
||||
appTagVo.setUpdateTime(TimeUtils.timestampToDate(appTags.getUpdateTime()));
|
||||
tagList.add(appTagVo);
|
||||
}
|
||||
vo.setAppTags(tagList);
|
||||
}
|
||||
vo.setImg(UrlUtils.toAbsoluteUrl(item.getImg()));
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态详情
|
||||
*
|
||||
* @param id 主键参数
|
||||
* @return AppDongtai
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Override
|
||||
public AppDongtaiDetailVo detail(Integer id) {
|
||||
AppDongtai model = appDongtaiMapper.selectOne(
|
||||
new QueryWrapper<AppDongtai>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在");
|
||||
|
||||
AppDongtaiDetailVo vo = new AppDongtaiDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
vo.setImg(UrlUtils.toAbsoluteUrl(model.getImg()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态新增
|
||||
*
|
||||
* @param createValidate 参数
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Override
|
||||
public void add(AppDongtaiCreateValidate createValidate) {
|
||||
if (createValidate.getRefType() != null && createValidate.getRefId() == null) {
|
||||
Assert.isNull(null, "引用id不能为空");
|
||||
}
|
||||
|
||||
if (StringUtils.isNoneBlank(createValidate.getTagId()) && createValidate.getTagId().contains(",")) {
|
||||
List<Integer> tags = ListUtils.stringToListAsInt(createValidate.getTagId(), ",");
|
||||
tags.forEach(id -> {
|
||||
AppTag tag = appTagMapper.selectById(id);
|
||||
Assert.notNull(tag, "标签不存在");
|
||||
});
|
||||
} else {
|
||||
AppTag tag = appTagMapper.selectOne(
|
||||
new QueryWrapper<AppTag>()
|
||||
.eq("id", createValidate.getTagId())
|
||||
.last("limit 1"));
|
||||
Assert.notNull(tag, "标签不存在");
|
||||
}
|
||||
if (StringUtils.isNoneBlank(createValidate.getRefUser())) {
|
||||
if (createValidate.getRefUser().contains(",")) {
|
||||
List<Integer> users = ListUtils.stringToListAsInt(createValidate.getTagId(), ",");
|
||||
users.forEach(id -> {
|
||||
AppUser appUser = appUserMapper.selectById(id);
|
||||
Assert.notNull(appUser, "用户不存在");
|
||||
});
|
||||
} else {
|
||||
AppUser appUser = appUserMapper.selectOne(
|
||||
new QueryWrapper<AppUser>()
|
||||
.eq("id", createValidate.getRefUser())
|
||||
.last("limit 1"));
|
||||
Assert.notNull(appUser, "用户不存在");
|
||||
}
|
||||
}
|
||||
AppDongtai model = new AppDongtai();
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setContent(createValidate.getContent());
|
||||
model.setImg(UrlUtils.toRelativeUrl(createValidate.getImg()));
|
||||
model.setVideo(createValidate.getVideo());
|
||||
model.setRefUser(createValidate.getRefUser());
|
||||
model.setTagId(createValidate.getTagId());
|
||||
model.setLocation(createValidate.getLocation());
|
||||
model.setRefType(createValidate.getRefType());
|
||||
model.setRefId(createValidate.getRefId());
|
||||
appDongtaiMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态编辑
|
||||
*
|
||||
* @param updateValidate 参数
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Override
|
||||
public void edit(AppDongtaiUpdateValidate updateValidate) {
|
||||
AppDongtai model = appDongtaiMapper.selectOne(
|
||||
new QueryWrapper<AppDongtai>()
|
||||
.eq("id", updateValidate.getId())
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setId(updateValidate.getId());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setContent(updateValidate.getContent());
|
||||
model.setImg(UrlUtils.toRelativeUrl(updateValidate.getImg()));
|
||||
model.setVideo(updateValidate.getVideo());
|
||||
model.setRefUser(updateValidate.getRefUser());
|
||||
model.setTagId(updateValidate.getTagId());
|
||||
model.setLocation(updateValidate.getLocation());
|
||||
model.setRefType(updateValidate.getRefType());
|
||||
model.setRefId(updateValidate.getRefId());
|
||||
appDongtaiMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态删除
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
AppDongtai model = appDongtaiMapper.selectOne(
|
||||
new QueryWrapper<AppDongtai>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
appDongtaiMapper.delete(new QueryWrapper<AppDongtai>().eq("id", id));
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String s = "1,2,3";
|
||||
List<Integer> integers = ListUtils.stringToListAsInt(s, ",");
|
||||
System.out.println(integers);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.mdd.front.validate;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Data
|
||||
@ApiModel("动态创建参数")
|
||||
public class AppDongtaiCreateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "content参数缺失")
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "图片,字符串拼接")
|
||||
private String img;
|
||||
|
||||
@ApiModelProperty(value = "视频url")
|
||||
private String video;
|
||||
|
||||
@ApiModelProperty(value = "提及用户,@的用户,字符串拼接")
|
||||
private String refUser;
|
||||
|
||||
@ApiModelProperty(value = "标签id,字符串拼接")
|
||||
private String tagId;
|
||||
|
||||
@ApiModelProperty(value = "位置")
|
||||
private String location;
|
||||
|
||||
@ApiModelProperty(value = "引用类型,1动态,2,圈子, 3, 心愿单")
|
||||
private Integer refType;
|
||||
|
||||
@ApiModelProperty(value = "引用内容id")
|
||||
private Integer refId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "发布用户")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.mdd.front.validate;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("动态搜索参数")
|
||||
public class AppDongtaiSearchValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "图片,字符串拼接")
|
||||
private String img;
|
||||
|
||||
@ApiModelProperty(value = "视频url")
|
||||
private String video;
|
||||
|
||||
@ApiModelProperty(value = "提及用户,@的用户,字符串拼接")
|
||||
private String refUser;
|
||||
|
||||
@ApiModelProperty(value = "标签id,字符串拼接")
|
||||
private String tagId;
|
||||
|
||||
@ApiModelProperty(value = "位置")
|
||||
private String location;
|
||||
|
||||
@ApiModelProperty(value = "引用类型,1动态,2,圈子")
|
||||
private Integer refType;
|
||||
|
||||
@ApiModelProperty(value = "引用内容id")
|
||||
private Integer refId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "发布用户")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.mdd.front.validate;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.*;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
|
||||
/**
|
||||
* 动态参数
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("动态更新参数")
|
||||
public class AppDongtaiUpdateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0")
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "content参数缺失")
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@NotNull(message = "img参数缺失")
|
||||
@ApiModelProperty(value = "图片,字符串拼接")
|
||||
private String img;
|
||||
|
||||
@NotNull(message = "video参数缺失")
|
||||
@ApiModelProperty(value = "视频url")
|
||||
private String video;
|
||||
|
||||
@NotNull(message = "refUser参数缺失")
|
||||
@ApiModelProperty(value = "提及用户,@的用户,字符串拼接")
|
||||
private String refUser;
|
||||
|
||||
@NotNull(message = "tagId参数缺失")
|
||||
@ApiModelProperty(value = "标签id,字符串拼接")
|
||||
private String tagId;
|
||||
|
||||
@NotNull(message = "location参数缺失")
|
||||
@ApiModelProperty(value = "位置")
|
||||
private String location;
|
||||
|
||||
@NotNull(message = "refType参数缺失")
|
||||
@ApiModelProperty(value = "引用类型,1动态,2,圈子")
|
||||
private Integer refType;
|
||||
|
||||
@NotNull(message = "refId参数缺失")
|
||||
@ApiModelProperty(value = "引用内容id")
|
||||
private Integer refId;
|
||||
|
||||
@ApiModelProperty(value = "发布用户")
|
||||
private Integer userId;
|
||||
|
||||
}
|
||||
|
|
@ -20,19 +20,15 @@ public class RegisterValidate implements Serializable {
|
|||
@NotBlank(message = "用户名不能为空")
|
||||
@ApiModelProperty(value = "用户名", required = true)
|
||||
private String username;
|
||||
|
||||
@NotBlank(message = "头像不能为空")
|
||||
@ApiModelProperty(value = "头像", required = true)
|
||||
private String avatar;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@ApiModelProperty(value = "手机号", required = true)
|
||||
private String mobile;
|
||||
|
||||
@NotNull(message = "性别不能为空")
|
||||
@ApiModelProperty(value = "性别1男2女", required = true)
|
||||
private Integer sex;
|
||||
|
||||
@ApiModelProperty(value = "地址")
|
||||
private String address;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("动态详情Vo")
|
||||
public class AppDongtaiDetailVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "图片,字符串拼接")
|
||||
private String img;
|
||||
|
||||
@ApiModelProperty(value = "视频url")
|
||||
private String video;
|
||||
|
||||
@ApiModelProperty(value = "提及用户,@的用户,字符串拼接")
|
||||
private String refUser;
|
||||
|
||||
@ApiModelProperty(value = "标签id,字符串拼接")
|
||||
private String tagId;
|
||||
|
||||
@ApiModelProperty(value = "位置")
|
||||
private String location;
|
||||
|
||||
@ApiModelProperty(value = "引用类型,1动态,2,圈子")
|
||||
private Integer refType;
|
||||
|
||||
@ApiModelProperty(value = "引用内容id")
|
||||
private Integer refId;
|
||||
|
||||
@ApiModelProperty(value = "发布用户")
|
||||
private Integer userId;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import com.mdd.common.entity.dttag.AppTag;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("动态列表Vo")
|
||||
public class AppDongtaiListedVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "图片,字符串拼接")
|
||||
private String img;
|
||||
|
||||
@ApiModelProperty(value = "视频url")
|
||||
private String video;
|
||||
|
||||
@ApiModelProperty(value = "提及用户,@的用户,字符串拼接")
|
||||
private String refUser;
|
||||
|
||||
@ApiModelProperty(value = "标签id,字符串拼接")
|
||||
private String tagId;
|
||||
|
||||
@ApiModelProperty(value = "位置")
|
||||
private String location;
|
||||
|
||||
@ApiModelProperty(value = "引用类型,1动态,2,圈子")
|
||||
private Integer refType;
|
||||
|
||||
@ApiModelProperty(value = "引用内容id")
|
||||
private Integer refId;
|
||||
|
||||
@ApiModelProperty(value = "发布用户")
|
||||
private Integer userId;
|
||||
|
||||
private List<AppUserListedVo> userInfos;
|
||||
|
||||
|
||||
private List<AppTagVo> appTags;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.mdd.common.entity.dttag.AppTag;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class AppTagVo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "标签名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "父级id,顶级为0")
|
||||
private Integer parentId;
|
||||
|
||||
@ApiModelProperty(value = "标签类型,1分类,2标签")
|
||||
private Integer type;
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@ spring:
|
|||
password: 4e14b5378637d9c7 # 数据库密码
|
||||
# Redis配置
|
||||
redis:
|
||||
host: 139.224.213.131 # Redis服务地址
|
||||
port: 7001 # Redis端口
|
||||
host: 101.133.172.2 # Redis服务地址
|
||||
port: 2007 # Redis端口
|
||||
password: 123456 # Redis密码
|
||||
database: 5 # 数据库索引
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
///////////////////////////////////////////////////////
|
||||
// _ _ _ _ _ _ //
|
||||
// | | (_) | __ / \ __| |_ __ ___ (_)_ __ //
|
||||
// | | | | |/ / / _ \ / _` | '_ ` _ \| | '_ \ //
|
||||
// | |___| | < / ___ \ (_| | | | | | | | | | | //
|
||||
// |_____|_|_|\_\/_/ \_\__,_|_| |_| |_|_|_| |_| //
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||
// 佛祖保佑 永不宕机 永无BUG //
|
||||
//////////////////////////////////////////////////////
|
||||
# ## ## # ##
|
||||
## ## # ############ # # #####
|
||||
## ########## ## ## #####
|
||||
## # # ########## # ## #
|
||||
### ######### # ### ####
|
||||
####### ## ######## # #######
|
||||
#### ### ## ## ## ## ##### # #
|
||||
# ## ######## ######## # # #### # ###
|
||||
## # ## # ## ## # #### ###
|
||||
## # ### ## ## # # ## # ## ##
|
||||
## #### # ############### ## # ## ##
|
||||
## ## ## ## ## ## ## ##
|
||||
## ## ## ### ########## ## ## ## ##
|
||||
## # ## ## ## ## ### # ## # ###
|
||||
## # ### # ########## ### # #### #
|
||||
# # ## ## # # #
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
|||
#end
|
||||
|
||||
@Data
|
||||
@ApiModel("${functionName}搜素参数")
|
||||
@ApiModel("${functionName}搜索参数")
|
||||
public class ${EntityName}SearchValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
Loading…
Reference in New Issue