Explorar o código

公司的业务

姜永辉 %!s(int64=2) %!d(string=hai) anos
pai
achega
362ca9c889

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

@@ -0,0 +1,25 @@
+package com.dk.oauth.controller;
+
+import com.dk.oauth.service.ICompanyService;
+import io.swagger.annotations.Api;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "企业API接口")
+@RestController
+@RequestMapping("/company")
+public class CompanyController {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    /**
+     * 服务对象
+     */
+    @Autowired
+    private ICompanyService companyService;
+
+
+}

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

@@ -1,23 +1,217 @@
 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.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 HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime 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;
+
+
+    /*
+     * 相关属性
+     * @TableField(exist = false)
+     */
+
+    /*
+     * 关联属性 + 查询条件
+     * @TableField(exist = false)
+     */
+
+
+    private static final long serialVersionUID = 1L;
+
 }

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

@@ -1,19 +1,33 @@
 package com.dk.oauth.mapper;
 
+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
      */
     Company getByCpId(@Param("cpId") Integer cpId);
+
+    int insertBatch(@Param("list") List<Company> list);
+
+    List<Company> selectByCond(Company t);
+
+    Long countByCond(Company t);
+
+//    Company selectByIdForUpdate(@Param("id") Long id);
+//
+//    List<Company> selectByIdsForUpdate(@Param("ids") List<Long> ids);
 }

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

@@ -0,0 +1,8 @@
+package com.dk.oauth.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.dk.oauth.entity.Company;
+
+public interface ICompanyService  extends IService<Company> {
+
+}

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

@@ -0,0 +1,19 @@
+package com.dk.oauth.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dk.oauth.entity.Company;
+import com.dk.oauth.mapper.CompanyMapper;
+import com.dk.oauth.service.ICompanyService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 公司实现类
+ *
+ * @author admin
+ * @since 2023-07-01 09:41:05
+ */
+@Service("companyService")
+public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements ICompanyService {
+
+
+}

+ 158 - 6
src/main/resources/mapper/CompanyMapper.xml

@@ -2,18 +2,170 @@
 <!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">
 
-    <resultMap type="com.dk.oauth.entity.Company" id="ResultMap">
-        <result column="cp_id" property="cpId"/>
+    <!-- 通用设置 -->
+    <!-- 通用查询列 -->
+    <sql id="Base_Column_List">
+        cp_id
+        , cp_code, cp_name, svc_code, opening_date, grade_code, end_date, max_staff_num, cur_staff_num, flg_valid, remarks, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user, owner
+    </sql>
+
+    <!-- 通用查询映射结果 -->
+    <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"/>
     </resultMap>
 
-    <select id="getByCpId" resultMap="ResultMap">
-        SELECT
-            cp_id, cp_code, cp_name, svc_code
+    <!-- 通用条件列 -->
+    <sql id="Condition">
+        <where>
+            <if test="cpCode != null and cpCode != ''">
+                AND cp_code = #{cpCode}
+            </if>
+            <if test="cpName != null and cpName != ''">
+                AND cp_name = #{cpName}
+            </if>
+            <if test="svcCode != null and svcCode != ''">
+                AND svc_code = #{svcCode}
+            </if>
+            <if test="openingDate != null">
+                AND opening_date = #{openingDate}
+            </if>
+            <if test="gradeCode != null and gradeCode != ''">
+                AND grade_code = #{gradeCode}
+            </if>
+            <if test="endDate != null">
+                AND end_date = #{endDate}
+            </if>
+            <if test="maxStaffNum != null">
+                AND max_staff_num = #{maxStaffNum}
+            </if>
+            <if test="curStaffNum != null">
+                AND cur_staff_num = #{curStaffNum}
+            </if>
+            <if test="flgValid != null">
+                AND flg_valid = #{flgValid}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                AND remarks = #{remarks}
+            </if>
+            <if test="opCreateTime != null">
+                AND op_create_time = #{opCreateTime}
+            </if>
+            <if test="opCreateUserId != null and opCreateUserId != ''">
+                AND op_create_user_id = #{opCreateUserId}
+            </if>
+            <if test="opUpdateTime != null">
+                AND op_update_time = #{opUpdateTime}
+            </if>
+            <if test="opUpdateUserId != null and opUpdateUserId != ''">
+                AND op_update_user_id = #{opUpdateUserId}
+            </if>
+            <if test="opAppCode != null and opAppCode != ''">
+                AND op_app_code = #{opAppCode}
+            </if>
+            <if test="opTimestamp != null">
+                AND op_timestamp = #{opTimestamp}
+            </if>
+            <if test="opDbUser != null and opDbUser != ''">
+                AND op_db_user = #{opDbUser}
+            </if>
+            <if test="owner != null and owner != ''">
+                AND 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
-        where cp_id = #{cpId} and (end_date is null or end_date > now()) and flg_valid
+        where cp_id = #{cpId}
+          and (end_date is null or end_date > now())
+          and flg_valid
+    </select>
+
+    <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 t_a_company
+        <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 t_a_company
+        <include refid="Condition"/>
     </select>
 
+
+    <insert id="insertBatch">
+        insert into 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>
+