Browse Source

初始化界面校验接口

chenw 7 years ago
parent
commit
a99b9315cd

+ 70 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/InitStatusDTO.java

@@ -0,0 +1,70 @@
+package com.usoftchina.saas.commons.dto;
+
+import java.io.Serializable;
+
+public class InitStatusDTO implements Serializable {
+
+    private Long companyId;
+    private boolean baseSet;
+    private boolean warehouse;
+    private boolean product;
+    private boolean customer;
+    private boolean vendor;
+    private boolean begin;
+
+    public boolean isBegin() {
+        return begin;
+    }
+
+    public void setBegin(boolean begin) {
+        this.begin = begin;
+    }
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
+    public boolean isBaseSet() {
+        return baseSet;
+    }
+
+    public void setBaseSet(boolean baseSet) {
+        this.baseSet = baseSet;
+    }
+
+    public boolean isWarehouse() {
+        return warehouse;
+    }
+
+    public void setWarehouse(boolean warehouse) {
+        this.warehouse = warehouse;
+    }
+
+    public boolean isProduct() {
+        return product;
+    }
+
+    public void setProduct(boolean product) {
+        this.product = product;
+    }
+
+    public boolean isCustomer() {
+        return customer;
+    }
+
+    public void setCustomer(boolean customer) {
+        this.customer = customer;
+    }
+
+    public boolean isVendor() {
+        return vendor;
+    }
+
+    public void setVendor(boolean vendor) {
+        this.vendor = vendor;
+    }
+}

+ 12 - 2
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/CommonController.java

@@ -1,16 +1,26 @@
 package com.usoftchina.saas.commons.controller;
 
 import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.service.CommonService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
 public class CommonController {
 
-    @RequestMapping("/{caller}/export")
+    @Autowired
+    private CommonService commonService;
+
+    @GetMapping("/{caller}/export")
     public Result export(@PathVariable("caller") String caller){
         return Result.success();
     }
 
+    @GetMapping("/init/check")
+    public Result checkInitStatus(){
+        return Result.success(commonService.initCheck());
+    }
+
 }

+ 17 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/CommonMapper.java

@@ -0,0 +1,17 @@
+package com.usoftchina.saas.commons.mapper;
+
+import org.apache.ibatis.annotations.Param;
+
+public interface CommonMapper {
+
+    int getCountBaseSet(@Param("companyId") Long companyId);
+
+    int getCountWarehouse(@Param("companyId") Long companyId);
+
+    int getCountProduct(@Param("companyId") Long companyId);
+
+    int getCountCustomer(@Param("companyId") Long companyId);
+
+    int getCountVendor(@Param("companyId") Long companyId);
+
+}

+ 13 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/CommonService.java

@@ -0,0 +1,13 @@
+package com.usoftchina.saas.commons.service;
+
+import com.usoftchina.saas.commons.dto.InitStatusDTO;
+
+public interface CommonService {
+
+    /**
+     * 检查初始化状态
+     * @return
+     */
+    InitStatusDTO initCheck();
+
+}

+ 46 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/CommonServiceImpl.java

@@ -0,0 +1,46 @@
+package com.usoftchina.saas.commons.service.impl;
+
+import com.usoftchina.saas.commons.dto.InitStatusDTO;
+import com.usoftchina.saas.commons.mapper.CommonMapper;
+import com.usoftchina.saas.commons.service.CommonService;
+import com.usoftchina.saas.context.BaseContextHolder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CommonServiceImpl implements CommonService {
+
+    @Autowired
+    private CommonMapper commonMapper;
+
+    @Override
+    public InitStatusDTO initCheck() {
+        InitStatusDTO result = new InitStatusDTO();
+        int count = 0;
+        Long companyId = BaseContextHolder.getCompanyId();
+        count = commonMapper.getCountBaseSet(companyId);
+        if (count > 0){
+            result.setBaseSet(true);
+        }
+        count = commonMapper.getCountWarehouse(companyId);
+        if (count > 0){
+            result.setWarehouse(true);
+        }
+        count = commonMapper.getCountProduct(companyId);
+        if (count > 0){
+            result.setProduct(true);
+        }
+        count = commonMapper.getCountProduct(companyId);
+        if (count > 0){
+            result.setCustomer(true);
+        }
+        count = commonMapper.getCountVendor(companyId);
+        if (count > 0){
+            result.setVendor(true);
+        }
+        if (result.isBaseSet() && result.isWarehouse() && result.isProduct() && result.isCustomer() && result.isVendor()){
+            result.setBegin(true);
+        }
+        return result;
+    }
+}

+ 19 - 0
applications/commons/commons-server/src/main/resources/mapper/CommonMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.CommonMapper" >
+    <select id="getCountBaseSet" resultType="int">
+        SELECT COUNT(*) FROM ENTERPRISE WHERE COMPANYID = #{companyId}
+    </select>
+    <select id="getCountWarehouse" resultType="int">
+        SELECT COUNT(*) FROM WAREHOUSE WHERE COMPANYID=#{companyId} AND WH_STATUSCODE = 'OPEN'
+    </select>
+    <select id="getCountProduct" resultType="int">
+        SELECT COUNT(*) FROM PRODUCT WHERE COMPANYID=#{companyId} AND PR_STATUSCODE = 'OPEN'
+    </select>
+    <select id="getCountCustomer" resultType="int">
+        SELECT COUNT(*) FROM CUSTOMER WHERE COMPANYID=#{companyId} AND CU_STATUSCODE = 'OPEN'
+    </select>
+    <select id="getCountVendor" resultType="int">
+        SELECT COUNT(*) FROM VENDOR WHERE COMPANYID=#{companyId} AND VE_STATUSCODE = 'OPEN'
+    </select>
+</mapper>