mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.panzhihua.applets.api;
 
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActSocialOrgVO;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.service.community.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
 
/**
 * @author zzj
 */
@Slf4j
@Api(tags = {"社会组织"})
@RestController
@RequestMapping("/comActSocialOrg")
public class ComActSocialOrgApi extends BaseController {
    @Resource
    private CommunityService communityService;
 
    /**
     * 分页查询所有数据
     *
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "社会组织列表", response = ComActSocialOrgVO.class)
    @PostMapping("queryAll")
    public R selectAll(@RequestBody CommonPage commonPage) {
        LoginUserInfoVO loginUserInfoSureNoLogin = this.getLoginUserInfoSureNoLogin();
        if (nonNull(loginUserInfoSureNoLogin)) {
            commonPage.setCommunityId(loginUserInfoSureNoLogin.getCommunityId());
        } else if (isNull(commonPage.getCommunityId())) {
            return R.fail("缺少社区id");
        }
        R r = communityService.detailCommunity(commonPage.getCommunityId());
        if (R.isOk(r)) {
            ComActVO comActVO = JSONObject.parseObject(JSONObject.toJSONString(r.getData()), ComActVO.class);
            if (comActVO != null) {
                commonPage.setStreetId(comActVO.getStreetId());
            }
        }
        commonPage.setCommunityId(null);
        return this.communityService.comActSocialOrgSelectAll(commonPage);
    }
 
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("通过主键查询单条数据")
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Long id){
        return this.communityService.comActSocialOrgSelectOne(id);
    }
    /**
     * 新增数据
     *
     * @param comActSocialOrg 实体对象
     * @return 新增结果
     */
    @ApiOperation("新增社会组织")
    @PostMapping
    public R insert(@RequestBody ComActSocialOrgVO comActSocialOrg) {
        comActSocialOrg.setCommunityId(this.getCommunityId());
        return this.communityService.comActSocialOrgInsert(comActSocialOrg);
    }
 
    /**
     * 修改数据
     *
     * @param comActSocialOrg 实体对象
     * @return 修改结果
     */
    @ApiOperation("修改社会组织")
    @PostMapping("/update")
    public R update(@RequestBody ComActSocialOrgVO comActSocialOrg) {
        return this.communityService.comActSocialOrgUpdate(comActSocialOrg);
    }
 
    /**
     * 删除数据
     *
     * @param id 主键结合
     * @return 删除结果
     */
    @ApiOperation("删除社会组织")
    @GetMapping("del")
    public R delete(@RequestParam("id") Long id) {
        return this.communityService.comActSocialOrgDelete(id);
    }
}