Procházet zdrojové kódy

所有单位列表

jz.kai před 5 roky
rodič
revize
e28da1cf99

+ 13 - 3
web/src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java

@@ -9,6 +9,8 @@ import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.service.CompanyInfoService;
+import com.jpsoft.smart.modules.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -29,7 +31,8 @@ public class CompanyInfoController {
 
     @Autowired
     private CompanyInfoService companyInfoService;
-
+    @Autowired
+    private UserService userService;
     @Autowired
     private CompanyPositionService companyPositionService;
 
@@ -307,10 +310,17 @@ public class CompanyInfoController {
 
     @ApiOperation(value="所有单位列表")
     @RequestMapping(value = "list",method = RequestMethod.POST)
-    public MessageResult<List<CompanyInfo>> list(){
+    public MessageResult<List<CompanyInfo>> list(@RequestAttribute String subject){
         MessageResult<List<CompanyInfo>> msgResult = new MessageResult<>();
+        User user = userService.get(subject);
+        List<CompanyInfo> list = new ArrayList<>();
 
-        List<CompanyInfo> list = companyInfoService.list();
+        if (userService.hasRole(subject,"SYSADMIN")) {
+            list = companyInfoService.list();
+        }
+        if(userService.hasRole(subject,"ADMIN")){
+            list.add(companyInfoService.get(user.getCompanyId()));
+        }
 
         msgResult.setResult(true);
         msgResult.setData(list);

+ 39 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/WarningPusherController.java

@@ -7,6 +7,8 @@ import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.base.entity.WarningPusher;
 import com.jpsoft.smart.modules.base.service.WarningPusherService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -222,4 +224,41 @@ public class WarningPusherController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="绑定微信")
+    @PostMapping("bindWeChat")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "编号", required = true, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "openId",value = "微信id", required = true, paramType = "form",dataType = "String")
+    })
+    public MessageResult<WarningPusher> bindWeChat(@RequestParam(value="id",defaultValue="") String id,
+                                                   @RequestParam(value="openId",defaultValue="") String openId,
+                                                   @RequestAttribute String subject){
+        MessageResult<WarningPusher> msgResult = new MessageResult<>();
+
+        try {
+            WarningPusher warningPusher = warningPusherService.get(id);
+            warningPusher.setOpenId(openId);
+            warningPusher.setUpdateBy(subject);
+            warningPusher.setUpdateTime(new Date());
+
+            int affectCount = warningPusherService.update(warningPusher);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(warningPusher);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }