18 changed files with 851 additions and 4 deletions
@ -0,0 +1,43 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.common.token.dto.TokenDto; |
|||
import com.elink.esua.epdc.commons.tools.annotation.LoginUser; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|||
import com.elink.esua.epdc.service.TopicService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* |
|||
* 移动端接口-话题模块 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 14:44 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("group/topic") |
|||
public class ApiTopicController { |
|||
|
|||
@Autowired |
|||
private TopicService topicService; |
|||
|
|||
/** |
|||
* |
|||
* 发布话题 |
|||
* |
|||
* @params [userDetail, formDto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author liuchuang |
|||
* @since 2019/11/6 14:46 |
|||
*/ |
|||
@PostMapping("submit") |
|||
public Result submit(@LoginUser TokenDto userDetail, @RequestBody TopicSubmitFormDTO formDto) { |
|||
ValidatorUtils.validateEntity(formDto); |
|||
return topicService.saveTopic(userDetail, formDto); |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|||
import com.elink.esua.epdc.feign.fallback.TopicFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
|
|||
/** |
|||
* |
|||
* 社群-话题模块调用 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 15:36 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_GROUP_SERVER, fallback = TopicFeignClientFallback.class) |
|||
public interface TopicFeignClient { |
|||
|
|||
/** |
|||
* |
|||
* 发布话题 |
|||
* |
|||
* @params [formDto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author liuchuang |
|||
* @since 2019/11/6 15:40 |
|||
*/ |
|||
@PostMapping(value = "group/epdc-app/topic/submit", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result submit(TopicSubmitFormDTO formDto); |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|||
import com.elink.esua.epdc.feign.TopicFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 15:36 |
|||
*/ |
|||
@Component |
|||
public class TopicFeignClientFallback implements TopicFeignClient { |
|||
|
|||
@Override |
|||
public Result submit(TopicSubmitFormDTO formDto) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_GROUP_SERVER, "submit", formDto); |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.common.token.dto.TokenDto; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|||
|
|||
/** |
|||
* |
|||
* 话题模块 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 14:48 |
|||
*/ |
|||
public interface TopicService { |
|||
|
|||
/** |
|||
* |
|||
* 发布话题 |
|||
* |
|||
* @params [userDetail, formDto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author liuchuang |
|||
* @since 2019/11/6 14:51 |
|||
*/ |
|||
Result saveTopic(TokenDto userDetail, TopicSubmitFormDTO formDto); |
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.elink.esua.epdc.common.token.dto.TokenDto; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.CompleteDeptDTO; |
|||
import com.elink.esua.epdc.dto.enums.TopicStateEnum; |
|||
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|||
import com.elink.esua.epdc.feign.AdminFeignClient; |
|||
import com.elink.esua.epdc.feign.TopicFeignClient; |
|||
import com.elink.esua.epdc.service.TopicService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* |
|||
* 话题模块 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 14:48 |
|||
*/ |
|||
@Service |
|||
public class TopicServiceImpl implements TopicService { |
|||
|
|||
@Autowired |
|||
private AdminFeignClient adminFeignClient; |
|||
|
|||
@Autowired |
|||
private TopicFeignClient topicFeignClient; |
|||
|
|||
@Override |
|||
public Result saveTopic(TokenDto userDetail, TopicSubmitFormDTO formDto) { |
|||
if (null == userDetail) { |
|||
return new Result().error("获取用户信息失败"); |
|||
} |
|||
|
|||
// 获取该网格所有上级机构
|
|||
Result<CompleteDeptDTO> deptDTOResult = adminFeignClient.getCompleteDept(userDetail.getGridId()); |
|||
CompleteDeptDTO deptDTO = deptDTOResult.getData(); |
|||
formDto.setArea(deptDTO.getDistrict()); |
|||
formDto.setAreaId(deptDTO.getDistrictId()); |
|||
formDto.setStreet(deptDTO.getStreet()); |
|||
formDto.setStreetId(deptDTO.getStreetId()); |
|||
formDto.setCommunity(deptDTO.getCommunity()); |
|||
formDto.setCommunityId(deptDTO.getCommunityId()); |
|||
formDto.setGrid(deptDTO.getGrid()); |
|||
formDto.setGridId(deptDTO.getGridId()); |
|||
|
|||
formDto.setUserId(userDetail.getUserId()); |
|||
formDto.setUserFace(userDetail.getFaceImg()); |
|||
formDto.setNickname(userDetail.getNickname()); |
|||
formDto.setPartyMember(userDetail.getPartyFlag()); |
|||
formDto.setState(TopicStateEnum.TOPIC_STATE_IN_CONVERSATION.getValue()); |
|||
|
|||
return topicFeignClient.submit(formDto); |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.elink.esua.epdc.dto.constant; |
|||
|
|||
/** |
|||
* |
|||
* 图片类型 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 16:17 |
|||
*/ |
|||
public interface TopicImageConstant { |
|||
|
|||
/** |
|||
* 图片类型-事件 |
|||
*/ |
|||
String TYPE_IMAGE_BIZ_TOPIC = "topic"; |
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.elink.esua.epdc.dto.enums; |
|||
|
|||
/** |
|||
* |
|||
* 话题状态枚举 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 15:11 |
|||
*/ |
|||
public enum TopicStateEnum { |
|||
|
|||
/** |
|||
* 0-讨论中 |
|||
*/ |
|||
TOPIC_STATE_IN_CONVERSATION(0, "讨论中"), |
|||
/** |
|||
* 5-转议题待审核 |
|||
*/ |
|||
TOPIC_STATE_CHANGE_TO_ISSUE_PENDING_REVIEW(5, "转议题待审核"), |
|||
/** |
|||
* 10-已转议题 |
|||
*/ |
|||
TOPIC_STATE_CHANGED_ISSUE(10, "已转议题"), |
|||
/** |
|||
* 15-已转项目 |
|||
*/ |
|||
TOPIC_STATE_CHANGED_ITEM(15, "已转项目"), |
|||
/** |
|||
* 20-已关闭 |
|||
*/ |
|||
TOPIC_STATE_CLOSED(20, "已关闭"); |
|||
|
|||
private Integer value; |
|||
private String name; |
|||
|
|||
TopicStateEnum(Integer value, String name) { |
|||
this.value = value; |
|||
this.name = name; |
|||
} |
|||
|
|||
public Integer getValue() { |
|||
return value; |
|||
} |
|||
|
|||
public void setValue(Integer value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
} |
@ -0,0 +1,86 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dto.topic; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 话题图片表 话题图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-11-06 |
|||
*/ |
|||
@Data |
|||
public class TopicImgDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 引用ID |
|||
*/ |
|||
private String referenceId; |
|||
|
|||
/** |
|||
* 图片地址 |
|||
*/ |
|||
private String imgUrl; |
|||
|
|||
/** |
|||
* 图片类型 |
|||
*/ |
|||
private String imgType; |
|||
|
|||
/** |
|||
* 删除标记 0:未删除,1:删除 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,126 @@ |
|||
package com.elink.esua.epdc.dto.topic.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.Size; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* |
|||
* 发布话题Form DTO |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 14:33 |
|||
*/ |
|||
@Data |
|||
public class TopicSubmitFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 7888315361241643792L; |
|||
|
|||
/** |
|||
* 话题内容 |
|||
*/ |
|||
@NotBlank(message = "话题内容不能为空且在2000个字以内") |
|||
@Size(min = 1, max = 2000, message = "话题内容不能为空且在2000个字以内") |
|||
private String topicContent; |
|||
|
|||
/** |
|||
* 图片 |
|||
*/ |
|||
private List<String> images; |
|||
|
|||
/** |
|||
* 话题地址 |
|||
*/ |
|||
@NotBlank(message = "话题地址不能为空") |
|||
private String topicAddress; |
|||
|
|||
/** |
|||
* 话题位置纬度 |
|||
*/ |
|||
private Double topicLatitude; |
|||
|
|||
/** |
|||
* 话题位置经度 |
|||
*/ |
|||
private Double topicLongitude; |
|||
|
|||
/** |
|||
* 友邻社群 |
|||
*/ |
|||
@NotBlank(message = "友邻社群名称不能为空") |
|||
private String groupName; |
|||
|
|||
/** |
|||
* 友邻社群ID |
|||
*/ |
|||
@NotBlank(message = "友邻社群ID不能为空") |
|||
private String groupId; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 用户昵称 |
|||
*/ |
|||
private String nickname; |
|||
|
|||
/** |
|||
* 用户头像 |
|||
*/ |
|||
private String userFace; |
|||
|
|||
/** |
|||
* 党员标识 0:否,1:是 |
|||
*/ |
|||
private String partyMember; |
|||
|
|||
/** |
|||
* 区 |
|||
*/ |
|||
private String area; |
|||
|
|||
/** |
|||
* 区ID |
|||
*/ |
|||
private Long areaId; |
|||
|
|||
/** |
|||
* 街道 |
|||
*/ |
|||
private String street; |
|||
|
|||
/** |
|||
* 街道ID |
|||
*/ |
|||
private Long streetId; |
|||
|
|||
/** |
|||
* 社区 |
|||
*/ |
|||
private String community; |
|||
|
|||
/** |
|||
* 社区ID |
|||
*/ |
|||
private Long communityId; |
|||
|
|||
/** |
|||
* 网格 |
|||
*/ |
|||
private String grid; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private Long gridId; |
|||
|
|||
/** |
|||
* 状态 0:讨论中,5:转议题待审核,10:转议题审核不通过,15:已转议题,20:已转项目,25:已关闭 |
|||
*/ |
|||
private Integer state; |
|||
|
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.elink.esua.epdc.modules.topic.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; |
|||
import com.elink.esua.epdc.modules.topic.service.TopicService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* |
|||
* 移动端-话题模块 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/6 15:43 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(Constant.EPDC_APP + "topic") |
|||
public class AppTopicController { |
|||
|
|||
@Autowired |
|||
private TopicService topicService; |
|||
|
|||
/** |
|||
* |
|||
* 发布话题 |
|||
* |
|||
* @params [formDto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author liuchuang |
|||
* @since 2019/11/6 15:52 |
|||
*/ |
|||
@PostMapping("submit") |
|||
public Result submit(@RequestBody TopicSubmitFormDTO formDto) { |
|||
return topicService.saveTopic(formDto); |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.topic.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.modules.topic.entity.TopicImgEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 话题图片表 话题图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-11-06 |
|||
*/ |
|||
@Mapper |
|||
public interface TopicImgDao extends BaseDao<TopicImgEntity> { |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.topic.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 话题图片表 话题图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-11-06 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_topic_img") |
|||
public class TopicImgEntity extends BaseEpdcEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 引用ID |
|||
*/ |
|||
private String referenceId; |
|||
|
|||
/** |
|||
* 图片地址 |
|||
*/ |
|||
private String imgUrl; |
|||
|
|||
/** |
|||
* 图片类型 |
|||
*/ |
|||
private String imgType; |
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.topic.service; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.dto.topic.TopicImgDTO; |
|||
import com.elink.esua.epdc.modules.topic.entity.TopicImgEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 话题图片表 话题图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-11-06 |
|||
*/ |
|||
public interface TopicImgService extends BaseService<TopicImgEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<TopicImgDTO> |
|||
* @author generator |
|||
* @date 2019-11-06 |
|||
*/ |
|||
PageData<TopicImgDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<TopicImgDTO> |
|||
* @author generator |
|||
* @date 2019-11-06 |
|||
*/ |
|||
List<TopicImgDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return TopicImgDTO |
|||
* @author generator |
|||
* @date 2019-11-06 |
|||
*/ |
|||
TopicImgDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2019-11-06 |
|||
*/ |
|||
void save(TopicImgDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2019-11-06 |
|||
*/ |
|||
void update(TopicImgDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2019-11-06 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* |
|||
* 保存图片 |
|||
* |
|||
* @params [images, referenceId, imgType] |
|||
* @return boolean |
|||
* @author liuchuang |
|||
* @since 2019/11/6 16:20 |
|||
*/ |
|||
boolean saveImages(List<String> images, String referenceId, String imgType); |
|||
} |
@ -0,0 +1,119 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.topic.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.dto.topic.TopicImgDTO; |
|||
import com.elink.esua.epdc.modules.topic.dao.TopicImgDao; |
|||
import com.elink.esua.epdc.modules.topic.entity.TopicImgEntity; |
|||
import com.elink.esua.epdc.modules.topic.service.TopicImgService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 话题图片表 话题图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-11-06 |
|||
*/ |
|||
@Service |
|||
public class TopicImgServiceImpl extends BaseServiceImpl<TopicImgDao, TopicImgEntity> implements TopicImgService { |
|||
|
|||
@Override |
|||
public PageData<TopicImgDTO> page(Map<String, Object> params) { |
|||
IPage<TopicImgEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, TopicImgDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<TopicImgDTO> list(Map<String, Object> params) { |
|||
List<TopicImgEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, TopicImgDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<TopicImgEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<TopicImgEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public TopicImgDTO get(String id) { |
|||
TopicImgEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, TopicImgDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(TopicImgDTO dto) { |
|||
TopicImgEntity entity = ConvertUtils.sourceToTarget(dto, TopicImgEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(TopicImgDTO dto) { |
|||
TopicImgEntity entity = ConvertUtils.sourceToTarget(dto, TopicImgEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public boolean saveImages(List<String> images, String referenceId, String imgType) { |
|||
if (null == images || images.isEmpty()) { |
|||
return true; |
|||
} |
|||
List<TopicImgEntity> imgEntities = new ArrayList<>(images.size()); |
|||
TopicImgEntity entity = null; |
|||
for (String url: |
|||
images) { |
|||
entity = new TopicImgEntity(); |
|||
entity.setReferenceId(referenceId); |
|||
entity.setImgUrl(url); |
|||
entity.setImgType(imgType); |
|||
imgEntities.add(entity); |
|||
} |
|||
return insertBatch(imgEntities); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue