27 changed files with 1114 additions and 14 deletions
@ -0,0 +1,42 @@ |
|||||
|
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.dto.group.form.GroupCreateFormDTO; |
||||
|
import com.elink.esua.epdc.service.GroupService; |
||||
|
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/10/17 13:48 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("group/group") |
||||
|
public class ApiGroupController { |
||||
|
|
||||
|
@Autowired |
||||
|
private GroupService groupService; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 创建社群 |
||||
|
* |
||||
|
* @params [userDetail, formDto] |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author liuchuang |
||||
|
* @since 2019/10/17 13:58 |
||||
|
*/ |
||||
|
@PostMapping("create") |
||||
|
public Result createGroup(@LoginUser TokenDto userDetail, @RequestBody GroupCreateFormDTO formDto) { |
||||
|
return groupService.saveGroup(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.group.form.GroupCreateFormDTO; |
||||
|
import com.elink.esua.epdc.feign.fallback.GroupFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 社群模块调用 |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 14:40 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_GROUP_SERVER, fallback = GroupFeignClientFallback.class) |
||||
|
public interface GroupFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 创建社群 |
||||
|
* |
||||
|
* @params [formDto] |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author liuchuang |
||||
|
* @since 2019/10/17 14:44 |
||||
|
*/ |
||||
|
@PostMapping(value = "group/epdc-app/group/create", consumes = MediaType.APPLICATION_JSON_VALUE) |
||||
|
Result createGroup(GroupCreateFormDTO 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.group.form.GroupCreateFormDTO; |
||||
|
import com.elink.esua.epdc.feign.GroupFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 14:40 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class GroupFeignClientFallback implements GroupFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result createGroup(GroupCreateFormDTO formDto) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_GROUP_SERVER, "createGroup", 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.group.form.GroupCreateFormDTO; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 社群模块 |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 13:55 |
||||
|
*/ |
||||
|
public interface GroupService { |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 创建社群 |
||||
|
* |
||||
|
* @params [userDetail, formDto] |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author liuchuang |
||||
|
* @since 2019/10/17 13:58 |
||||
|
*/ |
||||
|
Result saveGroup(TokenDto userDetail, GroupCreateFormDTO formDto); |
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import com.elink.esua.epdc.common.token.dto.TokenDto; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.CompleteDeptDTO; |
||||
|
import com.elink.esua.epdc.dto.group.enums.GroupUserStateEnum; |
||||
|
import com.elink.esua.epdc.dto.group.form.GroupCreateFormDTO; |
||||
|
import com.elink.esua.epdc.dto.group.form.GroupUserFormDTO; |
||||
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
||||
|
import com.elink.esua.epdc.feign.GroupFeignClient; |
||||
|
import com.elink.esua.epdc.service.GroupService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 社群模块 |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 13:55 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class GroupServiceImpl implements GroupService { |
||||
|
|
||||
|
@Autowired |
||||
|
private AdminFeignClient adminFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private GroupFeignClient groupFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public Result saveGroup(TokenDto userDetail, GroupCreateFormDTO 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.setGroupCategory(NumConstant.ONE_STR); |
||||
|
// 群主信息
|
||||
|
GroupUserFormDTO groupUserFormDTO = new GroupUserFormDTO(); |
||||
|
groupUserFormDTO.setUserId(userDetail.getUserId()); |
||||
|
groupUserFormDTO.setNickname(userDetail.getNickname()); |
||||
|
groupUserFormDTO.setUserAvatar(userDetail.getFaceImg()); |
||||
|
groupUserFormDTO.setMobile(userDetail.getMobile()); |
||||
|
// 判断当前用户是否为党员
|
||||
|
if (!NumConstant.ONE_STR.equals(userDetail.getPartyFlag())) { |
||||
|
return new Result().error("您当前身份不是党员,不能创建社群"); |
||||
|
} |
||||
|
groupUserFormDTO.setPartyMember(userDetail.getPartyFlag()); |
||||
|
groupUserFormDTO.setLordFlag(NumConstant.ONE_STR); |
||||
|
groupUserFormDTO.setState(GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
||||
|
formDto.setGroupUserFormDTO(groupUserFormDTO); |
||||
|
|
||||
|
return groupFeignClient.createGroup(formDto); |
||||
|
} |
||||
|
} |
@ -0,0 +1,116 @@ |
|||||
|
/** |
||||
|
* 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.group; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户社群关系表 用户社群关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-10-17 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserGroupDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 社群ID |
||||
|
*/ |
||||
|
private String groupId; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 用户名 |
||||
|
*/ |
||||
|
private String nickname; |
||||
|
|
||||
|
/** |
||||
|
* 用户头像 |
||||
|
*/ |
||||
|
private String userAvatar; |
||||
|
|
||||
|
/** |
||||
|
* 手机号 |
||||
|
*/ |
||||
|
private String mobile; |
||||
|
|
||||
|
/** |
||||
|
* 群主标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String lordFlag; |
||||
|
|
||||
|
/** |
||||
|
* 党员标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String partyMember; |
||||
|
|
||||
|
/** |
||||
|
* 状态 0:待审核,5:审核不通过,10:审核通过,15:已退群,20:已移除 |
||||
|
*/ |
||||
|
private Integer state; |
||||
|
|
||||
|
/** |
||||
|
* 审核意见 |
||||
|
*/ |
||||
|
private String auditOpinion; |
||||
|
|
||||
|
/** |
||||
|
* 删除标记 0:未删除,1:已删除 |
||||
|
*/ |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package com.elink.esua.epdc.dto.group.enums; |
||||
|
|
||||
|
/** |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 14:15 |
||||
|
*/ |
||||
|
public enum GroupStateEnum { |
||||
|
|
||||
|
/** |
||||
|
* 0-待审核 |
||||
|
*/ |
||||
|
GROUP_STATE_PENDING_REVIEW(0, "待审核"), |
||||
|
/** |
||||
|
* 5-审核不通过 |
||||
|
*/ |
||||
|
GROUP_STATE_AUDIT_NOT_PASSED(5, "审核不通过"), |
||||
|
/** |
||||
|
* 10-审核通过 |
||||
|
*/ |
||||
|
GROUP_STATE_EXAMINATION_PASSED(10, "审核通过"), |
||||
|
/** |
||||
|
* 15-禁言 |
||||
|
*/ |
||||
|
GROUP_STATE_BANNED(15, "禁言"), |
||||
|
/** |
||||
|
* 20-已解散 |
||||
|
*/ |
||||
|
GROUP_STATE_DISBANDED(20, "已解散"); |
||||
|
|
||||
|
private Integer value; |
||||
|
private String name; |
||||
|
|
||||
|
GroupStateEnum(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,56 @@ |
|||||
|
package com.elink.esua.epdc.dto.group.enums; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 社群成员状态枚举 |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 15:38 |
||||
|
*/ |
||||
|
public enum GroupUserStateEnum { |
||||
|
|
||||
|
/** |
||||
|
* 0-待审核 |
||||
|
*/ |
||||
|
GROUP_USER_STATE_PENDING_REVIEW(0, "待审核"), |
||||
|
/** |
||||
|
* 5-审核不通过 |
||||
|
*/ |
||||
|
GROUP_USER_STATE_AUDIT_NOT_PASSED(5, "审核不通过"), |
||||
|
/** |
||||
|
* 10-审核通过 |
||||
|
*/ |
||||
|
GROUP_USER_STATE_EXAMINATION_PASSED(10, "审核通过"), |
||||
|
/** |
||||
|
* 15-已退群 |
||||
|
*/ |
||||
|
GROUP_USER_STATE_RETIRED(15, "已退群"), |
||||
|
/** |
||||
|
* 20-已移除 |
||||
|
*/ |
||||
|
GROUP_USER_STATE_REMOVED(20, "已移除"); |
||||
|
|
||||
|
private Integer value; |
||||
|
private String name; |
||||
|
|
||||
|
GroupUserStateEnum(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,82 @@ |
|||||
|
package com.elink.esua.epdc.dto.group.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.Size; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 创建社群DTO |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 13:52 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GroupCreateFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 2948200217356354599L; |
||||
|
|
||||
|
/** |
||||
|
* 社群名称 |
||||
|
*/ |
||||
|
@NotBlank(message = "社群名称不能为空且在10个字以内") |
||||
|
@Size(min = 1, max = 10, message = "社群名称不能为空且在10个字以内") |
||||
|
private String groupName; |
||||
|
/** |
||||
|
* 社群头像 |
||||
|
*/ |
||||
|
@NotBlank(message = "社群头像不能为空") |
||||
|
private String groupAvatar; |
||||
|
/** |
||||
|
* 社群介绍 |
||||
|
*/ |
||||
|
@NotBlank(message = "社群介绍不能为空且在500个字以内") |
||||
|
@Size(min = 1, max = 500, message = "社群介绍不能为空且在500个字以内") |
||||
|
private String groupIntroduction; |
||||
|
/** |
||||
|
* 社群类别 0:党员群,1:自建群 |
||||
|
*/ |
||||
|
private String groupCategory; |
||||
|
/** |
||||
|
* 区 |
||||
|
*/ |
||||
|
private String area; |
||||
|
/** |
||||
|
* 区ID |
||||
|
*/ |
||||
|
@NotNull(message = "用户区ID不能为空") |
||||
|
private Long areaId; |
||||
|
/** |
||||
|
* 街道 |
||||
|
*/ |
||||
|
private String street; |
||||
|
/** |
||||
|
* 街道ID |
||||
|
*/ |
||||
|
@NotNull(message = "用户街道ID不能为空") |
||||
|
private Long streetId; |
||||
|
/** |
||||
|
* 社区 |
||||
|
*/ |
||||
|
private String community; |
||||
|
/** |
||||
|
* 社区ID |
||||
|
*/ |
||||
|
@NotNull(message = "用户社区ID不能为空") |
||||
|
private Long communityId; |
||||
|
/** |
||||
|
* 网格 |
||||
|
*/ |
||||
|
private String grid; |
||||
|
/** |
||||
|
* 网格ID |
||||
|
*/ |
||||
|
@NotNull(message = "用户网格ID不能为空") |
||||
|
private Long gridId; |
||||
|
/** |
||||
|
* 群主信息 |
||||
|
*/ |
||||
|
private GroupUserFormDTO groupUserFormDTO; |
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package com.elink.esua.epdc.dto.group.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 社群成员DTO |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2019/10/17 14:27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GroupUserFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -1532468675717622698L; |
||||
|
|
||||
|
/** |
||||
|
* 社群ID |
||||
|
*/ |
||||
|
private String groupId; |
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
@NotBlank(message = "用户ID不能为空") |
||||
|
private String userId; |
||||
|
/** |
||||
|
* 用户昵称 |
||||
|
*/ |
||||
|
@NotBlank(message = "用户昵称不能为空") |
||||
|
private String nickname; |
||||
|
/** |
||||
|
* 用户头像 |
||||
|
*/ |
||||
|
@NotBlank(message = "用户头像不能为空") |
||||
|
private String userAvatar; |
||||
|
/** |
||||
|
* 用户手机号 |
||||
|
*/ |
||||
|
@NotBlank(message = "用户联系方式不能为空") |
||||
|
private String mobile; |
||||
|
/** |
||||
|
* 群主标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String lordFlag; |
||||
|
/** |
||||
|
* 党员标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String partyMember; |
||||
|
/** |
||||
|
* 状态 0:待审核,5:审核不通过,10:审核通过,15:已退群,20:已移除 |
||||
|
*/ |
||||
|
private Integer state; |
||||
|
/** |
||||
|
* 处理意见 |
||||
|
*/ |
||||
|
private String auditOpinion; |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
package com.elink.esua.epdc.modules.group.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.Constant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.dto.group.form.GroupCreateFormDTO; |
||||
|
import com.elink.esua.epdc.modules.group.service.GroupService; |
||||
|
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/10/17 13:46 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping(Constant.EPDC_APP + "group") |
||||
|
public class AppGroupController { |
||||
|
|
||||
|
@Autowired |
||||
|
private GroupService groupService; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 创建社群 |
||||
|
* |
||||
|
* @params [formDto] |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author liuchuang |
||||
|
* @since 2019/10/17 14:56 |
||||
|
*/ |
||||
|
@PostMapping("create") |
||||
|
public Result createGroup(@RequestBody GroupCreateFormDTO formDto) { |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(formDto); |
||||
|
return groupService.saveGroup(formDto); |
||||
|
} |
||||
|
} |
@ -0,0 +1,84 @@ |
|||||
|
/** |
||||
|
* 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.group.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.group.UserGroupDTO; |
||||
|
import com.elink.esua.epdc.modules.group.service.UserGroupService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户社群关系表 用户社群关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-10-17 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("usergroup") |
||||
|
public class UserGroupController { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserGroupService userGroupService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<UserGroupDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<UserGroupDTO> page = userGroupService.page(params); |
||||
|
return new Result<PageData<UserGroupDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<UserGroupDTO> get(@PathVariable("id") String id){ |
||||
|
UserGroupDTO data = userGroupService.get(id); |
||||
|
return new Result<UserGroupDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody UserGroupDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
userGroupService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody UserGroupDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
userGroupService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
userGroupService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
/** |
||||
|
* 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.group.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.dto.group.UserGroupDTO; |
||||
|
import com.elink.esua.epdc.modules.group.entity.UserGroupEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户社群关系表 用户社群关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-10-17 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface UserGroupDao extends BaseDao<UserGroupEntity> { |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 社群成员列表 |
||||
|
* |
||||
|
* @params [params] |
||||
|
* @return java.util.List<com.elink.esua.epdc.dto.group.UserGroupDTO> |
||||
|
* @author liuchuang |
||||
|
* @since 2019/10/17 10:31 |
||||
|
*/ |
||||
|
List<UserGroupDTO> selectListOfGroupUsers(Map<String, Object> params); |
||||
|
|
||||
|
} |
@ -0,0 +1,84 @@ |
|||||
|
/** |
||||
|
* 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.group.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
/** |
||||
|
* 用户社群关系表 用户社群关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-10-17 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_user_group") |
||||
|
public class UserGroupEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 社群ID |
||||
|
*/ |
||||
|
private String groupId; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 用户名 |
||||
|
*/ |
||||
|
private String nickname; |
||||
|
|
||||
|
/** |
||||
|
* 用户头像 |
||||
|
*/ |
||||
|
private String userAvatar; |
||||
|
|
||||
|
/** |
||||
|
* 手机号 |
||||
|
*/ |
||||
|
private String mobile; |
||||
|
|
||||
|
/** |
||||
|
* 群主标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String lordFlag; |
||||
|
|
||||
|
/** |
||||
|
* 党员标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String partyMember; |
||||
|
|
||||
|
/** |
||||
|
* 状态 0:待审核,5:审核不通过,10:审核通过,15:已退群,20:已移除 |
||||
|
*/ |
||||
|
private Integer state; |
||||
|
|
||||
|
/** |
||||
|
* 审核意见 |
||||
|
*/ |
||||
|
private String auditOpinion; |
||||
|
|
||||
|
} |
@ -0,0 +1,95 @@ |
|||||
|
/** |
||||
|
* 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.group.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.group.UserGroupDTO; |
||||
|
import com.elink.esua.epdc.modules.group.entity.UserGroupEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户社群关系表 用户社群关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-10-17 |
||||
|
*/ |
||||
|
public interface UserGroupService extends BaseService<UserGroupEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<UserGroupDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-10-17 |
||||
|
*/ |
||||
|
PageData<UserGroupDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<UserGroupDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-10-17 |
||||
|
*/ |
||||
|
List<UserGroupDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return UserGroupDTO |
||||
|
* @author generator |
||||
|
* @date 2019-10-17 |
||||
|
*/ |
||||
|
UserGroupDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-10-17 |
||||
|
*/ |
||||
|
void save(UserGroupDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-10-17 |
||||
|
*/ |
||||
|
void update(UserGroupDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-10-17 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
} |
@ -0,0 +1,97 @@ |
|||||
|
/** |
||||
|
* 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.group.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.group.UserGroupDTO; |
||||
|
import com.elink.esua.epdc.modules.group.dao.UserGroupDao; |
||||
|
import com.elink.esua.epdc.modules.group.entity.UserGroupEntity; |
||||
|
import com.elink.esua.epdc.modules.group.service.UserGroupService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户社群关系表 用户社群关系表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-10-17 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class UserGroupServiceImpl extends BaseServiceImpl<UserGroupDao, UserGroupEntity> implements UserGroupService { |
||||
|
|
||||
|
@Override |
||||
|
public PageData<UserGroupDTO> page(Map<String, Object> params) { |
||||
|
IPage<UserGroupDTO> page = getPage(params); |
||||
|
List<UserGroupDTO> list = baseDao.selectListOfGroupUsers(params); |
||||
|
return new PageData<>(list, page.getTotal()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<UserGroupDTO> list(Map<String, Object> params) { |
||||
|
List<UserGroupEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, UserGroupDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<UserGroupEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<UserGroupEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public UserGroupDTO get(String id) { |
||||
|
UserGroupEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, UserGroupDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(UserGroupDTO dto) { |
||||
|
UserGroupEntity entity = ConvertUtils.sourceToTarget(dto, UserGroupEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(UserGroupDTO dto) { |
||||
|
UserGroupEntity entity = ConvertUtils.sourceToTarget(dto, UserGroupEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
<?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.elink.esua.epdc.modules.group.dao.UserGroupDao"> |
||||
|
|
||||
|
<select id="selectListOfGroupUsers" resultType="com.elink.esua.epdc.dto.group.UserGroupDTO"> |
||||
|
SELECT |
||||
|
ugp.USER_ID, |
||||
|
ugp.NICKNAME, |
||||
|
ugp.LORD_FLAG, |
||||
|
ugp.MOBILE |
||||
|
FROM |
||||
|
epdc_user_group ugp |
||||
|
WHERE |
||||
|
ugp.DEL_FLAG = '0' |
||||
|
AND ugp.GROUP_ID = #{groupId} |
||||
|
AND ugp.STATE = 10 |
||||
|
<if test="nickname != null and nickname != ''"> |
||||
|
AND ugp.NICKNAME LIKE concat('%', #{nickname}, '%') |
||||
|
</if> |
||||
|
<if test="mobile != null and mobile != ''"> |
||||
|
AND ugp.MOBILE = #{mobile} |
||||
|
</if> |
||||
|
ORDER BY |
||||
|
ugp.LORD_FLAG DESC, |
||||
|
ugp.CREATED_TIME DESC |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue