ソースを参照

Merge remote-tracking branch 'origin/master'

yanliming 5 年 前
コミット
c8bb1f6a74

BIN
document/后端接口.xlsx


+ 1 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/dao/CompanyDAO.java

@@ -15,4 +15,5 @@ public interface CompanyDAO {
 	int delete(String id);
 	List<Company> list();
 	List<Company> search(Map<String, Object> searchParams, List<Sort> sortList);
+    Company findByCreateBy(String userId);
 }

+ 1 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/CompanyService.java

@@ -14,4 +14,5 @@ public interface CompanyService {
 	int delete(String id);
 	List<Company> list();
 	Page<Company> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,List<Sort> sortList);
+    Company findByCreateBy(String userId);
 }

+ 5 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/CompanyServiceImpl.java

@@ -67,4 +67,9 @@ public class CompanyServiceImpl implements CompanyService {
         
         return page;
 	}
+
+	@Override
+	public Company findByCreateBy(String userId) {
+		return companyDAO.findByCreateBy(userId);
+	}
 }

+ 3 - 0
picc-common/src/main/resources/mapper/base/Company.xml

@@ -188,4 +188,7 @@ id_,name_,legal_name,legal_card,legal_card_file,uscc_code,uscc_files,type_,busin
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+    <select id="findByCreateBy" resultMap="CompanyMap">
+		select * from base_company where create_by=#{0} and del_flag=0 limit 1
+	</select>
 </mapper>

+ 94 - 0
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/CompanyController.java

@@ -1,9 +1,103 @@
 package com.jpsoft.picc.modules.auth.controller;
 
+import com.alibaba.druid.util.StringUtils;
+import com.jpsoft.picc.modules.base.entity.Company;
+import com.jpsoft.picc.modules.base.service.CompanyService;
+import com.jpsoft.picc.modules.common.dto.MessageResult;
+import com.jpsoft.picc.modules.common.utils.PojoUtils;
+import com.jpsoft.picc.modules.pub.dto.CompanyInfoDTO;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.jasig.cas.client.authentication.AttributePrincipal;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.UUID;
+
 @Api(description="企业信息管理")
 @RestController
