瀏覽代碼

公司的业务

姜永辉 2 年之前
父節點
當前提交
e97b5ce1a5

+ 11 - 4
src/main/java/com/dk/oauth/controller/CompanyController.java

@@ -8,10 +8,7 @@ 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.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 @Api(tags = "企业API接口")
 @RestController
@@ -26,6 +23,16 @@ public class CompanyController {
     @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   : 注册商户

+ 9 - 2
src/main/java/com/dk/oauth/entity/Company.java

@@ -17,6 +17,7 @@ import lombok.experimental.Accessors;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.time.LocalDate;
 import java.util.List;
 import java.time.LocalDateTime;
 
@@ -74,9 +75,9 @@ public class Company extends PageInfo<Company> implements Serializable {
      */
     @Excel(name = "注册日期")
     @ApiModelProperty(value = "注册日期")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime openingDate;
+    private LocalDate openingDate;
 
 
     /**
@@ -237,6 +238,12 @@ public class Company extends PageInfo<Company> implements Serializable {
     private String feedback;
 
 
+    /**
+     * 版本名称
+     */
+    @ApiModelProperty(value = "版本名称")
+    private String gradeName;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 7 - 0
src/main/java/com/dk/oauth/mapper/CompanyMapper.java

@@ -27,6 +27,13 @@ public interface CompanyMapper extends BaseMapper<Company> {
 
     Long countByCond(Company t);
 
+    /**
+     * @desc   : 通过ID查询
+     * @author : 洪旭东
+     * @date   : 2024-02-18 15:21
+     */
+    Company selectById(@Param("cpId") Integer cpId);
+
 //    Company selectByIdForUpdate(@Param("id") Long id);
 //
 //    List<Company> selectByIdsForUpdate(@Param("ids") List<Long> ids);

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

@@ -13,4 +13,6 @@ import com.dk.oauth.entity.Company;
 public interface ICompanyService  extends IService<Company> {
 
     ResponseResultVO registerCompany(Company company);
+
+    ResponseResultVO selectById(Integer id);
 }

+ 12 - 5
src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java

@@ -24,13 +24,20 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
     @Resource
     CompanyMapper companyMapper;
 
-    @Resource
-    private UserMapper userMapper;
+    /**
+     * @desc   : 通过ID查询
+     * @author : admin
+     * @date   : 2023/2/3 13:32
+     */
+    @Override
+    public  ResponseResultVO selectById(Integer id) {
+        return ResponseResultUtil.success(companyMapper.selectById(id));
+    }
 
     /**
-     * @desc   : 注册-商户
+     * @desc : 注册-商户
      * @author : 姜永辉
-     * @date   : 2024-02-20 13:55
+     * @date : 2024-02-20 13:55
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -39,7 +46,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         c.setFlgValid(true);
         c.setCpName(company.getCpName());
         Long aLong = companyMapper.countByCond(c);
-        if (aLong > 0){
+        if (aLong > 0) {
             return ResponseResultUtil.error(ErrorCodeEnum.COMPANY_CODE_EXISTS.getCode(), ErrorCodeEnum.COMPANY_CODE_EXISTS.getMessage());
         }
 

+ 39 - 25
src/main/resources/mapper/CompanyMapper.xml

@@ -5,10 +5,10 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <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,cp_manager,cp_phone,cp_size,shop_size,feedback
+        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>
 
     <!-- 通用查询映射结果 -->
@@ -37,6 +37,8 @@
         <result column="cp_size" property="cpSize"/>
         <result column="shop_size" property="shopSize"/>
         <result column="feedback" property="feedback"/>
+        <result column="gradeName" property="gradeName"/>
+
 
     </resultMap>
 
@@ -44,58 +46,58 @@
     <sql id="Condition">
         <where>
             <if test="cpCode != null and cpCode != ''">
-                AND cp_code = #{cpCode}
+                AND t.cp_code = #{cpCode}
             </if>
             <if test="cpName != null and cpName != ''">
-                AND cp_name = #{cpName}
+                AND t.cp_name = #{cpName}
             </if>
             <if test="svcCode != null and svcCode != ''">
-                AND svc_code = #{svcCode}
+                AND t.svc_code = #{svcCode}
             </if>
             <if test="openingDate != null">
-                AND opening_date = #{openingDate}
+                AND t.opening_date = #{openingDate}
             </if>
             <if test="gradeCode != null and gradeCode != ''">
-                AND grade_code = #{gradeCode}
+                AND t.grade_code = #{gradeCode}
             </if>
             <if test="endDate != null">
-                AND end_date = #{endDate}
+                AND t.end_date = #{endDate}
             </if>
             <if test="maxStaffNum != null">
-                AND max_staff_num = #{maxStaffNum}
+                AND t.max_staff_num = #{maxStaffNum}
             </if>
             <if test="curStaffNum != null">
-                AND cur_staff_num = #{curStaffNum}
+                AND t.cur_staff_num = #{curStaffNum}
             </if>
             <if test="flgValid != null">
-                AND flg_valid = #{flgValid}
+                AND t.flg_valid = #{flgValid}
             </if>
             <if test="remarks != null and remarks != ''">
-                AND remarks = #{remarks}
+                AND t.remarks = #{remarks}
             </if>
             <if test="opCreateTime != null">
-                AND op_create_time = #{opCreateTime}
+                AND t.op_create_time = #{opCreateTime}
             </if>
             <if test="opCreateUserId != null and opCreateUserId != ''">
-                AND op_create_user_id = #{opCreateUserId}
+                AND t.op_create_user_id = #{opCreateUserId}
             </if>
             <if test="opUpdateTime != null">
-                AND op_update_time = #{opUpdateTime}
+                AND t.op_update_time = #{opUpdateTime}
             </if>
             <if test="opUpdateUserId != null and opUpdateUserId != ''">
-                AND op_update_user_id = #{opUpdateUserId}
+                AND t.op_update_user_id = #{opUpdateUserId}
             </if>
             <if test="opAppCode != null and opAppCode != ''">
-                AND op_app_code = #{opAppCode}
+                AND t.op_app_code = #{opAppCode}
             </if>
             <if test="opTimestamp != null">
-                AND op_timestamp = #{opTimestamp}
+                AND t.op_timestamp = #{opTimestamp}
             </if>
             <if test="opDbUser != null and opDbUser != ''">
-                AND op_db_user = #{opDbUser}
+                AND t.op_db_user = #{opDbUser}
             </if>
             <if test="owner != null and owner != ''">
-                AND owner = #{owner}
+                AND t.owner = #{owner}
             </if>
         </where>
     </sql>
@@ -105,12 +107,23 @@
                cp_code,
                cp_name,
                svc_code
-        FROM dkic_a.t_a_company
+        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,
@@ -151,7 +164,8 @@
     <select id="selectByCond" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM dkic_a.t_a_company
+        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}
@@ -162,7 +176,7 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM dkic_a.t_a_company
+        FROM dkic_a.t_a_company t
         <include refid="Condition"/>
     </select>