浏览代码

文件柜手机端增删改查,分配部门和人员权限功能后台接口

yanliming 10 月之前
父节点
当前提交
c50e297b2c

+ 4 - 0
common/src/main/java/com/jpsoft/railroad/modules/base/entity/OaFileInfo.java

@@ -61,6 +61,10 @@ public class OaFileInfo {
 	@ApiModelProperty(value = "创建人")
 	private String createByN;
 
+	@Transient
+	@ApiModelProperty(value = "创建所属部门")
+	private String orgName;
+
 			@Transient
 	@ApiModelProperty(value = "文件列表")
 	private List<Map> urlList;

+ 12 - 6
common/src/main/resources/mapper/base/OaFileInfo.xml

@@ -129,12 +129,18 @@
 			<if test="searchParams.name != null">
 				and a.name_ like #{searchParams.name}
 			</if>
-			<if test="searchParams.businessIds != null">
-				and a.id_ in (select file_id from base_oa_file_reg_user_info
-				where del_flag = 0
-				<foreach item="businessId" collection="searchParams.businessIds"  open="and business_id in (" separator="," close=")">
-					#{businessId}
-				</foreach>
+			<if test="searchParams.createBy != null">
+				<![CDATA[
+					and (a.create_by = #{searchParams.createBy}
+				]]>
+				<if test="searchParams.businessIds != null">
+					or a.id_ in (select file_id from base_oa_file_reg_user_info
+					where del_flag = 0
+					<foreach item="businessId" collection="searchParams.businessIds"  open="and business_id in (" separator="," close=")">
+						#{businessId}
+					</foreach>
+					)
+				</if>
 				)
 			</if>
 		</where>

+ 262 - 1
web/src/main/java/com/jpsoft/railroad/modules/mobile/controller/OaFileInfoApi.java

@@ -2,7 +2,10 @@ package com.jpsoft.railroad.modules.mobile.controller;
 
 
 import com.github.pagehelper.Page;
+import com.jpsoft.railroad.modules.base.dto.OaFileRelationDTO;
 import com.jpsoft.railroad.modules.base.entity.OaFileInfo;
+import com.jpsoft.railroad.modules.base.entity.OaFileRegUserInfo;
+import com.jpsoft.railroad.modules.base.entity.Organization;
 import com.jpsoft.railroad.modules.base.entity.RegUser;
 import com.jpsoft.railroad.modules.base.service.OaFileInfoService;
 import com.jpsoft.railroad.modules.base.service.OaFileRegUserInfoService;
@@ -16,6 +19,10 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +48,12 @@ public class OaFileInfoApi {
     @Autowired
     private OaFileInfoService oaFileInfoService;
 
+    @Autowired
+    private OrganizationService organizationService;
+
+    @Autowired
+    private OaFileRegUserInfoService oaFileRegUserInfoService;
+
 
     @ApiOperation(value="公告列表")
     @RequestMapping(value = "oaFileInfoList",method = RequestMethod.POST)
@@ -72,14 +85,30 @@ public class OaFileInfoApi {
                 searchParams.put("createTime",queryDate);
             }
 
-            if(queryDate != null){
+            if(StringUtils.isNotEmpty(name)){
                 searchParams.put("name","%" + name + "%");
             }
 
             searchParams.put("businessIds",Arrays.asList(regUser.getId(),regUser.getOrgId()));
 
+            searchParams.put("createBy",regUser.getId());
+
             Page<OaFileInfo> page = oaFileInfoService.pageSearchByMobile(searchParams,pageIndex,pageSize,true,sortList);
 
+            for (OaFileInfo oaFileInfo:page) {
+                if(StringUtils.isNotEmpty(oaFileInfo.getCreateBy())){
+                    RegUser regUser1 = regUserService.get(oaFileInfo.getCreateBy());
+                    if(regUser1!=null){
+                        oaFileInfo.setCreateByN(regUser1.getName());
+
+                        Organization organization = organizationService.get(regUser1.getOrgId());
+                        if(organization!=null){
+                            oaFileInfo.setOrgName(organization.getName());
+                        }
+                    }
+                }
+            }
+
             msgResult.setResult(true);
             msgResult.setData(PojoUtils.pageWrapper(page));
         }
@@ -123,4 +152,236 @@ public class OaFileInfoApi {
 
         return msgResult;
     }
+
+
+
+    @ApiOperation(value="获取部门和人员信息")
+    @RequestMapping(value = "query",method = RequestMethod.GET)
+    public MessageResult<Map> query(String id) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+            Map map = new HashMap();
+
+            List<Organization> orgList = organizationService.findAllListOrder();
+
+            List<RegUser> regUserList = regUserService.findAllListOrder();
+
+            List<OaFileRegUserInfo> orgRelationList = oaFileRegUserInfoService.findRelationByFileId(id, "1");
+
+            List<OaFileRegUserInfo> regUserRelationList = oaFileRegUserInfoService.findRelationByFileId(id, "2");
+
+
+            map.put("orgList",orgList);
+            map.put("regUserList",regUserList);
+            map.put("orgRelationList",orgRelationList);
+            map.put("regUserRelationList",regUserRelationList);
+
+            msgResult.setResult(true);
+            msgResult.setData(map);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value = "更新相关联部门或者人员")
+    @PostMapping("relationItem")
+    public MessageResult<Integer> relationItem(@RequestBody OaFileRelationDTO dto, @RequestAttribute String subject) {
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+
+            int affectCount = oaFileRegUserInfoService.relationItem(dto,subject);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value = "添加文件")
+    @PostMapping("add")
+    public MessageResult<OaFileInfo> add(@RequestBody OaFileInfo oaFileInfo, @RequestAttribute String subject) {
+        MessageResult<OaFileInfo> msgResult = new MessageResult<>();
+
+        try {
+            oaFileInfo.setId(UUID.randomUUID().toString());
+            oaFileInfo.setDelFlag(false);
+            oaFileInfo.setCreateBy(subject);
+            oaFileInfo.setCreateTime(new Date());
+
+            JSONArray jsonArray = new JSONArray();
+
+            if (oaFileInfo.getUrlList() != null) {
+                for (Map<String, String> map : oaFileInfo.getUrlList()) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("name", map.get("name"));
+                    jsonObject.put("url", map.get("url"));
+                    jsonArray.add(jsonObject);
+                }
+            }
+
+            if (jsonArray.size() > 0) {
+                oaFileInfo.setUrl(jsonArray.toString());
+            }
+
+
+            int affectCount = oaFileInfoService.insert(oaFileInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(oaFileInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "获取文件")
+    @GetMapping("edit/{id}")
+    public MessageResult<OaFileInfo> edit(@PathVariable("id") String id) {
+        MessageResult<OaFileInfo> msgResult = new MessageResult<>();
+
+        try {
+            OaFileInfo oaFileInfo = oaFileInfoService.get(id);
+
+            if (oaFileInfo != null) {
+                String url = oaFileInfo.getUrl();
+
+                List<Map> annexFileList = new ArrayList<>();
+
+                if (StringUtils.isNotEmpty(url)) {
+
+                    JSONArray jsonArray = JSONArray.fromObject(url);
+
+                    for (Object object : jsonArray) {
+                        Map map = new HashedMap();
+                        JSONObject jsonObject = JSONObject.fromObject(object);
+                        String fileName = jsonObject.get("name").toString();
+                        String urlAddress = jsonObject.get("url").toString();
+                        map.put("fileName", fileName);
+                        map.put("url", urlAddress);
+                        map.put("name", fileName);
+                        annexFileList.add(map);
+                    }
+                }
+
+                oaFileInfo.setUrlList(annexFileList);
+
+
+                msgResult.setResult(true);
+                msgResult.setData(oaFileInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "更新文件")
+    @PostMapping("update")
+    public MessageResult<OaFileInfo> update(@RequestBody OaFileInfo oaFileInfo, @RequestAttribute String subject) {
+        MessageResult<OaFileInfo> msgResult = new MessageResult<>();
+
+        try {
+            oaFileInfo.setUpdateBy(subject);
+            oaFileInfo.setUpdateTime(new Date());
+
+
+            JSONArray jsonArray = new JSONArray();
+
+            if (oaFileInfo.getUrlList() != null) {
+                for (Map<String, String> map : oaFileInfo.getUrlList()) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("name", map.get("name"));
+                    jsonObject.put("url", map.get("url"));
+                    jsonArray.add(jsonObject);
+                }
+            }
+
+            if (jsonArray.size() > 0) {
+                oaFileInfo.setUrl(jsonArray.toString());
+            }
+
+            int affectCount = oaFileInfoService.update(oaFileInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(oaFileInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "删除文件")
+    @PostMapping("delete/{id}")
+    public MessageResult<OaFileInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
+        MessageResult<OaFileInfo> msgResult = new MessageResult<>();
+
+        try {
+
+            OaFileInfo oaFileInfo = oaFileInfoService.get(id);
+            oaFileInfo.setDelFlag(true);
+            oaFileInfo.setUpdateBy(subject);
+            oaFileInfo.setUpdateTime(new Date());
+
+            int affectCount = oaFileInfoService.update(oaFileInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库删除失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }