main
parent
0a860465fa
commit
792a3fd684
|
|
@ -214,6 +214,13 @@
|
|||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-pay</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--pagehelper 分页组件 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
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 AddressVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("圈子信息实体")
|
||||
|
|
@ -69,4 +70,8 @@ public class AppCircle implements Serializable {
|
|||
@ApiModelProperty(value = "删除时间")
|
||||
private Long deleteTime;
|
||||
|
||||
private String adminIds;
|
||||
|
||||
private List<Integer> ids;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
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 AppCircleAddress implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "圈子id")
|
||||
private Integer circleId;
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(value = "删除时间")
|
||||
private Long deleteTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.mdd.common.mapper;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.AppCircleAddress;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息Mapper
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppCircleAddressMapper extends IBaseMapper<AppCircleAddress> {
|
||||
}
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
package com.mdd.common.mapper;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.AddressVo;
|
||||
import com.mdd.common.entity.AppCircle;
|
||||
import com.mdd.common.vo.AppCircleVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 圈子信息Mapper
|
||||
|
|
@ -10,4 +15,10 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface AppCircleMapper extends IBaseMapper<AppCircle> {
|
||||
List<AppCircleVo> circleList(AppCircle appCircle);
|
||||
List<AppCircleVo> recommendCircleList(AppCircle appCircle);
|
||||
|
||||
List<Integer> listFriendByUserId(@Param("ids") List<Integer> ids);
|
||||
|
||||
List<AddressVo> circleUserGroupUser(@Param("circleId") Long circleId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package com.mdd.common.vo;
|
||||
|
||||
import com.mdd.common.entity.AppCircleAddress;
|
||||
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 AppCircleVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "圈子名字")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "圈子封面")
|
||||
private String imgUrl;
|
||||
|
||||
@ApiModelProperty(value = "圈子类型1私密群2好友圈3位置圈")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "圈子类型补充1固定位置2可变位置")
|
||||
private Integer typeInfo;
|
||||
|
||||
@ApiModelProperty(value = "创建用户")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "是否开启sos通知1是2否")
|
||||
private Integer isSos;
|
||||
|
||||
@ApiModelProperty(value = "sos消耗金额")
|
||||
private Integer sosUse;
|
||||
|
||||
@ApiModelProperty(value = "圈子内容是否仅圈友可写入1是2否")
|
||||
private Integer isWrite;
|
||||
|
||||
@ApiModelProperty(value = "圈子内容是否仅圈友可见1是2否")
|
||||
private Integer isRead;
|
||||
|
||||
@ApiModelProperty(value = "加入是否需要审核")
|
||||
private Integer isCheck;
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "用户数量")
|
||||
private Integer userNum;
|
||||
|
||||
@ApiModelProperty(value = "是否管理员1是2否")
|
||||
private Integer isAdmin;
|
||||
|
||||
@ApiModelProperty(value = "距离")
|
||||
private String distance;
|
||||
|
||||
@ApiModelProperty(value = "途经位置经纬度列表")
|
||||
private List<AppCircleAddress> addressVoList;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mdd.common.mapper.AppCircleMapper">
|
||||
<sql id="circleColumns">
|
||||
a.id as "id",
|
||||
a.name as "name",
|
||||
a.img_url as "img_url",
|
||||
a.content as "content",
|
||||
a.type as "type",
|
||||
a.type_info as "typeInfo",
|
||||
a.user_id as "userId",
|
||||
a.is_sos as "isSos",
|
||||
a.sos_use as "sosUse",
|
||||
a.is_write as "isWrite",
|
||||
a.is_read as "isRead",
|
||||
a.is_check as "isCheck",
|
||||
a.longitude as "longitude",
|
||||
a.latitude as "latitude",
|
||||
a.is_delete as "isDelete",
|
||||
a.create_time as "createTime",
|
||||
a.update_time as "updateTime",
|
||||
a.delete_time as "deleteTime"
|
||||
</sql>
|
||||
|
||||
<select id="circleList" resultType="com.mdd.common.vo.AppCircleVo">
|
||||
select
|
||||
<include refid="circleColumns"/>,
|
||||
count(u.id) as "userNum",
|
||||
if(find_in_set(#{userId},a.admin_ids) > 0,1,2) as "isAdmin"
|
||||
from la_app_circle a
|
||||
left join la_app_circle_user u on a.id = u.user_id
|
||||
where a.is_delete = 0
|
||||
and a.user_id = #{userId}
|
||||
<if test="name != null and name != ''">
|
||||
and a.name like concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and a.type = #{type}
|
||||
</if>
|
||||
group by a.id
|
||||
</select>
|
||||
|
||||
<select id="recommendCircleList" resultType="com.mdd.common.vo.AppCircleVo">
|
||||
select
|
||||
<include refid="circleColumns"/>,
|
||||
count(u.id) as "userNum"
|
||||
from la_app_circle a
|
||||
left join la_app_circle_user u on a.id = u.user_id and u.is_delete = 0
|
||||
left join la_app_circle_content c on a.id = c.circle_id and c.is_delete = 0
|
||||
left join la_app_content_like l on a.id = l.circle_id
|
||||
where a.is_delete = 0
|
||||
and a.type != 1
|
||||
<if test="name != null and name != ''">
|
||||
and a.name like concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and a.type = #{type}
|
||||
</if>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
and a.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
group by a.id
|
||||
order by count(c.id),count(l.id) desc
|
||||
</select>
|
||||
|
||||
<select id="circleUserGroupUser" resultType="com.mdd.common.entity.AddressVo">
|
||||
select
|
||||
a.longitude as "longitude",
|
||||
a.latitude as "latitude"
|
||||
from la_app_circle_user a
|
||||
where a.is_delete = 0
|
||||
and a.circle_id = #{circleId}
|
||||
group by a.longitude,a.latitude
|
||||
</select>
|
||||
|
||||
<select id="listFriendByUserId">
|
||||
select
|
||||
DISTINCT(a.circle_id)
|
||||
from la_app_circle_user a
|
||||
where a.is_delete = 0
|
||||
and a.user_id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.front.aop.Log;
|
||||
import com.mdd.front.service.IAppCircleAddressService;
|
||||
import com.mdd.front.validate.common.IdValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressCreateValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressUpdateValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressSearchValidate;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.AppCircleAddressListedVo;
|
||||
import com.mdd.front.vo.AppCircleAddressDetailVo;
|
||||
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/address")
|
||||
@Api(tags = "圈子途径位置信息管理")
|
||||
public class AppCircleAddressController {
|
||||
|
||||
@Resource
|
||||
IAppCircleAddressService iAppCircleAddressService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value="圈子途径位置信息列表")
|
||||
public AjaxResult<PageResult<AppCircleAddressListedVo>> list(@Validated PageValidate pageValidate,
|
||||
@Validated AppCircleAddressSearchValidate searchValidate) {
|
||||
PageResult<AppCircleAddressListedVo> list = iAppCircleAddressService.list(pageValidate, searchValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="圈子途径位置信息详情")
|
||||
public AjaxResult<AppCircleAddressDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
AppCircleAddressDetailVo detail = iAppCircleAddressService.detail(id);
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
@Log(title = "圈子途径位置信息新增")
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value="圈子途径位置信息新增")
|
||||
public AjaxResult<Object> add(@Validated @RequestBody AppCircleAddressCreateValidate createValidate) {
|
||||
iAppCircleAddressService.add(createValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Log(title = "圈子途径位置信息编辑")
|
||||
@PostMapping("/edit")
|
||||
@ApiOperation(value="圈子途径位置信息编辑")
|
||||
public AjaxResult<Object> edit(@Validated @RequestBody AppCircleAddressUpdateValidate updateValidate) {
|
||||
iAppCircleAddressService.edit(updateValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Log(title = "圈子途径位置信息删除")
|
||||
@PostMapping("/del")
|
||||
@ApiOperation(value="圈子途径位置信息删除")
|
||||
public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
|
||||
iAppCircleAddressService.del(idValidate.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mdd.common.vo.AppCircleVo;
|
||||
import com.mdd.front.aop.Log;
|
||||
import com.mdd.front.service.IAppCircleService;
|
||||
import com.mdd.front.validate.AppCircleCreateValidate;
|
||||
|
|
@ -35,6 +37,22 @@ public class AppCircleController {
|
|||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/circleList")
|
||||
@ApiOperation(value="我的圈子列表")
|
||||
public AjaxResult<PageInfo<AppCircleVo>> circleList(@Validated PageValidate pageValidate,
|
||||
@Validated AppCircleSearchValidate searchValidate) {
|
||||
PageInfo<AppCircleVo> list = iAppCircleService.circleList(pageValidate, searchValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/recommendCircleList")
|
||||
@ApiOperation(value="推荐圈子列表")
|
||||
public AjaxResult<PageInfo<AppCircleVo>> recommendCircleList(@Validated PageValidate pageValidate,
|
||||
@Validated AppCircleSearchValidate searchValidate) {
|
||||
PageInfo<AppCircleVo> list = iAppCircleService.recommendCircleList(pageValidate, searchValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="圈子信息详情")
|
||||
public AjaxResult<AppCircleDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package com.mdd.front.service;
|
||||
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressCreateValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressUpdateValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressSearchValidate;
|
||||
import com.mdd.front.vo.AppCircleAddressListedVo;
|
||||
import com.mdd.front.vo.AppCircleAddressDetailVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息服务接口类
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
public interface IAppCircleAddressService {
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息列表
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<AppCircleAddressListedVo>
|
||||
*/
|
||||
PageResult<AppCircleAddressListedVo> list(PageValidate pageValidate, AppCircleAddressSearchValidate searchValidate);
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息详情
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param id 主键ID
|
||||
* @return AppCircleAddressDetailVo
|
||||
*/
|
||||
AppCircleAddressDetailVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息新增
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
void add(AppCircleAddressCreateValidate createValidate);
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息编辑
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
void edit(AppCircleAddressUpdateValidate updateValidate);
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息删除
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param id 主键ID
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.mdd.front.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.vo.AppCircleVo;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.validate.AppCircleCreateValidate;
|
||||
import com.mdd.front.validate.AppCircleUpdateValidate;
|
||||
|
|
@ -24,6 +26,8 @@ public interface IAppCircleService {
|
|||
* @return PageResult<AppCircleListedVo>
|
||||
*/
|
||||
PageResult<AppCircleListedVo> list(PageValidate pageValidate, AppCircleSearchValidate searchValidate);
|
||||
PageInfo<AppCircleVo> circleList(PageValidate pageValidate, AppCircleSearchValidate searchValidate);
|
||||
PageInfo<AppCircleVo> recommendCircleList(PageValidate pageValidate, AppCircleSearchValidate searchValidate);
|
||||
|
||||
/**
|
||||
* 圈子信息详情
|
||||
|
|
|
|||
|
|
@ -0,0 +1,153 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
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.front.validate.common.PageValidate;
|
||||
import com.mdd.front.service.IAppCircleAddressService;
|
||||
import com.mdd.front.validate.AppCircleAddressCreateValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressUpdateValidate;
|
||||
import com.mdd.front.validate.AppCircleAddressSearchValidate;
|
||||
import com.mdd.front.vo.AppCircleAddressListedVo;
|
||||
import com.mdd.front.vo.AppCircleAddressDetailVo;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.AppCircleAddress;
|
||||
import com.mdd.common.mapper.AppCircleAddressMapper;
|
||||
import com.mdd.common.util.ListUtils;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.common.util.UrlUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息实现类
|
||||
* @author LikeAdmin
|
||||
*/
|
||||
@Service
|
||||
public class AppCircleAddressServiceImpl implements IAppCircleAddressService {
|
||||
|
||||
@Resource
|
||||
AppCircleAddressMapper appCircleAddressMapper;
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息列表
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<AppCircleAddressListedVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<AppCircleAddressListedVo> list(PageValidate pageValidate, AppCircleAddressSearchValidate searchValidate) {
|
||||
Integer page = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<AppCircleAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
appCircleAddressMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
||||
"=:circleId@circle_id:int",
|
||||
"=:longitude:str",
|
||||
"=:latitude:str",
|
||||
});
|
||||
|
||||
IPage<AppCircleAddress> iPage = appCircleAddressMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<AppCircleAddressListedVo> list = new LinkedList<>();
|
||||
for(AppCircleAddress item : iPage.getRecords()) {
|
||||
AppCircleAddressListedVo vo = new AppCircleAddressListedVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息详情
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param id 主键参数
|
||||
* @return AppCircleAddress
|
||||
*/
|
||||
@Override
|
||||
public AppCircleAddressDetailVo detail(Integer id) {
|
||||
AppCircleAddress model = appCircleAddressMapper.selectOne(
|
||||
new QueryWrapper<AppCircleAddress>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在");
|
||||
|
||||
AppCircleAddressDetailVo vo = new AppCircleAddressDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息新增
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(AppCircleAddressCreateValidate createValidate) {
|
||||
AppCircleAddress model = new AppCircleAddress();
|
||||
model.setCircleId(createValidate.getCircleId());
|
||||
model.setLongitude(createValidate.getLongitude());
|
||||
model.setLatitude(createValidate.getLatitude());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
appCircleAddressMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息编辑
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(AppCircleAddressUpdateValidate updateValidate) {
|
||||
AppCircleAddress model = appCircleAddressMapper.selectOne(
|
||||
new QueryWrapper<AppCircleAddress>()
|
||||
.eq("id", updateValidate.getId())
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setId(updateValidate.getId());
|
||||
model.setCircleId(updateValidate.getCircleId());
|
||||
model.setLongitude(updateValidate.getLongitude());
|
||||
model.setLatitude(updateValidate.getLatitude());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
appCircleAddressMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 圈子途径位置信息删除
|
||||
*
|
||||
* @author LikeAdmin
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
AppCircleAddress model = appCircleAddressMapper.selectOne(
|
||||
new QueryWrapper<AppCircleAddress>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
appCircleAddressMapper.delete(new QueryWrapper<AppCircleAddress>().eq("id", id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,26 +3,37 @@ package com.mdd.front.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.entity.AppCircleAddress;
|
||||
import com.mdd.common.entity.AppCircleUser;
|
||||
import com.mdd.common.entity.AppFriend;
|
||||
import com.mdd.common.mapper.AppCircleAddressMapper;
|
||||
import com.mdd.common.mapper.AppCircleUserMapper;
|
||||
import com.mdd.common.mapper.AppFriendMapper;
|
||||
import com.mdd.common.vo.AppCircleVo;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.service.IAppCircleService;
|
||||
import com.mdd.front.validate.AppCircleCreateValidate;
|
||||
import com.mdd.front.validate.AppCircleUpdateValidate;
|
||||
import com.mdd.front.validate.AppCircleSearchValidate;
|
||||
import com.mdd.front.vo.AppCircleListedVo;
|
||||
|
||||
import com.mdd.front.vo.AppCircleDetailVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.AppCircle;
|
||||
import com.mdd.common.mapper.AppCircleMapper;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.front.vo.AppCircleListedVo;
|
||||
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;
|
||||
|
||||
import static java.lang.Math.*;
|
||||
|
||||
/**
|
||||
* 圈子信息实现类
|
||||
|
|
@ -34,9 +45,15 @@ public class AppCircleServiceImpl implements IAppCircleService {
|
|||
@Resource
|
||||
AppCircleMapper appCircleMapper;
|
||||
|
||||
@Resource
|
||||
AppCircleAddressMapper appCircleAddressMapper;
|
||||
|
||||
@Resource
|
||||
AppCircleUserMapper appCircleUserMapper;
|
||||
|
||||
@Resource
|
||||
AppFriendMapper appFriendMapper;
|
||||
|
||||
/**
|
||||
* 圈子信息列表
|
||||
*
|
||||
|
|
@ -84,6 +101,97 @@ public class AppCircleServiceImpl implements IAppCircleService {
|
|||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AppCircleVo> circleList(PageValidate pageValidate, AppCircleSearchValidate searchValidate) {
|
||||
AppCircle appCircle = new AppCircle();
|
||||
BeanUtils.copyProperties(searchValidate,appCircle);
|
||||
Integer pageSize = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
PageHelper.startPage(pageSize, limit);
|
||||
PageInfo<AppCircleVo> page = new PageInfo(appCircleMapper.circleList(appCircle));
|
||||
List<AppCircleVo> list = page.getList();
|
||||
for (AppCircleVo circle : list) {
|
||||
// 计算位置
|
||||
if (circle.getType() == 3) {
|
||||
circle.setDistance(calculateDistance(
|
||||
Double.valueOf(searchValidate.getLatitude()),Double.valueOf(searchValidate.getLongitude()),
|
||||
Double.valueOf(circle.getLatitude()),Double.valueOf(circle.getLongitude())));
|
||||
// 途经位置
|
||||
if (circle.getTypeInfo() == 2) {
|
||||
List<AppCircleAddress> appCircleAddresses = appCircleAddressMapper.selectList(new QueryWrapper<AppCircleAddress>()
|
||||
.eq("circle_id",circle.getId())
|
||||
);
|
||||
circle.setAddressVoList(appCircleAddresses);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AppCircleVo> recommendCircleList(PageValidate pageValidate, AppCircleSearchValidate searchValidate) {
|
||||
AppCircle appCircle = new AppCircle();
|
||||
BeanUtils.copyProperties(searchValidate,appCircle);
|
||||
if (appCircle.getType() == null) {
|
||||
appCircle.setType(2);
|
||||
}
|
||||
// 查询我的好友
|
||||
List<AppFriend> friends = appFriendMapper.selectList(new QueryWrapper<AppFriend>()
|
||||
.eq("user_id",appCircle.getUserId())
|
||||
);
|
||||
List<Integer> friendIds = friends.stream().map(x->x.getFriendId()).collect(Collectors.toList());
|
||||
// 好友的圈子
|
||||
if (friendIds != null && friendIds.size() > 0) {
|
||||
List<Integer> circleIds = appCircleMapper.listFriendByUserId(friendIds);
|
||||
appCircle.setIds(circleIds);
|
||||
}
|
||||
Integer pageSize = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
PageHelper.startPage(pageSize, limit);
|
||||
PageInfo<AppCircleVo> page = new PageInfo(appCircleMapper.recommendCircleList(appCircle));
|
||||
List<AppCircleVo> list = page.getList();
|
||||
for (AppCircleVo circle : list) {
|
||||
// 计算位置
|
||||
if (circle.getType() == 3) {
|
||||
circle.setDistance(calculateDistance(
|
||||
Double.valueOf(searchValidate.getLatitude()),Double.valueOf(searchValidate.getLongitude()),
|
||||
Double.valueOf(circle.getLatitude()),Double.valueOf(circle.getLongitude())));
|
||||
// 途经位置
|
||||
if (circle.getTypeInfo() == 2) {
|
||||
List<AppCircleAddress> appCircleAddresses = appCircleAddressMapper.selectList(new QueryWrapper<AppCircleAddress>()
|
||||
.eq("circle_id",circle.getId())
|
||||
);
|
||||
circle.setAddressVoList(appCircleAddresses);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
private static final double EARTH_RADIUS = 6371000; // 地球半径,单位米
|
||||
|
||||
public static String calculateDistance(double lat1, double lon1, double lat2, double lon2) {
|
||||
double latDistance = toRadians(lat2 - lat1);
|
||||
double lonDistance = toRadians(lon2 - lon2);
|
||||
double a = sin(latDistance / 2) * sin(latDistance / 2) +
|
||||
cos(toRadians(lat1)) * cos(toRadians(lat2)) *
|
||||
sin(lonDistance / 2) * sin(lonDistance / 2);
|
||||
double c = 2 * atan2(sqrt(a), sqrt(1 - a));
|
||||
String d = (EARTH_RADIUS * c) + "";
|
||||
d = d.substring(0,d.indexOf("."));
|
||||
return d;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 示例:计算从当前地址(纬度40.7128,经度-74.0060)到另一个地址的距离
|
||||
String distance = calculateDistance(31.191648
|
||||
, 121.313248, 31.183105
|
||||
, 121.263785);
|
||||
System.out.println("距离: " + distance + " 米");
|
||||
}
|
||||
|
||||
/**
|
||||
* 圈子信息详情
|
||||
*
|
||||
|
|
@ -137,6 +245,7 @@ public class AppCircleServiceImpl implements IAppCircleService {
|
|||
model.setLatitude(createValidate.getLatitude());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setAdminIds(model.getUserId() + ",");
|
||||
appCircleMapper.insert(model);
|
||||
|
||||
// 保存群主为群内用户信息
|
||||
|
|
@ -146,7 +255,17 @@ public class AppCircleServiceImpl implements IAppCircleService {
|
|||
appCircleUser.setUserId(createValidate.getUserId());
|
||||
appCircleUser.setLatitude(createValidate.getLatitude());
|
||||
appCircleUser.setLongitude(createValidate.getLongitude());
|
||||
appCircleUser.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
appCircleUserMapper.insert(appCircleUser);
|
||||
|
||||
if (createValidate.getTypeInfo() == 2) {
|
||||
AppCircleAddress appCircleAddress = new AppCircleAddress();
|
||||
appCircleAddress.setCircleId(model.getId());
|
||||
appCircleAddress.setLatitude(model.getLatitude());
|
||||
appCircleAddress.setLongitude(model.getLongitude());
|
||||
appCircleAddress.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
appCircleAddressMapper.insert(appCircleAddress);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
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 AppCircleAddressCreateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "circleId参数缺失")
|
||||
@ApiModelProperty(value = "圈子id")
|
||||
private Integer circleId;
|
||||
|
||||
@NotNull(message = "longitude参数缺失")
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@NotNull(message = "latitude参数缺失")
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
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 AppCircleAddressSearchValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "圈子id")
|
||||
private Integer circleId;
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
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 AppCircleAddressUpdateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0")
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "circleId参数缺失")
|
||||
@ApiModelProperty(value = "圈子id")
|
||||
private Integer circleId;
|
||||
|
||||
@NotNull(message = "longitude参数缺失")
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@NotNull(message = "latitude参数缺失")
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
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 AppCircleAddressDetailVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "圈子id")
|
||||
private Integer circleId;
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
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 AppCircleAddressListedVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "圈子id")
|
||||
private Integer circleId;
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String latitude;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import com.mdd.common.entity.AddressVo;
|
||||
import com.mdd.common.entity.AppCircleAddress;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("圈子信息列表Vo")
|
||||
|
|
@ -57,5 +60,17 @@ public class AppCircleListedVo implements Serializable {
|
|||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "用户数量")
|
||||
private Integer userNum;
|
||||
|
||||
@ApiModelProperty(value = "是否管理员1是2否")
|
||||
private Integer isAdmin;
|
||||
|
||||
@ApiModelProperty(value = "距离")
|
||||
private String distance;
|
||||
|
||||
@ApiModelProperty(value = "途经位置经纬度列表")
|
||||
private List<AppCircleAddress> addressVoList;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue