Browse Source

社会组织CRUD

dev
sunyuchao 4 years ago
parent
commit
4966fc2ef6
  1. 13
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java
  2. 92
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java
  3. 51
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/GetListSocietyOrgFormDTO.java
  4. 69
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java
  5. 36
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java
  6. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/SocietyOrgDao.java
  7. 21
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java
  8. 76
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java
  9. 35
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/SocietyOrgDao.xml

13
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java

@ -18,6 +18,7 @@
package com.epmet.dto.form;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
@ -25,11 +26,9 @@ import java.util.Date;
/**
* 社会组织管理
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-18
*/
* @Author sun
* @Description 新增社会组织
**/
@Data
public class AddSocietyOrgFormDTO implements Serializable {
@ -50,21 +49,25 @@ public class AddSocietyOrgFormDTO implements Serializable {
* 社会组织名称
*/
@NotBlank(message = "社会组织名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@Length(max = 50, message = "社会组织名称不能超过50个字符",groups = {Add.class})
private String societyName;
/**
* 服务事项
*/
@NotBlank(message = "服务事项不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@Length(max = 1000, message = "服务事项不能超过1000个字符",groups = {Add.class})
private String serviceMatters;
/**
* 负责人
*/
@NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Add.class})
private String personInCharge;
/**
* 负责人电话
*/
@NotBlank(message = "负责人电话不能为空", groups = { AddSocietyOrgFormDTO.Add.class })
@Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Add.class})
private String mobile;
/**
* 起始服务时间

92
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java

@ -0,0 +1,92 @@
/**
* 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.epmet.dto.form;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* @Author sun
* @Description 修改删除社会组织
**/
@Data
public class EditSocietyOrgFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 社会组织Id
*/
@NotBlank(message = "社会组织Id不能为空", groups = { Edit.class, Del.class })
private String societyId;
/**
* 社会组织名称
*/
@Length(max = 50, message = "社会组织名称不能超过50个字符",groups = {Edit.class})
private String societyName;
/**
* 服务事项
*/
@Length(max = 1000, message = "服务事项不能超过1000个字符",groups = {Edit.class})
private String serviceMatters;
/**
* 负责人
*/
@Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Edit.class})
private String personInCharge;
/**
* 负责人电话
*/
@Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Edit.class})
private String mobile;
/**
* 起始服务时间
*/
private Date serviceStartTime;
/**
* 终止服务时间
*/
private Date serviceEndTime;
/**
* 绑定管理员[组织下录入的工作人员]
*/
private String adminStaffId;
/**
* 地址
*/
private String address;
/**
* 经度
*/
private String longitude;
/**
* 维度
*/
private String dimension;
//token中userId
private String staffId;
public interface Edit {}
public interface Del {}
}

51
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/GetListSocietyOrgFormDTO.java

@ -0,0 +1,51 @@
/**
* 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.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import java.io.Serializable;
import java.util.Date;
/**
* @Author sun
* @Description 社会组织列表查询
**/
@Data
public class GetListSocietyOrgFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
//社会组织名称
private String societyName;
//负责人
private String personInCharge;
//负责人电话
private String mobile;
//起始服务时间
private Date serviceStartTime;
//终止服务时间
private Date serviceEndTime;
//页码
@Min(1)
private Integer pageNo;
//每页多少条
private Integer pageSize = 20;
}

69
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java

@ -0,0 +1,69 @@
/**
* 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.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author sun
* @Description 社会组织列表查询
**/
@Data
public class GetListSocietyOrgResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
//集合总条数
private Integer total;
//社会组织信息
private List<SocietyOrgList> list;
@Data
public class SocietyOrgList{
//所属组织Id
private String agencyId;
//社会组织Id
private String societyId;
//社会组织名称
private String societyName;
//服务事项
private String serviceMatters;
//负责人姓名
private String personInCharge;
//负责人电话
private String mobile;
//起始服务时间
private String serviceStartTime;
//终止服务时间
private String serviceEndTime;
//绑定管理员[组织下Id录入的工作人员]
private String adminStaffId;
//绑定管理员[组织下录入的工作人员]姓名
private String adminStaffName;
//地址
private String address;
//经度
private String longitude;
//维度
private String dimension;
}
}

36
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java

@ -22,6 +22,9 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.AddSocietyOrgFormDTO;
import com.epmet.dto.form.EditSocietyOrgFormDTO;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.service.SocietyOrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -39,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("societyorg")
public class SocietyOrgController {
@Autowired
private SocietyOrgService societyOrgService;
@ -56,4 +59,35 @@ public class SocietyOrgController {
return new Result();
}
/**
* @Author sun
* @Description 修改社会组织
**/
@PostMapping("edit")
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditSocietyOrgFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, EditSocietyOrgFormDTO.Edit.class);
societyOrgService.edit(formDTO);
return new Result();
}
/**
* @Author sun
* @Description 删除社会组织
**/
@PostMapping("del")
public Result del(@LoginUser TokenDto tokenDto, @RequestBody EditSocietyOrgFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, EditSocietyOrgFormDTO.Del.class);
societyOrgService.del(formDTO.getSocietyId());
return new Result();
}
/**
* @Author sun
* @Description 社会组织列表查询
**/
@PostMapping("getlist")
public Result<GetListSocietyOrgResultDTO> getList(@LoginUser TokenDto tokenDto, @RequestBody GetListSocietyOrgFormDTO formDTO) {
return new Result<GetListSocietyOrgResultDTO>().ok(societyOrgService.getList(formDTO));
}
}

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/SocietyOrgDao.java

