lyhzzz 9 月之前
父節點
當前提交
48ffbef616

+ 0 - 1
src/main/java/com/fdkankan/manage/mapper/IJyPlatformMapper.java

@@ -19,5 +19,4 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface IJyPlatformMapper extends BaseMapper<JyPlatform> {
 
-    Page<JyPlatformVo> pageList(Page<JyPlatformVo> page, JyPlatformParam param);
 }

+ 5 - 2
src/main/java/com/fdkankan/manage/service/IJyUserPlatformService.java

@@ -7,6 +7,8 @@ import com.fdkankan.manage.vo.request.JyPlatformVo;
 import com.fdkankan.manage.vo.request.JyUserPlatformAddParam;
 import com.fdkankan.manage.vo.request.JyUserPlatformParam;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -21,8 +23,6 @@ public interface IJyUserPlatformService extends IService<JyUserPlatform> {
 
     void bindJyUserId(Integer id, Integer jyUserId);
 
-    JyUserPlatform getByPlatformAdmin(Integer platformId);
-
 
     void del(JyUserPlatformAddParam param);
 
@@ -37,4 +37,7 @@ public interface IJyUserPlatformService extends IService<JyUserPlatform> {
     void bindPlatform(Integer id, Integer platformId);
 
     JyUserPlatform getByJyUserId(Integer jyUserId);
+
+
+    void updatePlatformId(Integer id, Integer toPlatformId);
 }

+ 2 - 0
src/main/java/com/fdkankan/manage/service/ISysUserService.java

@@ -30,4 +30,6 @@ public interface ISysUserService extends IService<SysUser> {
     HashMap<Long, Long> groupByRoleId();
 
     HashMap<Long, SysUser> getByIds(Set<Long> sysUserIds);
+
+    void updateRoleId(Long sysUserId, Integer roleId);
 }

+ 47 - 6
src/main/java/com/fdkankan/manage/service/impl/JyPlatformServiceImpl.java

@@ -5,12 +5,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.manage.common.PageInfo;
 import com.fdkankan.manage.common.ResultCode;
 import com.fdkankan.manage.entity.JyPlatform;
+import com.fdkankan.manage.entity.JyUser;
 import com.fdkankan.manage.entity.JyUserPlatform;
+import com.fdkankan.manage.entity.SysUser;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.mapper.IJyPlatformMapper;
-import com.fdkankan.manage.service.IJyPlatformService;
+import com.fdkankan.manage.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fdkankan.manage.service.IJyUserPlatformService;
 import com.fdkankan.manage.vo.request.JyPlatformParam;
 import com.fdkankan.manage.vo.request.JyPlatformVo;
 import org.apache.commons.lang3.StringUtils;
@@ -18,6 +19,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 import java.util.UUID;
 
 /**
@@ -34,18 +36,32 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
 
     @Autowired
     IJyUserPlatformService jyUserPlatformService;
+    @Autowired
+    ISysUserService sysUserService;
+    @Autowired
+    IJyUserService jyUserService;
 
     @Override
     public Object pageList(JyPlatformParam param) {
-        Page<JyPlatformVo> page = this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
-
+        LambdaQueryWrapper<JyPlatform> wrapper = new LambdaQueryWrapper<>();
+        if(StringUtils.isNotBlank(param.getPlatformName())){
+            wrapper.like(JyPlatform::getPlatformAddress,param.getPlatformName());
+        }
+        if(StringUtils.isNotBlank(param.getName())){
+            wrapper.like(JyPlatform::getName,param.getName());
+        }
+        if(StringUtils.isNotBlank(param.getPhone())){
+            wrapper.like(JyPlatform::getPhone,param.getPhone());
+        }
+        wrapper.orderByDesc(JyPlatform::getId);
+        Page<JyPlatform> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
         return PageInfo.PageInfo(page);
     }
 
     @Override
     public void addOrUpdate(JyPlatformVo param) {
         if(StringUtils.isNotBlank(param.getPlatformName()) || StringUtils.isBlank(param.getName())
-                || StringUtils.isBlank(param.getPhone()) || StringUtils.isBlank(param.getIdCard())){
+                ||  StringUtils.isBlank(param.getIdCard())){
 
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
@@ -61,7 +77,7 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
             if(jyPlatform == null){
                 throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
             }
-            jyUserPlatform = jyUserPlatformService.getByPlatformAdmin(jyPlatform.getId());
+            jyUserPlatform = jyUserPlatformService.getByIdCard(jyPlatform.getIdCard());
         }
         BeanUtils.copyProperties(param,jyPlatform);
         BeanUtils.copyProperties(param,jyUserPlatform);
@@ -90,11 +106,36 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
 
     @Override
     public void enable(JyPlatformVo param) {
+        if(param.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        JyPlatform jyPlatform = this.getById(param.getId());
+        if(jyPlatform == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        //update userRole
+        JyUserPlatform jyUserPlatform = jyUserPlatformService.getByIdCard(jyPlatform.getIdCard());
+        JyUser jyUser = jyUserService.getById(jyUserPlatform.getJyUserId());
+        sysUserService.updateRoleId(jyUser.getSysUserId(),48);
 
     }
 
     @Override
     public void disable(JyPlatformVo param) {
+        if(param.getId() == null|| param.getToPlatformId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        JyPlatform jyPlatform = this.getById(param.getId());
+        if(jyPlatform == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        //update userRole
+        JyUserPlatform jyUserPlatform = jyUserPlatformService.getByIdCard(jyPlatform.getIdCard());
+        JyUser jyUser = jyUserService.getById(jyUserPlatform.getJyUserId());
+        sysUserService.updateRoleId(jyUser.getSysUserId(),47);
+
+        jyUserPlatformService.updatePlatformId(param.getId(),param.getToPlatformId());
+
 
     }
 }

+ 12 - 6
src/main/java/com/fdkankan/manage/service/impl/JyUserPlatformServiceImpl.java

@@ -18,8 +18,11 @@ import com.fdkankan.manage.vo.request.JyUserPlatformParam;
 import com.fdkankan.manage.vo.request.JyUserPlatformVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -55,12 +58,6 @@ public class JyUserPlatformServiceImpl extends ServiceImpl<IJyUserPlatformMapper
         this.update(wrapper);
     }
 
-    @Override
-    public JyUserPlatform getByPlatformAdmin(Integer platformId) {
-        LambdaQueryWrapper<JyUserPlatform> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(JyUserPlatform::getPlatformId,platformId);
-        return this.getOne(wrapper);
-    }
 
     @Override
     public void addByParam(JyUserPlatformAddParam param) {
@@ -116,6 +113,15 @@ public class JyUserPlatformServiceImpl extends ServiceImpl<IJyUserPlatformMapper
         return this.getOne(wrapper);
     }
 
+
+    @Override
+    public void updatePlatformId(Integer id, Integer toPlatformId) {
+        LambdaUpdateWrapper<JyUserPlatform> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(JyUserPlatform::getPlatformId,id);
+        wrapper.set(JyUserPlatform::getPlatformId,toPlatformId);
+        this.update(wrapper);
+    }
+
     private Integer getLoginPlatformId(){
         try {
             return   Integer.valueOf(StpUtil.getExtra("platformId").toString());

+ 10 - 0
src/main/java/com/fdkankan/manage/service/impl/SysUserServiceImpl.java

@@ -2,6 +2,7 @@ package com.fdkankan.manage.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.manage.common.ResultCode;
@@ -137,4 +138,13 @@ public class SysUserServiceImpl extends ServiceImpl<ISysUserMapper, SysUser> imp
         }
         return map;
     }
+
+
+    @Override
+    public void updateRoleId(Long sysUserId, Integer roleId) {
+        LambdaUpdateWrapper<SysUser> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(SysUser::getId,sysUserId);
+        wrapper.set(SysUser::getRoleId,roleId);
+        this.update(wrapper);
+    }
 }

+ 3 - 0
src/main/java/com/fdkankan/manage/service/impl/UserServiceImpl.java

@@ -219,6 +219,9 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements I
             JyPlatform jyPlatform = jyPlatformService.getById(jyUserPlatform.getPlatformId());
             if(jyPlatform != null){
                 jyUserPlatformService.bindJyUserId(jyUserPlatform.getId(),jyUser.getId());
+                if(param.getIdCard().equals(jyPlatform.getIdCard())){
+                    sysUserService.updateRoleId(sysUser.getId(),48);
+                }
             }
         }
     }

+ 1 - 0
src/main/java/com/fdkankan/manage/vo/request/JyPlatformVo.java

@@ -10,6 +10,7 @@ import lombok.Data;
 public class JyPlatformVo{
 
     private Integer id;
+    private Integer toPlatformId;
 
     private String platformName;
 

+ 0 - 15
src/main/resources/mapper/manage/JyPlatformMapper.xml

@@ -2,19 +2,4 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fdkankan.manage.mapper.IJyPlatformMapper">
 
-    <select id="pageList" resultType="com.fdkankan.manage.vo.request.JyPlatformVo">
-        select * from t_platform p left join  t_user_plaftform u on p.id = u.platform_id
-        where p.rec_status = 'A' and u.rec_status = 'A'
-        <if test="param.platformAddress != null and param.platformAddress !=''">
-            and p.platform_address like concat ('%',#{param.platformAddress},'%')
-        </if>
-        <if test="param.name != null and param.name !=''">
-            and u.name like concat ('%',#{param.name},'%')
-        </if>
-        <if test="param.phone != null and param.phone !=''">
-            and u.phone like concat ('%',#{param.phone},'%')
-        </if>
-        order by  p.id desc
-
-    </select>
 </mapper>

+ 1 - 1
src/main/resources/mapper/manage/JyUserPlatformMapper.xml

@@ -5,7 +5,7 @@
     <select id="pageList" resultType="com.fdkankan.manage.vo.request.JyUserPlatformVo">
         select * from jy_user_platform up left join jy_user jy on up.jy_user_id = jy.id
                                           left join jy_platform jp on up.platform_id = jp.id
-        where up.rec_status = 'A' and jy.rec_status = 'A' and jp.rec_status = 'A' and up.id_card != jp.id_card
+        where up.rec_status = 'A' and jy.rec_status = 'A' and jp.rec_status = 'A' and jp.status !=0 and up.id_card != jp.id_card
         <if test="param.name != null and param.name !=''">
             and up.name like concat ('%',#{param.name},'%')
         </if>

+ 0 - 5
src/main/resources/mapper/manage/JyUserPlatformUserMapper.xml

@@ -1,5 +0,0 @@
-<?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.fdkankan.manage.mapper.IJyUserPlatformUserMapper">
-
-</mapper>