manailin
2021-11-03 c3811d01d1929a98a0f34f70ca187d82ee312dbb
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/api/PartyBuildIngApi.java
New file
@@ -0,0 +1,698 @@
package com.panzhihua.service_dangjian.api;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panzhihua.common.exceptions.PartyBuildingMemberException;
import com.panzhihua.common.model.dtos.partybuilding.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.partybuilding.*;
import com.panzhihua.common.service.partybuilding.PartyBuildingService;
import com.panzhihua.service_dangjian.dao.ComPbOrgDAO;
import com.panzhihua.service_dangjian.model.dos.ComPbMemberDO;
import com.panzhihua.service_dangjian.model.dos.ComPbOrgDO;
import com.panzhihua.service_dangjian.service.ComBpActivityService;
import com.panzhihua.service_dangjian.service.ComPbMemberService;
import com.panzhihua.service_dangjian.service.ComPbServiceTeamService;
import com.panzhihua.service_dangjian.service.PartyOrganizationService;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 党建
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-11-30 10:41
 **/
@RequestMapping("/partybuildIng/")
@RestController
public class PartyBuildIngApi {
    @Resource
    private ComPbMemberService comPbMemberService;
    @Resource
    private PartyOrganizationService partyOrganizationService;
    @Resource
    private ComBpActivityService comBpActivityService;
    @Resource
    private ComPbServiceTeamService comPbServiceTeamService;
    @Resource
    private ComPbOrgDAO comPbOrgDAO;
    @Resource
    private PartyBuildingService partyBuildingService;
    /**
     * 社区所有启用的党组织列表
     *
     * @return 党组织集合
     */
    @PostMapping("listpartyorganization")
    public R listPartyOrganization(@RequestParam("communityId") Long communityId) {
        List<PartyOrganizationVO> partyOrganizationVOS = partyOrganizationService.listPartyOrganization(communityId);
        return R.ok(partyOrganizationVOS);
    }
    /**
     * 社区所有党组织列表
     *
     * @return 党组织集合
     */
    @PostMapping("listpartyorganizationAll")
    public R listPartyOrganizationAll(@RequestBody PartyOrganizationVO partyOrganizationVO) {
        return partyOrganizationService.listPartyOrganizationAll(partyOrganizationVO);
    }
    /**
     * 新增党支部
     *
     * @param partyOrganizationVO
     *            党支部基本信息
     * @return 新增结果
     */
    @PostMapping("addpartyorganization")
    public R addPartyOrganization(@RequestBody PartyOrganizationVO partyOrganizationVO) {
        return partyOrganizationService.addPartyOrganization(partyOrganizationVO);
    }
    /**
     * 编辑党支部
     *
     * @param partyOrganizationVO
     *            党支部基本信息
     * @return 编辑结果
     */
    @PostMapping("updatepartyorganization")
    public R updatePartyOrganization(@RequestBody PartyOrganizationVO partyOrganizationVO) {
        return partyOrganizationService.updatePartyOrganization(partyOrganizationVO);
    }
    /**
     * 启用,禁用党支部
     *
     * @param partyOrganizationVO
     *            党支部基本信息
     * @return 编辑结果
     */
    @PostMapping("resetpartyorganization")
    public R resetPartyOrganization(@RequestBody PartyOrganizationVO partyOrganizationVO) {
        return partyOrganizationService.resetPartyOrganization(partyOrganizationVO);
    }
    /**
     * 删除党支部
     *
     * @param partyOrganizationVO
     *            党支部基本信息
     * @return 编辑结果
     */
    @PostMapping("deletepartyorganization")
    public R deletePartyOrganization(@RequestBody PartyOrganizationVO partyOrganizationVO) {
        return partyOrganizationService.deletePartyOrganization(partyOrganizationVO);
    }
    /**
     * 新增党员
     *
     * @param partyBuildingMemberVO
     *            党员基本信息
     * @return 新增结果
     */
    @PostMapping("addpartybuildingmember")
    public R addPartyBuildingMember(@RequestBody PartyBuildingMemberVO partyBuildingMemberVO) {
        return comPbMemberService.addPartyBuildingMember(partyBuildingMemberVO);
    }
    /**
     * 批量新增党员
     *
     * @param list
     *            党员集合
     */
    @PostMapping("listsavepartybuildingmemberexcelvo")
    public R listSavePartyBuildingMemberExcelVO(@RequestBody List<PartyBuildingMemberExcelVO> list) {
        R r = null;
        try {
            r = comPbMemberService.listSavePartyBuildingMemberExcelVO(list);
        } catch (PartyBuildingMemberException e) {
            return R.fail(e.getMsg());
        } catch (Exception e) {
            e.printStackTrace();
            if (e.getMessage().contains("unique_id_card_community_id")) {
                return R.fail("身份证重复");
            } else {
                return R.fail("导入失败");
            }
        }
        return r;
    }
    /**
     * 分页查询党员信息
     *
     * @param pagePartyOrganizationVO
     *            查询信息
     * @return 分页数据
     */
    @PostMapping("pagepartyorganization")
    public R pagePartyOrganization(@RequestBody PagePartyOrganizationVO pagePartyOrganizationVO) {
        return comPbMemberService.pagePartyOrganization(pagePartyOrganizationVO);
    }
    /**
     * 党员活动查询
     *
     * @param partyBuildingActivityVO
     *            查询参数
     * @return 参加的所有活动
     */
    @PostMapping("listpartymemberactivities")
    public R listPartyMemberActivities(@RequestBody PartyBuildingActivityVO partyBuildingActivityVO) {
        Long id = partyBuildingActivityVO.getId();
        if (ObjectUtils.isEmpty(id)) {
            return R.fail("党员id不能为空");
        }
        return comBpActivityService.listPartyMemberActivities(partyBuildingActivityVO);
    }
    /**
     * 活动报名名单分页查询
     *
     * @param pageActivityMembersVO
     *            查询参数 手机号 名字
     * @return 分页数据
     */
    @PostMapping("pageactivitymembers")
    public R pageActivityMembers(@RequestBody PageActivityMembersVO pageActivityMembersVO) {
        return comBpActivityService.pageActivityMembers(pageActivityMembersVO);
    }
    /**
     * 编辑党员信息 新增字段均可编辑
     *
     * @param partyBuildingMemberVO
     *            编辑字段
     * @return 编辑结果
     */
    @PostMapping("updatepartybuildingmember")
    public R updatePartyBuildingMember(@RequestBody PartyBuildingMemberVO partyBuildingMemberVO) {
        return comPbMemberService.updatePartyBuildingMembers(partyBuildingMemberVO);
    }
    /**
     * 党员活动详情
     *
     * @param id
     *            活动id
     * @return 活动详情内容
     */
    @PostMapping("activityinfo")
    public R activityinfo(@RequestParam("id") Long id, @RequestParam("userId") Long userId) {
        return comBpActivityService.activityinfo(id, userId);
    }
    /**
     * 查询指定社区的所有党员
     *
     * @param communityId
     *            社区id
     * @return 党员列表
     */
    @PostMapping("listPartyMember")
    public R listPartyMember(@RequestParam("communityId") Long communityId) {
        return comPbMemberService.listPartyMember(communityId);
    }
    /**
     * 新增党委
     *
     * @param partyCommitteeVO
     *            新增信息
     * @return 新增结果
     */
    @PostMapping("addpartycommittee")
    public R addPartyCommittee(@RequestBody PartyCommitteeVO partyCommitteeVO) {
        return comPbMemberService.addPartyCommittee(partyCommitteeVO);
    }
    /**
     * 编辑党委
     *
     * @param partyCommitteeVO
     *            编辑信息
     * @return 编辑结果
     */
    @PostMapping("updatepartycommittee")
    public R updatePartyCommittee(@RequestBody PartyCommitteeVO partyCommitteeVO) {
        return comPbMemberService.updatePartyCommittee(partyCommitteeVO);
    }
    /**
     * 删除党委
     *
     * @param partyCommitteeVO
     *            删除id
     * @return 删除结果
     */
    @PostMapping("deletepartycommittee")
    public R deletePartyCommittee(@RequestBody PartyCommitteeVO partyCommitteeVO) {
        return comPbMemberService.deletePartyCommittee(partyCommitteeVO);
    }
    /**
     * 分页社区党委查询
     *
     * @param partyCommitteeVO
     *            查询参数
     * @return 分页集合
     */
    @PostMapping("pagepartycommittee")
    public R pagePartyCommittee(@RequestBody PartyCommitteeVO partyCommitteeVO) {
        return comPbMemberService.pagePartyCommittee(partyCommitteeVO);
    }
    /**
     * 新建党建动态
     *
     * @param partyCommitteeVO
     *            动态内容
     * @return 新增结果
     */
    @PostMapping("adddynamic")
    public R adddYnamic(@RequestBody PartyBuildingComPbDynVO partyCommitteeVO) {
        return comPbMemberService.adddYnamic(partyCommitteeVO);
    }
    /**
     * 编辑动态
     *
     * @param partyCommitteeVO
     *            编辑内容
     * @return 编辑结果
     */
    @PostMapping("updatedynamic")
    public R updateYnamic(@RequestBody PartyBuildingComPbDynVO partyCommitteeVO) {
        return comPbMemberService.updateYnamic(partyCommitteeVO);
    }
    /**
     * 动态详情
     *
     * @param id
     *            动态主键
     * @return 详情
     */
    @PostMapping("infodynamic")
    public R infoYnamic(@RequestParam("id") Long id) {
        return comPbMemberService.infoYnamic(id);
    }
    /**
     * 分页查询党员动态/政策文件
     *
     * @param partyBuildingComPbDynVO
     *            查询参数
     * @return 分页数据
     */
    @PostMapping("pagedynamic")
    public R pageYnamic(@RequestBody PartyBuildingComPbDynVO partyBuildingComPbDynVO) {
        return comPbMemberService.pageYnamic(partyBuildingComPbDynVO);
    }
    /**
     * 删除动态
     *
     * @param id
     *            动态主键
     * @return 删除结果
     */
    @PostMapping("deletedynamic")
    public R deleteYnamic(@RequestParam("id") Integer id) {
        return comPbMemberService.deleteYnamic(id);
    }
    /**
     * 新增党员活动
     *
     * @param partyBuildingActivityVO
     *            参数
     * @return 新增结果
     */
    @PostMapping("addactivity")
    public R addactivity(@RequestBody PartyBuildingActivityVO partyBuildingActivityVO) {
        return comBpActivityService.addactivity(partyBuildingActivityVO);
    }
    /**
     * 编辑党员活动
     *
     * @param partyBuildingActivityVO
     *            编辑内容
     * @return 编辑结果
     */
    @PostMapping("updateactivity")
    public R updateActivity(@RequestBody PartyBuildingActivityVO partyBuildingActivityVO) {
        return comBpActivityService.updateActivity(partyBuildingActivityVO);
    }
    /**
     * 发布党员活动
     *
     * @param id
     *            主键id
     * @return 发布结果
     */
    @PostMapping("releaseactivity")
    public R releaseActivity(@RequestParam("id") Long id) {
        return comBpActivityService.releaseActivity(id);
    }
    /**
     * 删除党员活动
     *
     * @param id
     *            主键id
     * @return 删除结果
     */
    @PostMapping("deleteactivity")
    public R deleteActivity(@RequestParam("id") Long id) {
        return comBpActivityService.deleteActivity(id);
    }
    /**
     * 分页查询党员活动
     *
     * @param partyBuildingActivityVO
     *            查询条件
     * @return 查询结果
     */
    @PostMapping("pageactivity")
    public R pageActivity(@RequestBody PartyBuildingActivityVO partyBuildingActivityVO) {
        return comBpActivityService.pageActivity(partyBuildingActivityVO);
    }
    /**
     * 增加阅读记录
     *
     * @param comPbDynUserVO
     *            记录内容
     * @return 增加结果
     */
    @PostMapping("adddynuser")
    public R addDynUser(@RequestBody ComPbDynUserVO comPbDynUserVO) {
        return comPbMemberService.addDynUser(comPbDynUserVO);
    }
    /**
     * 删除党员
     *
     * @param id
     *            党员主键
     * @return 删除结果
     */
    @PostMapping("deletepartybuildingmember")
    public R deleteDynUser(@RequestParam("id") Integer id) {
        return comPbMemberService.deleteDynUser(id);
    }
    /**
     * 取消活动
     *
     * @param partyBuildingActivityVO
     *            取消原因
     * @return 操作结果
     */
    @PostMapping("cancelactivity")
    public R cancelActivity(@RequestBody PartyBuildingActivityVO partyBuildingActivityVO) {
        return comBpActivityService.cancelActivity(partyBuildingActivityVO);
    }
    /**
     * 用户的所有党建活动
     *
     * @param userId
     *            用户id
     * @param communityId
     *            社区id
     * @return 党建活动列表
     */
    @PostMapping("listactivity")
    public R listActivity(@RequestParam("userId") Long userId,
                          @RequestParam("communityId") Long communityId,
                          @RequestParam(value = "status", required = false) Integer status) {
        return comBpActivityService.listActivity(userId, communityId, status);
    }
    /**
     * 党员活动人员参入列表
     *
     * @param id
     *            活动id
     * @return 党员集合
     */
    @PostMapping("listpartybuildingmember")
    public R listPartyBuildingMember(@RequestParam("id") Long id) {
        return comBpActivityService.listPartyBuildingMember(id);
    }
    /**
     * 报名、取消报名党员活动
     *
     * @param activitySignUpDTO
     *            操作参数
     * @return 操作结果
     */
    @PostMapping("putactivitysignup")
    public R putActivitySignUp(@RequestBody ActivitySignUpDTO activitySignUpDTO) {
        return comBpActivityService.putActivitySignUp(activitySignUpDTO);
    }
    /**
     * 获取党建活动所有参入人员的id集合
     *
     * @param id
     *            党建活动id
     * @return 人员id集合
     */
    @PostMapping("selectallpartybuildingactivitymembers")
    public R selectAllPartyBuildingActivityMembers(@RequestParam("id") Long id) {
        return comBpActivityService.selectAllPartyBuildingActivityMembers(id);
    }
    /**
     * 定时任务刷新党建动态发布状态
     *
     * @return 刷新数据数量
     */
    @PostMapping("timedtaskpartybuildingstatus")
    R timedTaskPartyBuildingStatus() {
        return comPbMemberService.timedTaskPartyBuildingStatus();
    }
    /**
     * 定时任务取消党建活动
     *
     * @return 党建活动集合
     */
    @PostMapping("timedtaskpartybuildingactivity")
    public R timedTaskPartyBuildingActivity() {
        return comBpActivityService.timedTaskPartyBuildingActivity();
    }
    /**
     * 定时任务刷新党建活动的各个状态 除取消外
     *
     * @return 修改结果
     */
    @PostMapping("timedtaskpartybuildingactivityall")
    public R timedTaskPartyBuildingActivityAll() {
        return comBpActivityService.timedTaskPartyBuildingActivityAll();
    }
    /**
     * 新增服务团队人员
     *
     * @param comPbServiceTeamDTO
     *            新增内容
     * @return 新增结果
     */
    @PostMapping("addserviceteam")
    public R addServiceTeam(@RequestBody ComPbServiceTeamDTO comPbServiceTeamDTO) {
        return comPbServiceTeamService.addServiceTeam(comPbServiceTeamDTO);
    }
    /**
     * 编辑团队人员
     *
     * @param comPbServiceTeamDTO
     *            编辑内容
     * @return 编辑结果
     */
    @PostMapping("putserviceteam")
    public R putServiceTeam(@RequestBody ComPbServiceTeamDTO comPbServiceTeamDTO) {
        return comPbServiceTeamService.putServiceTeam(comPbServiceTeamDTO);
    }
    /**
     * 分页查询服务团队成员
     *
     * @param pageComPbServiceTeamDTO
     *            查询参数
     * @return 查询结果
     */
    @PostMapping("pageserviceteam")
    public R pageServiceTeam(@RequestBody PageComPbServiceTeamDTO pageComPbServiceTeamDTO) {
        return comPbServiceTeamService.PageComPbServiceTeamDTO(pageComPbServiceTeamDTO);
    }
    /**
     * 删除服务团队人员
     *
     * @param comPbServiceTeamDTO
     *            删除主键
     * @return 删除结果
     */
    @PostMapping("deleteserviceteam")
    public R deleteServiceTeam(@RequestBody ComPbServiceTeamDTO comPbServiceTeamDTO) {
        return comPbServiceTeamService.deleteServiceTeam(comPbServiceTeamDTO);
    }
    /**
     * 创建党员活动 小程序创建党员活动
     *
     * @param comPbActivityDTO
     *            创建内容
     * @return 创建结果
     */
    @PostMapping("addactivityinfo")
    R addActivityApplets(@RequestBody ComPbActivityDTO comPbActivityDTO) {
        return comBpActivityService.addActivityApplets(comPbActivityDTO);
    }
    /**
     * 查询用户认证信息
     *
     * @param id
     *            用户id
     * @return 查询结果
     */
    @GetMapping("usercertification")
    R userCertification(@RequestParam("id") Long id) {
        List<ComPbMemberDO> comPbMemberDOList =
            comPbMemberService.list(new QueryWrapper<ComPbMemberDO>().lambda().eq(ComPbMemberDO::getUserId, id));
        List<PartyBuildingMemberVO> partyBuildingMemberVOList = new ArrayList<>();
        comPbMemberDOList.forEach(comPbMemberDO -> {
            PartyBuildingMemberVO partyBuildingMemberVO = new PartyBuildingMemberVO();
            BeanUtils.copyProperties(comPbMemberDO, partyBuildingMemberVO);
            ComPbOrgDO comPbOrgDO = comPbOrgDAO.selectById(partyBuildingMemberVO.getOrgId());
            partyBuildingMemberVO.setOrgName(comPbOrgDO.getName());
            partyBuildingMemberVOList.add(partyBuildingMemberVO);
        });
        return R.ok(partyBuildingMemberVOList);
    }
    /**
     * 查询用户认证信息
     *
     * @param pagePartyBuildingMemberVO
     *            查询参数
     * @return 查询结果
     */
    @PostMapping("pageusercertification")
    R pageUserCertification(@RequestBody PagePartyBuildingMemberVO pagePartyBuildingMemberVO) {
        return comPbMemberService.pagePrePartyBuilingMember(pagePartyBuildingMemberVO);
    }
    /**
     * 社区所有启用的党组织列表
     *
     * @return 党组织集合
     */
    @PostMapping("listpartyorganizationByApp")
    public R listPartyOrganizationByApp(@RequestBody ComListPartyDTO comListPartyDTO) {
        List<PartyOrganizationVO> partyOrganizationVOS =
            partyOrganizationService.listPartyOrganizationByApp(comListPartyDTO);
        return R.ok(partyOrganizationVOS);
    }
    /**
     * 根据党员认证id删除
     *
     * @param id
     *            党员认证id
     * @return 删除结果
     */
    @PostMapping("deleteprepartybuildingmember")
    public R deleteprepartybuildingmember(@RequestParam("id") Long id) {
        return R.ok(comPbMemberService.removeById(id));
    }
    /**
     * 导出党员信息
     *
     * @param organizationVO
     *            请求参数
     * @return 党员信息列表
     */
    @PostMapping("exportPbMember")
    public R exportPbMember(@RequestBody PagePartyOrganizationVO organizationVO) {
        return comPbMemberService.exportPbMember(organizationVO);
    }
    /**
     * 选择人员
     *
     * @param param
     *            查询条件
     * @return 查询结果
     */
    @PostMapping("getTotlePerson")
    public R getTotlePerson(@RequestParam(value = "param", required = false) String param,
        @RequestParam(value = "communityId") Long communityId) {
        return comPbServiceTeamService.getTotlePerson(param, communityId);
    }
    /**
     * 根据党员活动id查询活动下报名人员
     *
     * @param activityId
     *            党员活动id
     * @return 活动下报名人员
     */
    @PostMapping("getTaskPbActivityPeopleList")
    public R getTaskPbActivityPeopleList(@RequestParam("activityId") Long activityId) {
        return comBpActivityService.getTaskPbActivityPeopleList(activityId);
    }
}