Forráskód Böngészése

门户首页加入公司功能

chenw 7 éve
szülő
commit
a8e94dba31

+ 15 - 0
applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/SystemRemindApi.java

@@ -0,0 +1,15 @@
+package com.usoftchina.saas.commons.api;
+
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.AddApplyDTO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+@FeignClient("commons-server")
+public interface SystemRemindApi {
+
+    @PostMapping("/remind/apply/save")
+    Result save(@RequestBody AddApplyDTO addApplyDTO);
+
+}

+ 80 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/AddApplyDTO.java

@@ -0,0 +1,80 @@
+package com.usoftchina.saas.commons.dto;
+
+import com.usoftchina.saas.base.dto.CommonBaseDTO;
+
+import java.io.Serializable;
+
+/**
+ * @Description 加入企业申请  传输对象
+ * @Author chenwei
+ * @Date 2018/12/14
+ */
+public class AddApplyDTO extends CommonBaseDTO implements Serializable {
+
+    private String companyName;
+    private String username;
+    private String mobile;
+    private String roles;
+    /**
+     * 审批状态:  2.待处理  0.不同意   1.同意
+     */
+    private String status;
+    private Long creatorId;
+    private Long companyId;
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
+    public String getRoles() {
+        return roles;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public Long getCreatorId() {
+        return creatorId;
+    }
+
+    public void setCreatorId(Long creatorId) {
+        this.creatorId = creatorId;
+    }
+
+    public void setRoles(String roles) {
+        this.roles = roles;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 63 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/AddApply.java

@@ -0,0 +1,63 @@
+package com.usoftchina.saas.commons.po;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+
+import java.io.Serializable;
+
+/**
+ * @Description 加入申请 实体对象
+ * @Author chenwei
+ * @Date 2018/12/14
+ */
+public class AddApply extends CommonBaseEntity implements Serializable {
+
+    private String username;
+    private String mobile;
+    private String roles;
+    /**
+     * 审批状态:  2.待处理  0.不同意   1.同意
+     */
+    private String status;
+    private Long companyId;
+
+    @Override
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getRoles() {
+        return roles;
+    }
+
+    public void setRoles(String roles) {
+        this.roles = roles;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 52 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/SystemRemindController.java

@@ -0,0 +1,52 @@
+package com.usoftchina.saas.commons.controller;
+
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.AddApplyDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.service.SystemRemindService;
+import com.usoftchina.saas.page.PageDefault;
+import com.usoftchina.saas.page.PageRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Description 系统提醒
+ * @Author chenwei
+ * @Date 2018/12/14
+ */
+@RestController
+@RequestMapping("/remind")
+public class SystemRemindController {
+
+    @Autowired
+    private SystemRemindService systemRemindService;
+
+    /**
+     * @description 申请列表
+     * @param pageRequest
+     * @param listReqDTO
+     * @return
+     */
+    @GetMapping("/apply/list")
+    public Result getApplyList(@PageDefault(number = 1, size = 10) PageRequest pageRequest, ListReqDTO listReqDTO){
+        return Result.success(systemRemindService.getApplyList(pageRequest, listReqDTO));
+    }
+
+    /**
+     * 批准、不批准申请
+     * @param addApplyDTO
+     * @return
+     */
+    @PostMapping("/apply/confirm")
+    public Result confirmApply(@RequestBody AddApplyDTO addApplyDTO){
+        systemRemindService.confirmApply(addApplyDTO);
+        return Result.success();
+    }
+
+    @PostMapping("/apply/save")
+    public Result save(@RequestBody AddApplyDTO addApplyDTO){
+        systemRemindService.save(addApplyDTO);
+        return Result.success();
+    }
+
+}

+ 15 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/SystemRemindMapper.java

@@ -0,0 +1,15 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.commons.dto.AddApplyDTO;
+import com.usoftchina.saas.commons.po.AddApply;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface SystemRemindMapper extends CommonBaseMapper<AddApply> {
+
+    List<AddApplyDTO> getApplyList(@Param("condition") String condition, @Param("companyId") Long companyId);
+
+    void confirmApply(@Param("status") String status, @Param("id") Long id, @Param("updaterId") Long updaterId);
+}

+ 29 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/SystemRemindService.java

@@ -0,0 +1,29 @@
+package com.usoftchina.saas.commons.service;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.commons.dto.AddApplyDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.page.PageRequest;
+
+public interface SystemRemindService {
+
+    /**
+     * 保存加入申请
+     * @param addApplyDTO
+     */
+    void save(AddApplyDTO addApplyDTO);
+
+    /**
+     * 查询申请列表
+     * @param pageRequest
+     * @param listReqDTO
+     * @return
+     */
+    PageInfo<AddApplyDTO> getApplyList(PageRequest pageRequest, ListReqDTO listReqDTO);
+
+    /**
+     * 批准、不批准
+     * @param addApplyDTO
+     */
+    void confirmApply(AddApplyDTO addApplyDTO);
+}

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

@@ -0,0 +1,68 @@
+package com.usoftchina.saas.commons.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.account.api.AccountApi;
+import com.usoftchina.saas.account.dto.AccountDTO;
+import com.usoftchina.saas.commons.dto.AddApplyDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.mapper.SystemRemindMapper;
+import com.usoftchina.saas.commons.po.AddApply;
+import com.usoftchina.saas.commons.service.SystemRemindService;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description TODO
+ * @Author chenwei
+ * @Date 2018/12/14
+ */
+@Service
+public class SystemRemindServiceImpl implements SystemRemindService {
+
+    @Autowired
+    private SystemRemindMapper systemRemindMapper;
+    @Autowired
+    private AccountApi accountApi;
+
+    @Override
+    public void save(AddApplyDTO addApplyDTO) {
+        addApplyDTO.setCreateTime(new Date());
+        AddApply addApply = BeanMapper.map(addApplyDTO, AddApply.class);
+        addApply.setCreatorId(BaseContextHolder.getUserId());
+        addApply.setCreatorName(BaseContextHolder.getUserName());
+        systemRemindMapper.insertSelective(addApply);
+    }
+
+    @Override
+    public PageInfo<AddApplyDTO> getApplyList(PageRequest pageRequest, ListReqDTO listReqDTO) {
+        PageHelper.startPage(pageRequest.getNumber(), pageRequest.getSize());
+        String condition = listReqDTO.getFinalCondition();
+        List<AddApplyDTO> addApplyDTOList = systemRemindMapper.getApplyList(condition, BaseContextHolder.getCompanyId());
+        PageInfo<AddApplyDTO> pageInfo = new PageInfo<AddApplyDTO>(addApplyDTOList);
+        return pageInfo;
+    }
+
+    @Override
+    public void confirmApply(AddApplyDTO addApplyDTO) {
+        //批准
+        if ("1".equals(addApplyDTO.getStatus())){
+            AccountDTO accountDTO = accountApi.getAccount(addApplyDTO.getMobile()).getData();
+            if (!ObjectUtils.isEmpty(accountDTO)){
+                //绑定公司
+                accountApi.bindCompany(accountDTO.getId(), BaseContextHolder.getCompanyId());
+                //绑定角色
+                accountApi.bindRoles(accountDTO.getId(), addApplyDTO.getRoles());
+            }
+        }
+        //更新申请单状态
+        systemRemindMapper.confirmApply(addApplyDTO.getStatus(), addApplyDTO.getId(), BaseContextHolder.getUserId());
+    }
+}

+ 75 - 0
applications/commons/commons-server/src/main/resources/mapper/SystemRemindMapper.xml

@@ -0,0 +1,75 @@
+<?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.SystemRemindMapper">
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.commons.dto.AddApplyDTO">
+        <result column="re_id" jdbcType="INTEGER" property="id" />
+        <result column="re_applyname" jdbcType="VARCHAR" property="username" />
+        <result column="re_applymobile" jdbcType="VARCHAR" property="mobile" />
+        <result column="re_status" jdbcType="VARCHAR" property="status" />
+        <result column="creatorId" jdbcType="INTEGER" property="creatorId" />
+        <result column="creatorName" jdbcType="VARCHAR" property="creatorName" />
+        <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
+    </resultMap>
+    <select id="getApplyList" resultMap="BaseResultMap">
+      SELECT * FROM REMIND
+      <where>
+          <if test="condition != null">
+              ${condition}
+          </if>
+          <if test="companyId != null">
+              AND COMPANYID = #{companyId}
+          </if>
+      </where>
+      ORDER BY RE_STATUS, CREATETIME DESC
+    </select>
+    <update id="confirmApply">
+        UPDATE REMIND SET STATUS = #{status}, updateTime = now(), updaterId = #{updaterId}
+        where re_id = #{id}
+    </update>
+    <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.AddApply">
+        <selectKey resultType="java.lang.Long" keyProperty="id">
+            SELECT LAST_INSERT_ID() AS ID
+        </selectKey>
+        insert into remind
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="username != null">
+                re_applyname,
+            </if>
+            <if test="mobile != null">
+                re_applymobile,
+            </if>
+            <if test="creatorId != null">
+                creatorId,
+            </if>
+            <if test="creatorName != null">
+                creatorName,
+            </if>
+            <if test="createTime != null">
+                createTime,
+            </if>
+            <if test="companyId != null">
+                companyId
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="username != null">
+                #{username, jdbcType=VARCHAR},
+            </if>
+            <if test="mobile != null">
+                #{mobile, jdbcType=VARCHAR},
+            </if>
+            <if test="creatorId != null">
+                #{creatorId, jdbcType=INTEGER},
+            </if>
+            <if test="creatorName != null">
+                #{creatorName, jdbcType=VARCHAR},
+            </if>
+            <if test="createTime != null">
+                #{createTime, jdbcType=TIMESTAMP},
+            </if>
+            <if test="companyId != null">
+                #{companyId, jdbcType=TIMESTAMP}
+            </if>
+        </trim>
+    </insert>
+</mapper>

+ 18 - 0
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/AccountApi.java

@@ -78,4 +78,22 @@ public interface AccountApi {
      */
     @PostMapping("/account/update")
     Result update(@RequestBody AccountUpdateDTO accountUpdateDTO);
+
+    /**
+     * 个人账户绑定公司
+     * @param accountId
+     * @param companyId
+     * @return
+     */
+    @PostMapping("/bind/company")
+    Result bindCompany(@RequestParam long accountId, @RequestParam long companyId);
+
+    /**
+     * 个人账户绑定多个角色
+     * @param accountId
+     * @param roleIds
+     * @return
+     */
+    @PostMapping("/bind/roles")
+    Result bindRoles(@RequestParam("accountId") Long accountId, @RequestParam("roleIds") String roleIds);
 }

+ 9 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/BindCompanyDTO.java

@@ -6,6 +6,15 @@ public class BindCompanyDTO implements Serializable {
 
     private Long companyId;
     private Long accountId;
+    private String username;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
 
     public Long getCompanyId() {
         return companyId;

+ 8 - 0
base-servers/account/account-server/pom.xml

@@ -52,6 +52,14 @@
             <artifactId>sms-api</artifactId>
             <version>1.0.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>commons-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>commons-dto</artifactId>
+        </dependency>
         <!-- db -->
         <dependency>
             <groupId>mysql</groupId>

+ 45 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountCenterController.java

@@ -1,9 +1,16 @@
 package com.usoftchina.saas.account.controller;
 
+import com.usoftchina.saas.account.api.AccountApi;
+import com.usoftchina.saas.account.api.CompanyApi;
+import com.usoftchina.saas.account.dto.AccountDTO;
 import com.usoftchina.saas.account.dto.BindCompanyDTO;
 import com.usoftchina.saas.account.dto.CompanyAccountDTO;
+import com.usoftchina.saas.account.dto.CompanyDTO;
 import com.usoftchina.saas.account.service.AccountCenterService;
 import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.api.SystemRemindApi;
+import com.usoftchina.saas.commons.dto.AddApplyDTO;
+import com.usoftchina.saas.utils.ObjectUtils;
 import com.usoftchina.sso.api.SsoUserSpaceApi;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -16,6 +23,12 @@ public class AccountCenterController {
     private AccountCenterService accountCenterService;
     @Autowired
     private SsoUserSpaceApi ssoUserSpaceApi;
+    @Autowired
+    private CompanyApi companyApi;
+    @Autowired
+    private AccountApi accountApi;
+    @Autowired
+    private SystemRemindApi systemRemindApi;
 
     /**
      * 信息完善界面   保存接口
@@ -71,7 +84,7 @@ public class AccountCenterController {
     }
 
     /**
-     * 校验企业名称时候已在账户中心注册过
+     * 校验企业名称是否已在账户中心注册过
      * @param spaceName
      * @return
      */
@@ -80,4 +93,35 @@ public class AccountCenterController {
         return Result.success(ssoUserSpaceApi.checkSpaceName(spaceName));
     }
 
+    /**
+     * 校验企业是否已开通saas
+     * @param companyName
+     * @return
+     */
+    @GetMapping("/company/isOpen")
+    public Result checkIsOpen(@RequestParam("companyName") String companyName){
+        CompanyDTO companyDTO = companyApi.getCompanyByName(companyName).getData();
+        if (ObjectUtils.isEmpty(companyDTO)){
+            return Result.error();
+        }
+        return Result.success(companyDTO.getId());
+    }
+
+    /**
+     * 加入企业,在系统的提醒中生成一条记录待管理员确认
+     * @param bindCompanyDTO
+     * @return
+     */
+    @PostMapping("/company/join")
+    public Result joinCompany(@RequestBody BindCompanyDTO bindCompanyDTO){
+        AddApplyDTO addApplyDTO = new AddApplyDTO();
+        AccountDTO accountDTO = accountApi.getAccountById(bindCompanyDTO.getAccountId()).getData();
+        addApplyDTO.setMobile(accountDTO.getMobile());
+        addApplyDTO.setCompanyId(bindCompanyDTO.getCompanyId());
+        addApplyDTO.setUsername(bindCompanyDTO.getUsername());
+        addApplyDTO.setStatus("0");
+        systemRemindApi.save(addApplyDTO);
+        return Result.success();
+    }
+
 }

+ 1 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java

@@ -427,7 +427,7 @@ public class AccountController {
     }
 
     /**
-     * 个人账户绑定角色
+     * 个人账户绑定多个角色
      * @param accountId
      * @param roleIds
      * @return