@ -18,9 +18,13 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.entity.SocietyOrgEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 社会组织管理
*
@ -29,5 +33,11 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface SocietyOrgDao extends BaseDao<SocietyOrgEntity> {
/**
* @Author sun
* @Description 社会组织列表查询
**/
List<GetListSocietyOrgResultDTO.SocietyOrgList> getList(GetListSocietyOrgFormDTO formDTO);
}

21
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java

@ -19,6 +19,9 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.form.AddSocietyOrgFormDTO;
import com.epmet.dto.form.EditSocietyOrgFormDTO;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.entity.SocietyOrgEntity;
/**
@ -34,4 +37,22 @@ public interface SocietyOrgService extends BaseService<SocietyOrgEntity> {
* @Description 新增社会组织
**/
void add(AddSocietyOrgFormDTO dto);
/**
* @Author sun
* @Description 修改社会组织
**/
void edit(EditSocietyOrgFormDTO formDTO);
/**
* @Author sun
* @Description 删除社会组织
**/
void del(String societyId);
/**
* @Author sun
* @Description 社会组织列表查询
**/
GetListSocietyOrgResultDTO getList(GetListSocietyOrgFormDTO formDTO);
}

76
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java

@ -18,17 +18,36 @@
package com.epmet.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.SocietyOrgDao;
import com.epmet.dto.ProjectStaffDTO;
import com.epmet.dto.form.AddSocietyOrgFormDTO;
import com.epmet.dto.form.EditSocietyOrgFormDTO;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.form.UserIdsFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.dto.result.StaffSinGridResultDTO;
import com.epmet.entity.ActInfoEntity;
import com.epmet.entity.SocietyOrgEntity;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.SocietyOrgService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 社会组织管理
@ -39,6 +58,9 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class SocietyOrgServiceImpl extends BaseServiceImpl<SocietyOrgDao, SocietyOrgEntity> implements SocietyOrgService {
private static final Logger log = LoggerFactory.getLogger(SocietyOrgServiceImpl.class);
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
/**
* @Author sun
@ -53,4 +75,58 @@ public class SocietyOrgServiceImpl extends BaseServiceImpl<SocietyOrgDao, Societ
insert(entity);
}
/**
* @Author sun
* @Description 修改社会组织
**/
@Override
public void edit(EditSocietyOrgFormDTO formDTO) {
SocietyOrgEntity entity = baseDao.selectById(formDTO.getSocietyId());
if (null == entity) {
throw new RenException(String.format("修改社会组织信息失败,社会组织信息不存在,组织Id->%s", formDTO.getSocietyId()));
}
entity = ConvertUtils.sourceToTarget(formDTO, SocietyOrgEntity.class);
baseDao.updateById(entity);
}
/**
* @Author sun
* @Description 删除社会组织
**/
@Override
public void del(String societyId) {
if (baseDao.deleteById(societyId) < NumConstant.ONE) {
throw new RenException(String.format("修改社会组织信息删除失败,社会组织Id->%s", societyId));
}
}
/**
* @Author sun
* @Description 社会组织列表查询
**/
@Override
public GetListSocietyOrgResultDTO getList(GetListSocietyOrgFormDTO formDTO) {
GetListSocietyOrgResultDTO resultDTO = new GetListSocietyOrgResultDTO();
//1.根据查询条件分页查询社会组织数据
PageInfo<GetListSocietyOrgResultDTO.SocietyOrgList> result =
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.getList(formDTO));
if (CollectionUtils.isEmpty(result.getList())) {
return resultDTO;
}
resultDTO.setTotal((int) result.getTotal());
//2.查询被绑定管理员信息
UserIdsFormDTO dto = new UserIdsFormDTO();
List<String> staffIdList = result.getList().stream().map(GetListSocietyOrgResultDTO.SocietyOrgList::getAdminStaffId).collect(Collectors.toList());
staffIdList = staffIdList.stream().distinct().collect(Collectors.toList());
dto.setUserIds(staffIdList);
Result<List<StaffSinGridResultDTO>> listResult = epmetUserOpenFeignClient.getStaffInfoList(dto);
if (!listResult.success()) {
throw new RenException("获取工作人员基本信息失败......");
}
result.getList().forEach(r -> listResult.getData().stream().filter(u -> r.getAdminStaffId().equals(u.getStaffId())).forEach(u -> r.setAdminStaffName(u.getStaffName())));
resultDTO.setList(result.getList());
return resultDTO;
}
}

35
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/SocietyOrgDao.xml

@ -3,6 +3,39 @@
<mapper namespace="com.epmet.dao.SocietyOrgDao">
<select id="getList" resultType="com.epmet.dto.result.GetListSocietyOrgResultDTO$SocietyOrgList">
SELECT
agency_id agencyId,
id societyId,
society_name societyName,
service_matters serviceMatters,
person_in_charge personInCharge,
mobile mobile,
service_start_time serviceStartTime,
service_end_time serviceEndTime,
admin_staff_id adminStaffId,
address address,
longitude longitude,
dimension dimension
FROM
society_org
WHERE
del_flag = '0'
<if test="societyName != null and societyName.trim() != ''">
AND society_name LIKE #{societyName}
</if>
<if test="personInCharge != null and personInCharge.trim() != ''">
AND person_in_charge LIKE #{personInCharge}
</if>
<if test="mobile != null and mobile.trim() != ''">
AND mobile = #{mobile}
</if>
<if test="serviceStartTime != null and serviceStartTime != ''">
AND date_id <![CDATA[>=]]> #{serviceStartTime}
</if>
<if test="serviceEndTime != null and serviceEndTime != ''">
AND date_id <![CDATA[<=]]> #{serviceEndTime}
</if>
</select>
</mapper>
Loading…
Cancel
Save