zhoux 2 лет назад
Родитель
Сommit
f7394afc2e

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

@@ -2,6 +2,7 @@ package com.dk.oauth.controller;
 
 import com.dk.common.response.ResponseResultVO;
 import com.dk.oauth.entity.Company;
+import com.dk.oauth.entity.MenuFrequency;
 import com.dk.oauth.service.ICompanyService;
 import io.lettuce.core.dynamic.annotation.Param;
 import io.swagger.annotations.Api;
@@ -57,4 +58,15 @@ public class CompanyController {
     public ResponseResultVO<?> registerCompany(@RequestBody Company company) {
         return companyService.registerCompany(company);
     }
+
+    /**
+     * @desc   : 保存功能频率
+     * @author : admin
+     * @date   : 2024/3/28 14:55
+     */
+    @ApiOperation( value = "保存功能频率", notes = "保存功能频率" )
+    @PostMapping(value = "/save_menu_frequency")
+    public ResponseResultVO<?> saveMenuFrequency(@RequestBody MenuFrequency menuFrequency) {
+        return companyService.saveMenuFrequency(menuFrequency);
+    }
 }

+ 8 - 4
src/main/java/com/dk/oauth/mapper/CompanyMapper.java

@@ -1,12 +1,9 @@
 package com.dk.oauth.mapper;
 
-import com.dk.oauth.entity.CompanyResponse;
+import com.dk.oauth.entity.*;
 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;
@@ -44,4 +41,11 @@ public interface CompanyMapper extends BaseMapper<Company> {
      */
     String selectServiceAllot(@Param("gradeCode") String gradeCode);
 
+    /**
+     * @desc : 保存功能频率
+     * @author : 周兴
+     * @date : 2024-03-28 15:21
+     */
+    int saveMenuFrequency(MenuFrequency menuFrequency);
+
 }

+ 0 - 2
src/main/java/com/dk/oauth/mapper/UserMapper.java

