Jelajahi Sumber

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-oauth

# Conflicts:
#	src/main/java/com/dk/oauth/mapper/CompanyMapper.java
#	src/main/resources/mapper/CompanyMapper.xml

解决冲突
zhoux 2 tahun lalu
induk
melakukan
d259e341fc

+ 47 - 0
src/main/java/com/dk/oauth/controller/CompanyController.java

@@ -0,0 +1,47 @@
+package com.dk.oauth.controller;
+
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.entity.Company;
+import com.dk.oauth.service.ICompanyService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags = "企业API接口")
+@RestController
+@RequestMapping("/company")
+public class CompanyController {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    /**
+     * 服务对象
+     */
+    @Autowired
+    private ICompanyService companyService;
+
+    /**
+     * @desc   : 通过ID查询
+     * @author : admin
+     * @date   : 2023/2/3 13:32
+     */
+    @PostMapping({"{id}"})
+    public ResponseResultVO<?> selectById(@PathVariable Integer id) {
+        return companyService.selectById(id);
+    }
+
+
+    /**
+     * @desc   : 注册商户
+     * @author : admin
+     * @date   : 2024/2/1 14:55
+     */
+    @ApiOperation( value = "注册商户", notes = "注册商户" )
+    @PostMapping({"register_company"})
+    public ResponseResultVO<?> registerCompany(@RequestBody Company company) {
+        return companyService.registerCompany(company);
+    }
+}

+ 242 - 5
src/main/java/com/dk/oauth/entity/Company.java

@@ -1,23 +1,260 @@
 package com.dk.oauth.entity;
 
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.io.Serializable;
+
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.*;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 
-import java.util.Date;
+import java.time.LocalDate;
+import java.util.List;
+import java.time.LocalDateTime;
 
 /**
- * @author : 洪旭东
- * @desc : Company
- * @date : 2024-2-18 15:35
+ * 企业
  */
 @Data
