@@ -0,0 +1,108 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.domain.WestreamScenery; | |||
import com.tuoheng.api.entity.domain.WestreamUser; | |||
import com.tuoheng.api.entity.request.OnlineNumQuery; | |||
import com.tuoheng.api.entity.request.WestreamActQuery; | |||
import com.tuoheng.api.entity.request.WestreamKnowQuery; | |||
import com.tuoheng.api.entity.request.WestreamSceneryQuery; | |||
import com.tuoheng.api.service.IWestreamActService; | |||
import com.tuoheng.api.service.IWestreamKnowService; | |||
import com.tuoheng.api.service.IWestreamSceneryService; | |||
import com.tuoheng.api.service.IWestreamUserService; | |||
import com.tuoheng.common.common.OperationEnum; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* 首页 前端控制器 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@RestController | |||
@RequestMapping("/index") | |||
public class IndexController { | |||
@Autowired | |||
IWestreamActService westreamActService; | |||
@Autowired | |||
IWestreamKnowService westreamKnowService; | |||
@Autowired | |||
IWestreamSceneryService westreamSceneryService; | |||
@Autowired | |||
IWestreamUserService westreamUserService; | |||
/** | |||
* 获取全民护河公告列表(分页) | |||
* | |||
* @param westreamActQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/westreamAct/page") | |||
public JsonResult westreamActPage(WestreamActQuery westreamActQuery) { | |||
return westreamActService.queryPage(westreamActQuery); | |||
} | |||
/** | |||
* 获取全民护河知识列表(分页) | |||
* | |||
* @param westreamKnowQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/westreamKnow/page") | |||
public JsonResult westreamKnowPage(WestreamKnowQuery westreamKnowQuery) { | |||
return westreamKnowService.queryPage(westreamKnowQuery); | |||
} | |||
/** | |||
* 获取全民护河美景列表(分页) | |||
* | |||
* @param westreamSceneryQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/westreamScenery/page") | |||
public JsonResult westreamSceneryPage(WestreamSceneryQuery westreamSceneryQuery) { | |||
return westreamSceneryService.queryPage(westreamSceneryQuery); | |||
} | |||
/** | |||
* 大好河山-发布 | |||
* | |||
* @param westreamScenery | |||
* @return | |||
*/ | |||
@PostMapping("/westreamScenery/submit") | |||
public JsonResult submit(@RequestBody WestreamScenery westreamScenery){ | |||
return westreamSceneryService.submit(westreamScenery); | |||
} | |||
/** | |||
* 获取在线人数 | |||
* | |||
* @param | |||
* @return | |||
*/ | |||
@GetMapping("/westreamUser/onlineNum") | |||
public JsonResult onlineNum(OnlineNumQuery query) { | |||
return westreamUserService.onlineNum(query); | |||
} | |||
/** | |||
* 编辑微信小程序用户 | |||
* | |||
* @param westreamUser 实体对象 | |||
* @return | |||
*/ | |||
@PutMapping("/westreamUser/edit") | |||
public JsonResult edit(@RequestBody WestreamUser westreamUser) { | |||
return westreamSceneryService.editInfo(westreamUser); | |||
} | |||
} |
@@ -31,6 +31,16 @@ public class StreamController { | |||
return streamService.queryPage(streamQuery); | |||
} | |||
/** | |||
* 获取河流列表 | |||
* | |||
* @param streamQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/indexAll") | |||
public JsonResult indexAll(StreamQuery streamQuery) { | |||
return streamService.indexAll(streamQuery); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.request.FeedbackQuery; | |||
import com.tuoheng.api.entity.request.WestreamSceneryQuery; | |||
import com.tuoheng.api.service.IWestreamSceneryService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 美拍 前端控制器 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@RestController | |||
@RequestMapping("/westreamScenery") | |||
public class WestreamSceneryController { | |||
@Autowired | |||
IWestreamSceneryService westreamSceneryService; | |||
/** | |||
* 我的美拍 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/my") | |||
public JsonResult my(WestreamSceneryQuery query) { | |||
return westreamSceneryService.my(query); | |||
} | |||
} |
@@ -0,0 +1,70 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
/** | |||
* 全民护河公告表 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_act") | |||
public class WestreamAct extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 省份编号 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 市区编号 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编号 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 通知标题 | |||
*/ | |||
private String title; | |||
/** | |||
* 公告摘要 | |||
*/ | |||
private String guide; | |||
/** | |||
* 图片地址 | |||
*/ | |||
private String image; | |||
/** | |||
* 通知内容 | |||
*/ | |||
private String content; | |||
/** | |||
* 状态:1已发布 2待发布 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,70 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
/** | |||
* 全民护河知识表 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_know") | |||
public class WestreamKnow extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 省份编号 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 市区编号 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编号 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 知识标题 | |||
*/ | |||
private String title; | |||
/** | |||
* 知识摘要 | |||
*/ | |||
private String guide; | |||
/** | |||
* 图片地址 | |||
*/ | |||
private String image; | |||
/** | |||
* 知识内容 | |||
*/ | |||
private String content; | |||
/** | |||
* 状态:1已发布 2待发布 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,93 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 全民护河知识表 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_scenery") | |||
public class WestreamScenery extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 提交人openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 用户昵称 | |||
*/ | |||
@TableField(exist = false) | |||
private String nickname; | |||
/** | |||
* 用户头像 | |||
*/ | |||
@TableField(exist = false) | |||
private String headimgurl; | |||
/** | |||
* 河流ID | |||
*/ | |||
private Integer streamId; | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 描述 | |||
*/ | |||
private String content; | |||
/** | |||
* 图片地址 | |||
*/ | |||
private String image; | |||
/** | |||
* 审核备注 | |||
*/ | |||
private String remark; | |||
/** | |||
* 审核时间 | |||
*/ | |||
private Date examineTime; | |||
/** | |||
* 审核状态:1待审核 2通过 3驳回 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,73 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 全民护河用户表 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-20 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_user") | |||
public class WestreamUser extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 用户openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 用户昵称 | |||
*/ | |||
private String nickname; | |||
/** | |||
* 用户头像 | |||
*/ | |||
private String headimgurl; | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 心跳时间 | |||
*/ | |||
private Date heartbeatTime; | |||
/** | |||
* 用户状态 1 在线 2 离线 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.tuoheng.api.entity.request; | |||
import lombok.Data; | |||
@Data | |||
public class OnlineNumQuery { | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 全民护河公告查询 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Data | |||
public class WestreamActQuery extends BaseQuery { | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
} |
@@ -0,0 +1,30 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 全民护河知识查询 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Data | |||
public class WestreamKnowQuery extends BaseQuery { | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 全民护河美景查询 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Data | |||
public class WestreamSceneryQuery extends BaseQuery { | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 用户openid | |||
*/ | |||
private String openid; | |||
} |
@@ -0,0 +1,13 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamAct; | |||
/** | |||
* 全民护河公告表 Mapper 接口 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
public interface WestreamActMapper extends BaseMapper<WestreamAct> { | |||
} |
@@ -0,0 +1,13 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamKnow; | |||
/** | |||
* 全民护河知识表 Mapper 接口 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
public interface WestreamKnowMapper extends BaseMapper<WestreamKnow> { | |||
} |
@@ -0,0 +1,13 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamScenery; | |||
/** | |||
* 全民护河美景表 Mapper 接口 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
public interface WestreamSceneryMapper extends BaseMapper<WestreamScenery> { | |||
} |
@@ -0,0 +1,13 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamUser; | |||
/** | |||
* 全民护河用户表 Mapper 接口 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-20 | |||
*/ | |||
public interface WestreamUserMapper extends BaseMapper<WestreamUser> { | |||
} |
@@ -23,4 +23,5 @@ public interface IStreamService extends IBaseService<Stream> { | |||
*/ | |||
JsonResult queryPage(StreamQuery query); | |||
JsonResult indexAll(StreamQuery streamQuery); | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.WestreamAct; | |||
import com.tuoheng.api.entity.request.WestreamActQuery; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 全民护河公告表 服务类 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
public interface IWestreamActService extends IBaseService<WestreamAct> { | |||
JsonResult queryPage(WestreamActQuery westreamActQuery); | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.WestreamKnow; | |||
import com.tuoheng.api.entity.request.WestreamKnowQuery; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 全民护河知识表 服务类 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
public interface IWestreamKnowService extends IBaseService<WestreamKnow> { | |||
JsonResult queryPage(WestreamKnowQuery westreamKnowQuery); | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.WestreamScenery; | |||
import com.tuoheng.api.entity.domain.WestreamUser; | |||
import com.tuoheng.api.entity.request.WestreamSceneryQuery; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
public interface IWestreamSceneryService extends IBaseService<WestreamScenery> { | |||
JsonResult queryPage(WestreamSceneryQuery westreamSceneryQuery); | |||
JsonResult submit(WestreamScenery westreamScenery); | |||
JsonResult my(WestreamSceneryQuery query); | |||
JsonResult editInfo(WestreamUser westreamUser); | |||
} |
@@ -0,0 +1,10 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.WestreamUser; | |||
import com.tuoheng.api.entity.request.OnlineNumQuery; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
public interface IWestreamUserService extends IBaseService<WestreamUser> { | |||
JsonResult onlineNum(OnlineNumQuery query); | |||
} |
@@ -20,6 +20,8 @@ import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* 河道表 服务实现类 | |||
@@ -91,4 +93,15 @@ public class StreamServiceImpl extends BaseServiceImpl<StreamMapper, Stream> imp | |||
return JsonResult.success(pageData); | |||
} | |||
@Override | |||
public JsonResult indexAll(StreamQuery query) { | |||
List<Stream> streamList = streamMapper.selectList(new LambdaQueryWrapper<Stream>() | |||
.eq(Stream::getMark, 1) | |||
.eq(StringUtils.isNotEmpty(query.getProvinceCode()), Stream::getProvinceCode, query.getProvinceCode()) | |||
.eq(StringUtils.isNotEmpty(query.getCityCode()), Stream::getCityCode, query.getCityCode()) | |||
.eq(StringUtils.isNotEmpty(query.getDistrictCode()), Stream::getDistrictCode, query.getDistrictCode()) | |||
.orderByDesc(Stream::getCreateTime)); | |||
return JsonResult.success(streamList); | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
package com.tuoheng.api.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.api.entity.domain.Stream; | |||
import com.tuoheng.api.entity.domain.WestreamAct; | |||
import com.tuoheng.api.entity.request.WestreamActQuery; | |||
import com.tuoheng.api.mapper.StreamMapper; | |||
import com.tuoheng.api.mapper.WestreamActMapper; | |||
import com.tuoheng.api.service.IWestreamActService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 全民护河公告表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Service | |||
public class WestreamActServiceImpl extends BaseServiceImpl<WestreamActMapper, WestreamAct> implements IWestreamActService { | |||
@Autowired | |||
private WestreamActMapper westreamActMapper; | |||
@Override | |||
public JsonResult queryPage(WestreamActQuery query) { | |||
if (null == query.getPage() || null == query.getLimit()) { | |||
return JsonResult.error("参数为空!"); | |||
} | |||
// 获取分页数据 | |||
IPage<WestreamAct> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<WestreamAct> pageData = westreamActMapper.selectPage(page, new LambdaQueryWrapper<WestreamAct>() | |||
.eq(WestreamAct::getMark, 1) | |||
.eq(StringUtils.isNotEmpty(query.getProvinceCode()), WestreamAct::getProvinceCode, query.getProvinceCode()) | |||
.eq(StringUtils.isNotEmpty(query.getCityCode()), WestreamAct::getCityCode, query.getCityCode()) | |||
.eq(StringUtils.isNotEmpty(query.getDistrictCode()), WestreamAct::getDistrictCode, query.getDistrictCode()) | |||
.orderByDesc(WestreamAct::getCreateTime)); | |||
for (WestreamAct record : pageData.getRecords()) { | |||
if(StringUtils.isNotEmpty(record.getImage())){ | |||
record.setImage(CommonUtils.getMultipleUrl(record.getImage())); | |||
} | |||
} | |||
return JsonResult.success(pageData); | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
package com.tuoheng.api.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.api.entity.domain.WestreamAct; | |||
import com.tuoheng.api.entity.domain.WestreamKnow; | |||
import com.tuoheng.api.entity.request.WestreamKnowQuery; | |||
import com.tuoheng.api.mapper.WestreamKnowMapper; | |||
import com.tuoheng.api.service.IWestreamKnowService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 全民护河知识表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Service | |||
public class WestreamKnowServiceImpl extends BaseServiceImpl<WestreamKnowMapper, WestreamKnow> implements IWestreamKnowService { | |||
@Autowired | |||
private WestreamKnowMapper westreamKnowMapper; | |||
@Override | |||
public JsonResult queryPage(WestreamKnowQuery query) { | |||
if (null == query.getPage() || null == query.getLimit()) { | |||
return JsonResult.error("参数为空!"); | |||
} | |||
// 获取分页数据 | |||
IPage<WestreamKnow> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<WestreamKnow> pageData = westreamKnowMapper.selectPage(page, new LambdaQueryWrapper<WestreamKnow>() | |||
.eq(WestreamKnow::getMark, 1) | |||
.eq(StringUtils.isNotEmpty(query.getProvinceCode()), WestreamKnow::getProvinceCode, query.getProvinceCode()) | |||
.eq(StringUtils.isNotEmpty(query.getCityCode()), WestreamKnow::getCityCode, query.getCityCode()) | |||
.eq(StringUtils.isNotEmpty(query.getDistrictCode()), WestreamKnow::getDistrictCode, query.getDistrictCode()) | |||
.orderByDesc(WestreamKnow::getCreateTime)); | |||
for (WestreamKnow record : pageData.getRecords()) { | |||
if(StringUtils.isNotEmpty(record.getImage())){ | |||
record.setImage(CommonUtils.getMultipleUrl(record.getImage())); | |||
} | |||
} | |||
return JsonResult.success(pageData); | |||
} | |||
} |
@@ -0,0 +1,138 @@ | |||
package com.tuoheng.api.service.impl; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.api.entity.domain.*; | |||
import com.tuoheng.api.entity.request.WestreamSceneryQuery; | |||
import com.tuoheng.api.mapper.StreamMapper; | |||
import com.tuoheng.api.mapper.WestreamSceneryMapper; | |||
import com.tuoheng.api.mapper.WestreamUserMapper; | |||
import com.tuoheng.api.service.IWestreamSceneryService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.common.OperationEnum; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.Date; | |||
/** | |||
* 全民护河美景表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-16 | |||
*/ | |||
@Service | |||
public class WestreamSceneryServiceImpl extends BaseServiceImpl<WestreamSceneryMapper, WestreamScenery> implements IWestreamSceneryService { | |||
@Autowired | |||
private WestreamSceneryMapper westreamSceneryMapper; | |||
@Autowired | |||
private WestreamUserMapper westreamUserMapper; | |||
@Autowired | |||
private StreamMapper streamMapper; | |||
@Override | |||
public JsonResult queryPage(WestreamSceneryQuery query) { | |||
if (null == query.getPage() || null == query.getLimit()) { | |||
return JsonResult.error("参数为空!"); | |||
} | |||
// 获取分页数据 | |||
IPage<WestreamScenery> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<WestreamScenery> pageData = westreamSceneryMapper.selectPage(page, new LambdaQueryWrapper<WestreamScenery>() | |||
.eq(WestreamScenery::getMark, 1) | |||
.eq(WestreamScenery::getStatus,2) | |||
.eq(StringUtils.isNotEmpty(query.getProvinceCode()), WestreamScenery::getProvinceCode, query.getProvinceCode()) | |||
.eq(StringUtils.isNotEmpty(query.getCityCode()), WestreamScenery::getCityCode, query.getCityCode()) | |||
.eq(StringUtils.isNotEmpty(query.getDistrictCode()), WestreamScenery::getDistrictCode, query.getDistrictCode()) | |||
.orderByDesc(WestreamScenery::getCreateTime)); | |||
for (WestreamScenery record : pageData.getRecords()) { | |||
//查询微信用户昵称和头像 | |||
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>() | |||
.eq(WestreamUser::getOpenid, record.getOpenid()) | |||
.eq(WestreamUser::getMark, 1)); | |||
if(ObjectUtil.isNotNull(westreamUser)){ | |||
record.setNickname(westreamUser.getNickname()); | |||
record.setHeadimgurl(westreamUser.getHeadimgurl()); | |||
} | |||
//拼接图片域名 | |||
if(StringUtils.isNotEmpty(record.getImage())){ | |||
record.setImage(CommonUtils.getMultipleUrl(record.getImage())); | |||
} | |||
} | |||
return JsonResult.success(pageData); | |||
} | |||
@Override | |||
public JsonResult submit(WestreamScenery westreamScenery) { | |||
//查询河流信息 | |||
Stream stream = streamMapper.selectById(westreamScenery.getStreamId()); | |||
if(ObjectUtil.isEmpty(stream)){ | |||
return JsonResult.error("河流信息为空"); | |||
} | |||
westreamScenery.setProvinceCode(stream.getProvinceCode()); | |||
westreamScenery.setCityCode(stream.getCityCode()); | |||
westreamScenery.setDistrictCode(stream.getDistrictCode()); | |||
westreamScenery.setTenantId(stream.getTenantId()); | |||
westreamScenery.setCreateTime(new Date()); | |||
westreamSceneryMapper.insert(westreamScenery); | |||
return JsonResult.success(); | |||
} | |||
@Override | |||
public JsonResult my(WestreamSceneryQuery query) { | |||
if (null == query.getPage() || null == query.getLimit()) { | |||
return JsonResult.error("分页数据为空"); | |||
} | |||
if (StringUtils.isEmpty(query.getOpenid())) { | |||
return JsonResult.error("openid为空"); | |||
} | |||
// 获取分页数据 | |||
IPage<WestreamScenery> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<WestreamScenery> pageData = westreamSceneryMapper.selectPage(page, new LambdaQueryWrapper<WestreamScenery>() | |||
.eq(WestreamScenery::getMark, 1) | |||
.eq(WestreamScenery::getOpenid, query.getOpenid()) | |||
.orderByDesc(WestreamScenery::getCreateTime)); | |||
for (WestreamScenery record : pageData.getRecords()) { | |||
if(StringUtils.isNotEmpty(record.getImage())){ | |||
record.setImage(CommonUtils.getMultipleUrl(record.getImage())); | |||
} | |||
} | |||
return JsonResult.success(pageData); | |||
} | |||
@Override | |||
public JsonResult editInfo(WestreamUser entity) { | |||
if (StringUtils.isEmpty(entity.getOpenid())) { | |||
return JsonResult.error("openid为空"); | |||
} | |||
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>() | |||
.eq(WestreamUser::getOpenid, entity.getOpenid()) | |||
.eq(WestreamUser::getMark, 1)); | |||
entity.setStatus(1); | |||
if(ObjectUtil.isNull(westreamUser)){ | |||
//新增 | |||
entity.setHeartbeatTime(new Date()); | |||
westreamUserMapper.insert(entity); | |||
}else { | |||
// 编辑 | |||
entity.setHeartbeatTime(new Date()); | |||
westreamUserMapper.update(entity,new LambdaQueryWrapper<WestreamUser>() | |||
.eq(WestreamUser::getOpenid,entity.getOpenid()) | |||
.eq(WestreamUser::getMark, 1)); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.api.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.api.entity.domain.WestreamScenery; | |||
import com.tuoheng.api.entity.domain.WestreamUser; | |||
import com.tuoheng.api.entity.request.OnlineNumQuery; | |||
import com.tuoheng.api.mapper.WestreamUserMapper; | |||
import com.tuoheng.api.service.IWestreamUserService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 全民护河用户表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2023-03-20 | |||
*/ | |||
@Service | |||
public class WestreamUserServiceImpl extends BaseServiceImpl<WestreamUserMapper, WestreamUser> implements IWestreamUserService { | |||
@Autowired | |||
private WestreamUserMapper westreamUserMapper; | |||
@Override | |||
public JsonResult onlineNum(OnlineNumQuery query) { | |||
Integer count = westreamUserMapper.selectCount(new LambdaQueryWrapper<WestreamUser>() | |||
.eq(StringUtils.isNotEmpty(query.getProvinceCode()), WestreamUser::getProvinceCode, query.getProvinceCode()) | |||
.eq(StringUtils.isNotEmpty(query.getCityCode()), WestreamUser::getCityCode, query.getCityCode()) | |||
.eq(StringUtils.isNotEmpty(query.getDistrictCode()), WestreamUser::getDistrictCode, query.getDistrictCode()) | |||
.eq(WestreamUser::getMark, 1) | |||
.eq(WestreamUser::getStatus, 1)); | |||
return JsonResult.success(count); | |||
} | |||
} |
@@ -6,10 +6,7 @@ import org.springframework.util.CollectionUtils; | |||
import java.lang.reflect.Field; | |||
import java.security.MessageDigest; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.*; | |||
import java.util.function.Consumer; | |||
import java.util.regex.Matcher; | |||
import java.util.regex.Pattern; | |||
@@ -30,6 +27,20 @@ public class CommonUtils { | |||
return CommonConfig.imageURL + imageUrl; | |||
} | |||
/** | |||
* 多个url进行转换,用,号隔开 | |||
* | |||
* @param url | |||
* @return | |||
*/ | |||
public static String getMultipleUrl(String url) { | |||
List<String> collect = Arrays.asList(url.split(",")).stream().map(s -> getImageURL(s)).collect(Collectors.toList()); | |||
//返回 | |||
return org.apache.commons.lang3.StringUtils.join(collect, ","); | |||
} | |||
/** | |||
* 正则匹配富文本图片 | |||
* |