@@ -85,6 +85,4 @@ public interface UserMapper  extends BaseMapper<UserLogin> {
      * @date : 2023/2/7 14:45
      */
     Map<String, Object> selectUserLogin(@Param("userId") String userId,String appCode);
-
-    updatePassword(
 }

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

@@ -3,6 +3,7 @@ package com.dk.oauth.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.oauth.entity.Company;
+import com.dk.oauth.entity.MenuFrequency;
 import org.springframework.web.bind.annotation.RequestBody;
 
 import java.util.Map;
@@ -20,4 +21,6 @@ public interface ICompanyService  extends IService<Company> {
     ResponseResultVO selectById(Integer id);
 
     ResponseResultVO updateWxUserCompany(Map<String,Object> map);
+
+    ResponseResultVO saveMenuFrequency(MenuFrequency menuFrequency);
 }

+ 5 - 1
src/main/java/com/dk/oauth/service/impl/AuthAccessTokenServiceImpl.java

@@ -345,7 +345,11 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
      */
     public ResponseResultVO<?> changeCp(UserLogin userLogin) throws OAuthSystemException {
         // 更新用户的当前企业
-        userMapper.updateCpid(userLogin.getUserId(),userLogin.getCurrentCp(), userLogin.getJoinedCps());
+        if(userLogin.getCurrentCp() != Constant.Experience.profession.getName()
+                && userLogin.getCurrentCp() != Constant.Experience.Standard.getName() ){
+            userMapper.updateCpid(userLogin.getUserId(),userLogin.getCurrentCp(), userLogin.getJoinedCps());
+        }
+
         //当前公司
         CompanyResponse company = null;
         String accessToken = "";

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

@@ -11,6 +11,7 @@ import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.oauth.entity.Company;
+import com.dk.oauth.entity.MenuFrequency;
 import com.dk.oauth.entity.UserLogin;
 import com.dk.oauth.entity.UserWxLogin;
 import com.dk.oauth.feign.service.OrgFeign;
@@ -153,4 +154,19 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
 
         return ResponseResultUtil.success(company);
     }
+
+    /**
+     * @desc : 保存用户功能频率表
+     * @author : 周兴
+     * @date : 2024/3/28 9:39
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> saveMenuFrequency(MenuFrequency menuFrequency) {
+        menuFrequency.setQty(1);
+        // 保存用户功能频率表
+        companyMapper.saveMenuFrequency(menuFrequency);
+        return ResponseResultUtil.success();
+    }
 }

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

@@ -196,6 +196,30 @@
         <include refid="Condition"/>
     </select>
 
+    <!--新建编辑功能频率-->
+    <insert id="saveMenuFrequency">
+        insert into dkic_a.t_a_menu_frequency
+        (
+        <trim suffixOverrides=",">
+            menu_uuid,
+            cp_id,
+            app_code,
+            qty,
+        </trim>
+        )
+        values
+        (
+        <trim suffixOverrides=",">
+            #{menuUuid} ::uuid,
+            #{cpId},
+            #{appCode},
+            #{qty},
+        </trim>
+        )
+        on conflict (menu_uuid,cp_id,app_code) do update set
+        qty = excluded."qty" + 1;
+    </insert>
+
 
     <insert id="insertBatch">
         insert into dkic_a.t_a_company

+ 54 - 27
src/main/resources/mapper/UserMapper.xml

@@ -27,32 +27,54 @@
 
     <!-- 根据电话号码获取用户信息 -->
     <select id="getByPhone" resultMap="ResultMap">
-        SELECT
-            txu.user_id, txu.user_wxid, txu.user_name, txu.user_phone, txu.user_pwd, txu.current_cp, txu.flg_valid,txu.joined_cps,
-               tac.cp_id AS "join_cp_id",tac.cp_code AS "join_cp_code",tac.cp_name AS "join_cp_name",tac.svc_code AS "join_svc_code",
-            tss.svc_ip AS "join_svc_ip",tss.svc_port AS "join_svc_port"
+        SELECT txu.user_id,
+               txu.user_wxid,
+               txu.user_name,
+               txu.user_phone,
+               txu.user_pwd,
+               txu.current_cp,
+               txu.flg_valid,
+               txu.joined_cps,
+               tac.cp_id    AS "join_cp_id",
+               tac.cp_code  AS "join_cp_code",
+               tac.cp_name  AS "join_cp_name",
+               tac.svc_code AS "join_svc_code",
+               tss.svc_ip   AS "join_svc_ip",
+               tss.svc_port AS "join_svc_port"
         FROM dkic_a.t_wx_user txu
-        LEFT JOIN dkic_a.t_a_company tac
-        ON tac.cp_id = ANY(txu.joined_cps)
-        AND (tac.end_date is null or tac.end_date > now())
-        LEFT JOIN dkic_a.t_s_service tss
-        ON tac.svc_code = tss.svc_code
-        AND tss.flg_valid
+                 LEFT JOIN dkic_a.t_a_company tac
+                           ON tac.cp_id = ANY (txu.joined_cps)
+                               AND (tac.end_date is null or tac.end_date > now())
+                 LEFT JOIN dkic_a.t_s_service tss
+                           ON tac.svc_code = tss.svc_code
+                               AND tss.flg_valid
         where txu.user_phone = #{userPhone}
-        AND txu.flg_valid
+          AND txu.flg_valid
     </select>
 
     <select id="getByWxid" resultMap="ResultMap">
-        SELECT
-            txu.user_id, txu.user_wxid, txu.user_name, txu.user_phone, txu.user_pwd, txu.current_cp, txu.joined_cps,txu.flg_valid
+        SELECT txu.user_id,
+               txu.user_wxid,
+               txu.user_name,
+               txu.user_phone,
+               txu.user_pwd,
+               txu.current_cp,
+               txu.joined_cps,
+               txu.flg_valid
         FROM dkic_a.t_wx_user txu
         where txu.user_wxid = #{userWxid}
           AND txu.flg_valid
     </select>
 
     <select id="selectById" resultMap="ResultMap">
-        SELECT
-            user_id, user_wxid, user_name, user_phone, user_pwd, current_cp,joined_cps, flg_valid
+        SELECT user_id,
+               user_wxid,
+               user_name,
+               user_phone,
+               user_pwd,
+               current_cp,
+               joined_cps,
+               flg_valid
         FROM dkic_a.t_wx_user
         where user_id = #{userId}::uuid
     </select>
@@ -63,29 +85,34 @@
     </insert>
 
     <update id="cleanPhone">
-        update dkic_a.t_wx_user set user_phone = null
+        update dkic_a.t_wx_user
+        set user_phone = null
         where user_phone = #{userPhone}
     </update>
 
     <update id="updateWxid">
-        update dkic_a.t_wx_user set user_wxid = #{userWxid}
+        update dkic_a.t_wx_user
+        set user_wxid = #{userWxid}
         where user_id = #{userId}::uuid
     </update>
 
     <update id="updatePhone">
-        update dkic_a.t_wx_user set user_phone = #{userPhone}
+        update dkic_a.t_wx_user
+        set user_phone = #{userPhone}
         where user_id = #{userId}::uuid
     </update>
-<!--更新微信用的公司-->
+    <!--更新微信用的公司-->
     <update id="updateCpid">
-        update dkic_a.t_wx_user set current_cp = #{currentCp},
-                                    joined_cps = #{joinedCps,typeHandler=IntListTypeHandler}
+        update dkic_a.t_wx_user set current_cp = #{currentCp}
+        <if test="joinedCps != null">
+            ,joined_cps = #{joinedCps,typeHandler=IntListTypeHandler}
+        </if>
         where user_id = #{userId}::uuid
     </update>
 
     <!--新建用户状态表-->
     <insert id="insertOrUpdateUserLogin">
-        insert into  dkic_a.t_wx_user_login
+        insert into dkic_a.t_wx_user_login
         (
         <trim suffixOverrides=",">
             user_id,
@@ -110,8 +137,10 @@
 
     <!--查询用户状态-->
     <select id="selectUserLogin" resultType="java.util.Map">
-        SELECT
-            user_id AS "userId", app_code AS "appCode", token_key AS "tokenKey", op_update_time AS "opUpdateTime"
+        SELECT user_id        AS "userId",
+               app_code       AS "appCode",
+               token_key      AS "tokenKey",
+               op_update_time AS "opUpdateTime"
         FROM dkic_a.t_wx_user_login
         WHERE user_id = #{userId}::uuid
         AND app_code = #{appCode}
@@ -121,9 +150,7 @@
     <update id="updatePassword">
         update dkic_a.t_wx_user
         <set>
-            <if test="userPwd != null">
-                user_pwd = #{userPwd},
-            </if>
+            user_pwd = #{userPwd}
         </set>
         where user_id = #{userId}
     </update>