-public class Company {
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("企业")
+@TableName(value = "t_a_company", schema = "dkic_a", autoResultMap = true)
+@ApiModel(value = "实体类:企业", description = "表名:t_a_company")
+public class Company extends PageInfo<Company> implements Serializable {
+
+    /*
+     * 数据库字段
+     */
 
+    /**
+     * 企业ID
+     */
+    @TableId(value = "cp_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+
+    /**
+     * 企业代码 (dc+xxxxxx)
+     */
+    @Excel(name = "企业代码 (dc+xxxxxx)")
+    @ApiModelProperty(value = "企业代码 (dc+xxxxxx)")
     private String cpCode;
 
+
+    /**
+     * 企业名称
+     */
+    @Excel(name = "企业名称")
+    @ApiModelProperty(value = "企业名称")
     private String cpName;
 
+
+    /**
+     * 所在服务器
+     */
+    @Excel(name = "所在服务器")
+    @ApiModelProperty(value = "所在服务器")
     private String svcCode;
 
+
+    /**
+     * 注册日期
+     */
+    @Excel(name = "注册日期")
+    @ApiModelProperty(value = "注册日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate openingDate;
+
+
+    /**
+     * 系统版本
+     */
+    @Excel(name = "系统版本")
+    @ApiModelProperty(value = "系统版本")
+    private String gradeCode;
+
+
+    /**
+     * 结束日期
+     */
+    @Excel(name = "结束日期")
+    @ApiModelProperty(value = "结束日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime endDate;
+
+
+    /**
+     * 人数上限 (可以绑定微信的员工人数)
+     */
+    @Excel(name = "人数上限 (可以绑定微信的员工人数)")
+    @ApiModelProperty(value = "人数上限 (可以绑定微信的员工人数)")
+    private Integer maxStaffNum;
+
+
+    /**
+     * 当前人数 (当前绑定微信的员工人数)
+     */
+    @Excel(name = "当前人数 (当前绑定微信的员工人数)")
+    @ApiModelProperty(value = "当前人数 (当前绑定微信的员工人数)")
+    private Integer curStaffNum;
+
+
+    /**
+     * 有效标识 (1:正常 0:停用)
+     */
+    @Excel(name = "有效标识 (1:正常 0:停用)")
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+
+    /**
+     * 创建时间 (触发器自动处理)
+     */
+    @Excel(name = "创建时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
+    @ApiModelProperty(value = "创建时间 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opCreateTime;
+
+
+    /**
+     * 创建用户 (触发器自动处理)
+     */
+    @Excel(name = "创建用户 (触发器自动处理)")
+    @ApiModelProperty(value = "创建用户 (触发器自动处理)")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String opCreateUserId;
+
+
+    /**
+     * 修改时间 (触发器自动处理)
+     */
+    @Excel(name = "修改时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
+    @ApiModelProperty(value = "修改时间 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opUpdateTime;
+
+
+    /**
+     * 修改用户 (触发器自动处理)
+     */
+    @Excel(name = "修改用户 (触发器自动处理)")
+    @ApiModelProperty(value = "修改用户 (触发器自动处理)")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String opUpdateUserId;
+
+
+    /**
+     * 数据操作应用 (触发器自动处理)
+     */
+    @Excel(name = "数据操作应用 (触发器自动处理)")
+    @ApiModelProperty(value = "数据操作应用 (触发器自动处理)")
+    private String opAppCode;
+
+
+    /**
+     * 数据时间戳 (触发器自动处理)
+     */
+    @Excel(name = "数据时间戳 (触发器自动处理)")
+    @ApiModelProperty(value = "数据时间戳 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opTimestamp;
+
+
+    /**
+     * 数据操作数据库用户 (触发器自动处理)
+     */
+    @Excel(name = "数据操作数据库用户 (触发器自动处理)")
+    @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
+    private String opDbUser;
+
+
+    /**
+     * 所有者 (t_wx_user)
+     */
+    @Excel(name = "所有者 (t_wx_user)")
+    @ApiModelProperty(value = "所有者 (t_wx_user)")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String owner;
+
+    /**
+     * 负责人
+     */
+    @Excel(name = "负责人")
+    @ApiModelProperty(value = "负责人")
+    private String cpManager;
+
+    /**
+     * 负责人联系电话
+     */
+    @Excel(name = "负责人联系电话")
+    @ApiModelProperty(value = "负责人联系电话")
+    private String cpPhone;
+
+
+    /**
+     * 公司规模
+     */
+    @Excel(name = "公司规模")
+    @ApiModelProperty(value = "公司规模")
+    private String cpSize;
+
+    /**
+     * 门店规模
+     */
+    @Excel(name = "门店规模")
+    @ApiModelProperty(value = "门店规模")
+    private String shopSize;
+    /**
+     * 反馈
+     */
+    @Excel(name = "反馈")
+    @ApiModelProperty(value = "反馈")
+    private String feedback;
+
+
+    /**
+     * 版本名称
+     */
+    @ApiModelProperty(value = "版本名称")
+    private String gradeName;
+
+    /*
+     * 相关属性
+     * @TableField(exist = false)
+     */
+
+    /*
+     * 关联属性 + 查询条件
+     * @TableField(exist = false)
+     */
+
+
+    private static final long serialVersionUID = 1L;
+
 }

+ 21 - 1
src/main/java/com/dk/oauth/mapper/CompanyMapper.java

@@ -3,17 +3,37 @@ package com.dk.oauth.mapper;
 import com.dk.oauth.entity.CompanyResponse;
 import org.apache.ibatis.annotations.Param;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.dk.oauth.entity.AuthAccessToken;
+import com.dk.oauth.entity.Company;
+import com.dk.oauth.entity.UserLogin;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @author : 洪旭东
  * @desc : CompanyMapper
  * @date : 2024-2-18 15:39
  */
-public interface CompanyMapper {
+public interface CompanyMapper extends BaseMapper<Company> {
     /**
      * @desc   : 通过ID查询
      * @author : 洪旭东
      * @date   : 2024-02-18 15:21
      */
     CompanyResponse getByCpId(@Param("cpId") Integer cpId);
+
+    int insertBatch(@Param("list") List<Company> list);
+
+    List<Company> selectByCond(Company t);
+
+    Long countByCond(Company t);
+
+    /**
+     * @desc   : 通过ID查询
+     * @author : 洪旭东
+     * @date   : 2024-02-18 15:21
+     */
+    Company selectById(@Param("cpId") Integer cpId);
 }

+ 18 - 0
src/main/java/com/dk/oauth/service/ICompanyService.java

@@ -0,0 +1,18 @@
+package com.dk.oauth.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.entity.Company;
+
+/**
+ * 注册商户接口
+ *
+ * @author admin
+ * @since 2023-07-01 09:41:05
+ */
+public interface ICompanyService  extends IService<Company> {
+
+    ResponseResultVO registerCompany(Company company);
+
+    ResponseResultVO selectById(Integer id);
+}

+ 64 - 0
src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java

@@ -0,0 +1,64 @@
+package com.dk.oauth.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.entity.Company;
+import com.dk.oauth.mapper.CompanyMapper;
+import com.dk.oauth.mapper.UserMapper;
+import com.dk.oauth.service.ICompanyService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+
+/**
+ * 公司实现类
+ *
+ * @author admin
+ * @since 2023-07-01 09:41:05
+ */
+@Service("companyService")
+public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements ICompanyService {
+    @Resource
+    CompanyMapper companyMapper;
+
+    /**
+     * @desc   : 通过ID查询
+     * @author : admin
+     * @date   : 2023/2/3 13:32
+     */
+    @Override
+    public  ResponseResultVO selectById(Integer id) {
+        return ResponseResultUtil.success(companyMapper.selectById(id));
+    }
+
+    /**
+     * @desc : 注册-商户
+     * @author : 姜永辉
+     * @date : 2024-02-20 13:55
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseResultVO registerCompany(Company company) {
+        Company c = new Company();
+        c.setFlgValid(true);
+        c.setCpName(company.getCpName());
+        Long aLong = companyMapper.countByCond(c);
+        if (aLong > 0) {
+            return ResponseResultUtil.error(ErrorCodeEnum.COMPANY_CODE_EXISTS.getCode(), ErrorCodeEnum.COMPANY_CODE_EXISTS.getMessage());
+        }
+
+        company.setCurStaffNum(0);
+        company.setMaxStaffNum(0);
+        companyMapper.insert(company);
+
+        // 注册用户
+
+        // 注册权限
+
+
+        return ResponseResultUtil.success(company);
+    }
+}

+ 1 - 1
src/main/resources/dev/bootstrap.yml

@@ -2,7 +2,7 @@ server:
   port: 7002
 spring:
   application:
-    name: oauth-server
+    name: oauth-server-zx
   cloud:
     nacos:
       config:

+ 212 - 0
src/main/resources/mapper/CompanyMapper.xml

@@ -2,6 +2,14 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.dk.oauth.mapper.CompanyMapper">
 
+    <!-- 通用查询列 -->
+    <sql id="Base_Column_List">
+        t.cp_id
+        , t.cp_code, t.cp_name, t.svc_code, t.opening_date, t.grade_code, t.end_date, t.max_staff_num, t.cur_staff_num, t.flg_valid,
+        t.remarks, t.op_create_time, t.op_create_user_id, t.op_update_time, t.op_update_user_id, t.op_app_code, t.op_timestamp, t.op_db_user,
+        t.owner,t.cp_manager,t.cp_phone,t.cp_size,t.shop_size,t.feedback
+    </sql>
+
     <resultMap type="com.dk.oauth.entity.CompanyResponse" id="ResultMap">
         <result column="cp_id" property="cpId"/>
         <result column="cp_code" property="cpCode"/>
@@ -11,6 +19,35 @@
         <result column="svc_port" property="svcPort"/>
     </resultMap>
 
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.dk.oauth.entity.Company">
+        <id column="cp_id" property="cpId"/>
+        <result column="cp_code" property="cpCode"/>
+        <result column="cp_name" property="cpName"/>
+        <result column="svc_code" property="svcCode"/>
+        <result column="opening_date" property="openingDate" typeHandler="TimestampTypeHandler"/>
+        <result column="grade_code" property="gradeCode"/>
+        <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
+        <result column="max_staff_num" property="maxStaffNum"/>
+        <result column="cur_staff_num" property="curStaffNum"/>
+        <result column="flg_valid" property="flgValid"/>
+        <result column="remarks" property="remarks"/>
+        <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_app_code" property="opAppCode"/>
+        <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
+        <result column="op_db_user" property="opDbUser"/>
+        <result column="owner" property="owner" typeHandler="UuidTypeHandler"/>
+        <result column="cp_manager" property="cpManager"/>
+        <result column="cp_phone" property="cpPhone"/>
+        <result column="cp_size" property="cpSize"/>
+        <result column="shop_size" property="shopSize"/>
+        <result column="feedback" property="feedback"/>
+        <result column="gradeName" property="gradeName"/>
+    </resultMap>
+
     <!--获取企业信息-->
     <select id="getByCpId" resultMap="ResultMap">
         SELECT
@@ -27,4 +64,179 @@
         where tac.cp_id = #{cpId} and (tac.end_date is null or tac.end_date > now()) and tac.flg_valid
     </select>
 
+    <!-- 通用条件列 -->
+    <sql id="Condition">
+        <where>
+            <if test="cpCode != null and cpCode != ''">
+                AND t.cp_code = #{cpCode}
+            </if>
+            <if test="cpName != null and cpName != ''">
+                AND t.cp_name = #{cpName}
+            </if>
+            <if test="svcCode != null and svcCode != ''">
+                AND t.svc_code = #{svcCode}
+            </if>
+            <if test="openingDate != null">
+                AND t.opening_date = #{openingDate}
+            </if>
+            <if test="gradeCode != null and gradeCode != ''">
+                AND t.grade_code = #{gradeCode}
+            </if>
+            <if test="endDate != null">
+                AND t.end_date = #{endDate}
+            </if>
+            <if test="maxStaffNum != null">
+                AND t.max_staff_num = #{maxStaffNum}
+            </if>
+            <if test="curStaffNum != null">
+                AND t.cur_staff_num = #{curStaffNum}
+            </if>
+            <if test="flgValid != null">
+                AND t.flg_valid = #{flgValid}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                AND t.remarks = #{remarks}
+            </if>
+            <if test="opCreateTime != null">
+                AND t.op_create_time = #{opCreateTime}
+            </if>
+            <if test="opCreateUserId != null and opCreateUserId != ''">
+                AND t.op_create_user_id = #{opCreateUserId}
+            </if>
+            <if test="opUpdateTime != null">
+                AND t.op_update_time = #{opUpdateTime}
+            </if>
+            <if test="opUpdateUserId != null and opUpdateUserId != ''">
+                AND t.op_update_user_id = #{opUpdateUserId}
+            </if>
+            <if test="opAppCode != null and opAppCode != ''">
+                AND t.op_app_code = #{opAppCode}
+            </if>
+            <if test="opTimestamp != null">
+                AND t.op_timestamp = #{opTimestamp}
+            </if>
+            <if test="opDbUser != null and opDbUser != ''">
+                AND t.op_db_user = #{opDbUser}
+            </if>
+            <if test="owner != null and owner != ''">
+                AND t.owner = #{owner}
+            </if>
+        </where>
+    </sql>
+
+    <select id="getByCpId" resultMap="BaseResultMap">
+        SELECT cp_id,
+               cp_code,
+               cp_name,
+               svc_code
+        FROM dkic_a.t_a_company t
+        where cp_id = #{cpId}
+          and (end_date is null or end_date > now())
+          and flg_valid
+    </select>
+
+    <!-- 根据主键查询表t_mst_staff的一行数据 -->
+    <select id="selectById" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        ,g.grade_name gradeName
+        FROM dkic_a.t_a_company t
+        left join  sys.t_grade g on t.grade_code = g.grade_code
+        WHERE t.cp_id = #{cpId}
+    </select>
+
+    <insert id="insert">
+        insert into dkic_a.t_a_company
+        (cp_name,
+         svc_code,
+         grade_code,
+         max_staff_num,
+         cur_staff_num,
+         owner,
+         cp_manager,
+         cp_phone,
+         cp_size,
+         shop_size,
+         feedback)
+        values (#{cpName},
+                dkic_a.f_allot_service(#{gradeCode}) ,
+                #{gradeCode}  ,
+                #{maxStaffNum},
+                #{curStaffNum},
+                #{owner}::uuid,
+                #{cpManager},
+                #{cpPhone},
+                #{cpSize},
+                #{shopSize},
+                #{feedback}
+                )
+
+    </insert>
+
+    <sql id="idsForeach">
+        <!-- 根据主键cpId批量操作 -->
+        WHERE cp_id in
+        <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </sql>
+
+    <!-- 查询表t_a_company,(条件查询+分页)列表 -->
+    <select id="selectByCond" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_a.t_a_company t
+
+        <include refid="Condition"/>
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
+
+    <!-- 查询表t_a_company,(条件查询)个数 -->
+    <select id="countByCond" resultType="Long">
+        SELECT
+        count(1)
+        FROM dkic_a.t_a_company t
+        <include refid="Condition"/>
+    </select>
+
+
+    <insert id="insertBatch">
+        insert into dkic_a.t_a_company
+        (
+        <trim suffixOverrides=",">
+            cp_code,
+            cp_name,
+            svc_code,
+            opening_date,
+            grade_code,
+            end_date,
+            max_staff_num,
+            cur_staff_num,
+            remarks,
+            op_app_code,
+            owner,
+        </trim>
+        )
+        values
+        <foreach collection="list" index="index" item="item" separator=",">
+            (
+            <trim suffixOverrides=",">
+                #{item.cpCode},
+                #{item.cpName},
+                #{item.svcCode},
+                #{item.openingDate},
+                #{item.gradeCode},
+                #{item.endDate},
+                #{item.maxStaffNum},
+                #{item.curStaffNum},
+                #{item.remarks},
+                #{item.opAppCode},
+                #{item.owner}::uuid,
+            </trim>
+            )
+        </foreach>
+    </insert>
 </mapper>
+