forked from luyan/epmet-cloud-lingshan
20 changed files with 642 additions and 23 deletions
@ -0,0 +1,20 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 描述一下 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 17:02 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DeleteBranchFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 5321430865413383354L; |
||||
|
|
||||
|
@NotBlank(message = "党支部id不能为空") |
||||
|
private String partyBranchId; |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 添加党支部入参DTO |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 12:35 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PartyBranchAddFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -8102877381223078842L; |
||||
|
|
||||
|
public interface AddUserInternalGroup { |
||||
|
} |
||||
|
|
||||
|
public interface AddUserShowGroup extends CustomerClientShowGroup { |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 客户id |
||||
|
*/ |
||||
|
@NotBlank(message = "客户id不能为空", groups = {AddUserInternalGroup.class}) |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 网格id |
||||
|
*/ |
||||
|
@NotBlank(message = "网格id不能为空", groups = {AddUserInternalGroup.class}) |
||||
|
private String gridId; |
||||
|
|
||||
|
/** |
||||
|
* 党支部名称 |
||||
|
*/ |
||||
|
@NotBlank(message = "请输入支部名称", groups = {AddUserShowGroup.class}) |
||||
|
@Length(max = 20, message = "支部名称不能超过20个字", groups = AddUserShowGroup.class) |
||||
|
private String partyBranchName; |
||||
|
|
||||
|
/** |
||||
|
* 党支部概要信息 |
||||
|
*/ |
||||
|
@NotBlank(message = "请输入支部概要信息", groups = {AddUserShowGroup.class}) |
||||
|
@Length(max = 500, message = "支部概要信息不能超过500个字", groups = AddUserShowGroup.class) |
||||
|
private String profile; |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 修改党支部信息入参DTO |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 14:00 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PartyBranchEditFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -6739109166420798965L; |
||||
|
public interface AddUserInternalGroup { |
||||
|
} |
||||
|
|
||||
|
public interface AddUserShowGroup extends CustomerClientShowGroup { |
||||
|
} |
||||
|
|
||||
|
@NotBlank(message = "党支部id不能为空", groups = {AddUserInternalGroup.class}) |
||||
|
private String partyBranchId; |
||||
|
/** |
||||
|
* 党支部名称 |
||||
|
*/ |
||||
|
@NotBlank(message = "请输入支部名称", groups = {AddUserShowGroup.class}) |
||||
|
@Length(max = 20, message = "支部名称不能超过20个字", groups = AddUserShowGroup.class) |
||||
|
private String partyBranchName; |
||||
|
|
||||
|
/** |
||||
|
* 党支部概要信息 |
||||
|
*/ |
||||
|
@NotBlank(message = "请输入支部概要信息", groups = {AddUserShowGroup.class}) |
||||
|
@Length(max = 500, message = "支部概要信息不能超过500个字", groups = AddUserShowGroup.class) |
||||
|
private String profile; |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 3、党支部列表查询入参DTO |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 16:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PartyBranchListFormDTO implements Serializable { |
||||
|
public interface AddUserInternalGroup { |
||||
|
} |
||||
|
/** |
||||
|
* 客户id |
||||
|
*/ |
||||
|
@NotBlank(message = "客户id不能为空", groups = {PartyBranchListFormDTO.AddUserInternalGroup.class}) |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 网格id |
||||
|
*/ |
||||
|
@NotBlank(message = "网格id不能为空", groups = {PartyBranchListFormDTO.AddUserInternalGroup.class}) |
||||
|
private String gridId; |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 添加党支部返参DTO |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 12:45 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PartyBranchAddResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 5610858988982913682L; |
||||
|
/** |
||||
|
* 党支部id |
||||
|
*/ |
||||
|
private String partyBranchId; |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 3、党支部列表查询返参DTO |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 16:13 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PartyBranchListResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 8342529186641647970L; |
||||
|
/** |
||||
|
* 支部id |
||||
|
*/ |
||||
|
private String partyBranchId; |
||||
|
/** |
||||
|
* 支部名称 |
||||
|
*/ |
||||
|
private String partyBranchName; |
||||
|
} |
@ -0,0 +1,88 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.form.DeleteBranchFormDTO; |
||||
|
import com.epmet.dto.form.PartyBranchAddFormDTO; |
||||
|
import com.epmet.dto.form.PartyBranchEditFormDTO; |
||||
|
import com.epmet.dto.form.PartyBranchListFormDTO; |
||||
|
import com.epmet.dto.result.PartyBranchAddResultDTO; |
||||
|
import com.epmet.dto.result.PartyBranchListResultDTO; |
||||
|
import com.epmet.service.PartyBranchManageService; |
||||
|
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; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 基层治理-支部管理 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 12:25 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("partybranch") |
||||
|
public class PartyBranchManageController { |
||||
|
@Autowired |
||||
|
private PartyBranchManageService partyBranchManageService; |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.PartyBranchAddResultDTO> |
||||
|
* @author yinzuomei |
||||
|
* @description 添加党支部 |
||||
|
* @Date 2020/6/17 12:47 |
||||
|
**/ |
||||
|
@PostMapping("add") |
||||
|
public Result<PartyBranchAddResultDTO> addPartyBranch(@RequestBody PartyBranchAddFormDTO formDTO) { |
||||
|
ValidatorUtils.validateEntity(formDTO, PartyBranchAddFormDTO.AddUserShowGroup.class, PartyBranchAddFormDTO.AddUserInternalGroup.class); |
||||
|
PartyBranchAddResultDTO partyBranchAddResultDTO = partyBranchManageService.addPartyBranch(formDTO); |
||||
|
return new Result<PartyBranchAddResultDTO>().ok(partyBranchAddResultDTO); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.PartyBranchAddResultDTO> |
||||
|
* @author yinzuomei |
||||
|
* @description 修改党支部信息 |
||||
|
* @Date 2020/6/17 15:31 |
||||
|
**/ |
||||
|
@PostMapping("edit") |
||||
|
public Result<PartyBranchAddResultDTO> editPartyBranch(@RequestBody PartyBranchEditFormDTO formDTO) { |
||||
|
ValidatorUtils.validateEntity(formDTO, PartyBranchEditFormDTO.AddUserShowGroup.class, PartyBranchEditFormDTO.AddUserInternalGroup.class); |
||||
|
partyBranchManageService.editPartyBranch(formDTO); |
||||
|
PartyBranchAddResultDTO partyBranchAddResultDTO = new PartyBranchAddResultDTO(); |
||||
|
partyBranchAddResultDTO.setPartyBranchId(formDTO.getPartyBranchId()); |
||||
|
return new Result<PartyBranchAddResultDTO>().ok(partyBranchAddResultDTO); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.PartyBranchListResultDTO>> |
||||
|
* @author yinzuomei |
||||
|
* @description 党支部列表查询 |
||||
|
* @Date 2020/6/17 16:15 |
||||
|
**/ |
||||
|
@PostMapping("list") |
||||
|
public Result<List<PartyBranchListResultDTO>> listPartyBranch(@RequestBody PartyBranchListFormDTO formDTO) { |
||||
|
ValidatorUtils.validateEntity(formDTO, PartyBranchListFormDTO.AddUserInternalGroup.class); |
||||
|
return new Result<List<PartyBranchListResultDTO>>().ok(partyBranchManageService.listPartyBranch(formDTO)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.commons.tools.utils.Result |
||||
|
* @param formDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 删除党支部 |
||||
|
* @Date 2020/6/17 18:23 |
||||
|
**/ |
||||
|
@PostMapping("delete") |
||||
|
public Result deleteBranch(@RequestBody DeleteBranchFormDTO formDTO) { |
||||
|
ValidatorUtils.validateEntity(formDTO); |
||||
|
partyBranchManageService.deleteBranch(formDTO); |
||||
|
return new Result(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.dto.form.DeleteBranchFormDTO; |
||||
|
import com.epmet.dto.form.PartyBranchAddFormDTO; |
||||
|
import com.epmet.dto.form.PartyBranchEditFormDTO; |
||||
|
import com.epmet.dto.form.PartyBranchListFormDTO; |
||||
|
import com.epmet.dto.result.PartyBranchAddResultDTO; |
||||
|
import com.epmet.dto.result.PartyBranchListResultDTO; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 基层治理-支部管理 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 12:47 |
||||
|
*/ |
||||
|
public interface PartyBranchManageService { |
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.epmet.dto.result.PartyBranchAddResultDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 添加党支部 |
||||
|
* @Date 2020/6/17 13:24 |
||||
|
**/ |
||||
|
PartyBranchAddResultDTO addPartyBranch(PartyBranchAddFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return com.epmet.dto.result.PartyBranchAddResultDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 修改党支部信息 |
||||
|
* @Date 2020/6/17 14:30 |
||||
|
**/ |
||||
|
void editPartyBranch(PartyBranchEditFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @return java.util.List<com.epmet.dto.result.PartyBranchListResultDTO> |
||||
|
* @author yinzuomei |
||||
|
* @description 党支部列表查询 |
||||
|
* @Date 2020/6/17 16:15 |
||||
|
**/ |
||||
|
List<PartyBranchListResultDTO> listPartyBranch(PartyBranchListFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @return void |
||||
|
* @param formDTO |
||||
|
* @author yinzuomei |
||||
|
* @description 删除党支部 |
||||
|
* @Date 2020/6/17 17:04 |
||||
|
**/ |
||||
|
void deleteBranch(DeleteBranchFormDTO formDTO); |
||||
|
} |
@ -0,0 +1,89 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
||||
|
import com.epmet.commons.tools.exception.RenException; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.CustomerPartyBranchDTO; |
||||
|
import com.epmet.dto.form.*; |
||||
|
import com.epmet.dto.result.ListPartyBranchResultDTO; |
||||
|
import com.epmet.dto.result.PartyBranchAddResultDTO; |
||||
|
import com.epmet.dto.result.PartyBranchListResultDTO; |
||||
|
import com.epmet.feign.GovOrgOpenFeignClient; |
||||
|
import com.epmet.service.PartyBranchManageService; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 基层治理-支部管理 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 13:23 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class PartyBranchManageServiceImpl implements PartyBranchManageService { |
||||
|
private Logger logger = LogManager.getLogger(PartyBranchManageServiceImpl.class); |
||||
|
@Autowired |
||||
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public PartyBranchAddResultDTO addPartyBranch(PartyBranchAddFormDTO formDTO) { |
||||
|
CustomerPartyBranchDTO customerPartyBranchDTO = ConvertUtils.sourceToTarget(formDTO, CustomerPartyBranchDTO.class); |
||||
|
customerPartyBranchDTO.setTotalPartyMember(0); |
||||
|
PartyBranchAddResultDTO partyBranchAddResultDTO = new PartyBranchAddResultDTO(); |
||||
|
Result<String> result = govOrgOpenFeignClient.savePartyBranch(customerPartyBranchDTO); |
||||
|
if (result.success()) { |
||||
|
partyBranchAddResultDTO.setPartyBranchId(result.getData()); |
||||
|
} else { |
||||
|
logger.error("添加党支部错误,调用gov-org-server接口返回失败"); |
||||
|
} |
||||
|
return partyBranchAddResultDTO; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void editPartyBranch(PartyBranchEditFormDTO formDTO) { |
||||
|
CustomerPartyBranchDTO customerPartyBranchDTO = ConvertUtils.sourceToTarget(formDTO, CustomerPartyBranchDTO.class); |
||||
|
customerPartyBranchDTO.setId(formDTO.getPartyBranchId()); |
||||
|
Result<String> result = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranchDTO); |
||||
|
if (result.success()) { |
||||
|
logger.info("修改党支部信息成功"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<PartyBranchListResultDTO> listPartyBranch(PartyBranchListFormDTO formDTO) { |
||||
|
ListPartyBranchFormDTO listPartyBranchFormDTO = ConvertUtils.sourceToTarget(formDTO, ListPartyBranchFormDTO.class); |
||||
|
Result<List<ListPartyBranchResultDTO>> result = govOrgOpenFeignClient.listPartyBranch(listPartyBranchFormDTO); |
||||
|
List<ListPartyBranchResultDTO> resultList=result.getData(); |
||||
|
if (result.success()) { |
||||
|
List<PartyBranchListResultDTO> list = ConvertUtils.sourceToTarget(resultList, PartyBranchListResultDTO.class); |
||||
|
return list; |
||||
|
} else { |
||||
|
logger.error(String.format("党支部列表查询失败入参:"), JSON.toJSONString(formDTO)); |
||||
|
} |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void deleteBranch(DeleteBranchFormDTO formDTO) { |
||||
|
Result<CustomerPartyBranchDTO> customerPartyBranchDTOResult = govOrgOpenFeignClient.getPartyBranchById(formDTO.getPartyBranchId()); |
||||
|
if (!customerPartyBranchDTOResult.success()||null==customerPartyBranchDTOResult.getData()) { |
||||
|
logger.error(String.format("查询党支部信息失败入参:%s",JSON.toJSONString(formDTO))); |
||||
|
return; |
||||
|
}else{ |
||||
|
if (null != customerPartyBranchDTOResult.getData() && customerPartyBranchDTOResult.getData().getTotalPartyMember() > 0) { |
||||
|
throw new RenException(EpmetErrorCode.CANNOT_DELETE_PARTYB_RANCH.getCode()); |
||||
|
} |
||||
|
} |
||||
|
Result delteResult=govOrgOpenFeignClient.deletePartyBranchById(formDTO.getPartyBranchId()); |
||||
|
if(!delteResult.success()){ |
||||
|
logger.error(String.format("删除党支部失败入参:%s",JSON.toJSONString(formDTO))); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 党支部列表查询 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 16:27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ListPartyBranchFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -5693132528876149747L; |
||||
|
|
||||
|
/** |
||||
|
* 客户id |
||||
|
*/ |
||||
|
@NotBlank(message = "客户id不能为空") |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 网格id |
||||
|
*/ |
||||
|
@NotBlank(message = "网格id不能为空") |
||||
|
private String gridId; |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 党支部列表查询返参 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/6/17 16:30 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ListPartyBranchResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 2306892144298853581L; |
||||
|
/** |
||||
|
* 支部id |
||||
|
*/ |
||||
|
private String partyBranchId; |
||||
|
/** |
||||
|
* 支部名称 |
||||
|
*/ |
||||
|
private String partyBranchName; |
||||
|
} |
Loading…
Reference in new issue