+@RequestMapping("/auth/company")
 public class CompanyController {
+    @Autowired
+    private CompanyService companyService;
+
+    @GetMapping(value="detail")
+    @ApiOperation(value = "获取企业信息")
+    public MessageResult<CompanyInfoDTO> detail(HttpServletRequest request){
+        MessageResult<CompanyInfoDTO> messageResult = new MessageResult<>();
+
+        try {
+            CompanyInfoDTO companyInfoDTO = new CompanyInfoDTO();
+
+            //todo
+            AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
+
+            Company company = companyService.findByCreateBy(principal.getName());
+
+            if(company!=null) {
+                PojoUtils.map(company, companyInfoDTO);
+                messageResult.setData(companyInfoDTO);
+            }
+            else{
+                messageResult.setData(companyInfoDTO);
+            }
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping(value="save")
+    @ApiOperation(value = "保存企业信息")
+    public MessageResult<String> save(CompanyInfoDTO companyInfoDTO,HttpServletRequest request){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            //todo
+            AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
+
+            if (StringUtils.isEmpty(companyInfoDTO.getId())){
+                Company company = new Company();
+
+                PojoUtils.map(companyInfoDTO, company);
+
+                company.setId(UUID.randomUUID().toString());
+                company.setCreateTime(new Date());
+                company.setCreateBy(principal.getName());
+                company.setDelFlag(false);
+
+                companyService.insert(company);
+
+                messageResult.setData(company.getId());
+            }
+            else {
+                Company company = companyService.get(companyInfoDTO.getId());
+                PojoUtils.map(companyInfoDTO, company);
+                company.setUpdateTime(new Date());
+                company.setUpdateBy(principal.getName());
+
+                companyService.update(company);
+
+                messageResult.setData(company.getId());
+            }
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
 }

+ 5 - 73
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pub/controller/CompanyUserController.java

@@ -23,8 +23,12 @@ import javax.servlet.http.HttpSession;
 import java.util.Date;
 import java.util.UUID;
 
+/***
+ * 账户信息在荆鹏云中统一管理
+ */
+@Deprecated
 @RestController
-@Api(description = "企业用户操作")
+//@Api(description = "企业用户操作")
 @RequestMapping("/companyUser")
 public class CompanyUserController {
     @Autowired
@@ -175,78 +179,6 @@ public class CompanyUserController {
         return messageResult;
     }
 
-    @GetMapping(value="getCompanyInformation")
-    @ApiOperation(value = "获取企业信息")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "companyId",value = "企业用户编号", required = true, paramType = "query"),
-    })
-    public MessageResult<CompanyInfoDTO> getCompanyInformation(String companyId){
-        MessageResult<CompanyInfoDTO> messageResult = new MessageResult<>();
-
-        try {
-            //todo
-            Company company = companyService.get(companyId);
-
-            CompanyInfoDTO companyInfoDTO = new CompanyInfoDTO();
-            PojoUtils.map(company,companyInfoDTO);
-
-            messageResult.setData(companyInfoDTO);
-            messageResult.setResult(true);
-        }
-        catch (Exception ex){
-            messageResult.setResult(false);
-            messageResult.setMessage(ex.getMessage());
-        }
-
-        return messageResult;
-    }
-
-    @PostMapping(value="saveCompanyInformation")
-    @ApiOperation(value = "保存企业信息")
-    public MessageResult<String> saveCompanyInformation(CompanyInfoDTO companyInfoDTO){
-        MessageResult<String> messageResult = new MessageResult<>();
-
-        try {
-            //todo
-            if (StringUtils.isEmpty(companyInfoDTO.getId())){
-                Company company = new Company();
-
-                PojoUtils.map(companyInfoDTO, company);
-
-                company.setId(UUID.randomUUID().toString());
-                company.setCreateTime(new Date());
-
-                companyService.insert(company);
-
-                messageResult.setData(company.getId());
-            }
-            else {
-                Company company = companyService.get(companyInfoDTO.getId());
-                PojoUtils.map(companyInfoDTO, company);
-                company.setUpdateTime(new Date());
-
-                companyService.update(company);
-
-                messageResult.setData(company.getId());
-            }
-
-            CompanyUser companyUser = companyUserService.get(companyInfoDTO.getCompanyUserId());
-
-            if (companyUser!=null) {
-                companyUser.setCompanyId(companyInfoDTO.getId());
-                companyUserService.update(companyUser);
-            }
-
-            messageResult.setResult(true);
-        }
-        catch (Exception ex){
-            messageResult.setResult(false);
-            messageResult.setMessage(ex.getMessage());
-        }
-
-        return messageResult;
-    }
-
     @PostMapping(value="updatePhoneNumber")
     @ApiOperation(value = "更新账户手机号")
     @ApiImplicitParams({

+ 1 - 0
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pub/controller/UserController.java

@@ -115,6 +115,7 @@ public class UserController {
 
             Map<String, Object> map = new HashMap<>();
 
+            //{"serialNumber":"000101000178","phone":"13986703087","userName":"2142006","userId":"178"}
             for (String key : principal.getAttributes().keySet()) {
                 map.put(key, principal.getAttributes().get(key));
             }

+ 0 - 2
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pub/dto/CompanyInfoDTO.java

@@ -7,8 +7,6 @@ import lombok.Data;
 @Data
 @ApiModel(value = "企业信息")
 public class CompanyInfoDTO {
-    @ApiModelProperty(value = "企业用户编号")
-    private String companyUserId;
     @ApiModelProperty(value = "企业编号")
     private String id;
     @ApiModelProperty(value = "企业名称")