yuliang hace 5 años
padre
commit
24e5cf233b

+ 23 - 0
whepi-web/src/main/java/com/bofeng/controller/EpiAdminController.java

@@ -0,0 +1,23 @@
+package com.bofeng.controller;
+
+import com.bofeng.service.EpiAdminService;
+import com.yvan.ModelOps;
+import com.yvan.mvc.Pd;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class EpiAdminController {
+
+    @Autowired
+    private EpiAdminService epiAdminService;
+
+    @ApiOperation("升级业委会角色")
+    @GetMapping("/epi/admin/addRole")
+    public ModelOps adminAddRole(@Pd(name = "we", desc = "手机号码") String we){
+        return ModelOps.newSuccess(epiAdminService.addYwhRole(we));
+    }
+
+}

+ 45 - 0
whepi-web/src/main/java/com/bofeng/dao/EpiAdminMapper.java

@@ -0,0 +1,45 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.EpiAdmin;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface EpiAdminMapper extends BaseMapper<EpiAdmin> {
+
+    @Select(
+            "insert into tp_user\n" +
+                    "(select ur.user_id,u.uptown_id,aa.linkman,aa.phone,now(),now() from sys_user_role ur\n" +
+                    "left join sys_uptown_house up on up.house_id = ur.property_id\n" +
+                    "left join sys_uptown_unit uu on uu.unit_id = up.unit_id\n" +
+                    "left join sys_uptown u on u.uptown_id = uu.uptown_id\n" +
+                    "left join (\n" +
+                    "select ur.user_id,up.linkman,up.phone from sys_user_role ur\n" +
+                    "left join sys_uptown_home up on up.house_id = ur.property_id\n" +
+                    "where ur.role_id = 1 and up.phone = #{we}) aa on aa.user_id = ur.user_id\n" +
+                    "where ur.role_id = 1 and ur.user_id = (select user_id from sys_user_role where property_id = (select house_id from sys_uptown_home where phone = #{we}) and role_id = 1))\n"
+    )
+    void step1(@Param("we") String we);
+
+    @Select(
+            "insert into sys_owner\n" +
+                    "select (select owner_id from (\n" +
+                    "(select ifnull(max(owner_id+0)+1,1) as owner_id from sys_owner)\n" +
+                    ") as tmp),uptown_id,linkman,phone,user_id,now(),user_id,now() from tp_user order by time_create desc limit 1;\n"
+    )
+    void step2(@Param("we") String we);
+
+    @Select(
+            "insert into sys_user_role\n" +
+                    "select (select ur_id from (\n" +
+                    "(select ifnull(max(ur_id+0)+1,1) as ur_id from sys_user_role)\n" +
+                    ") as tmp),user_id, 2,\n" +
+                    "(select owner_id from sys_owner where user_create = (select user_id from tp_user order by time_create desc limit 1))\n" +
+                    ",user_id,now(),user_id,now() from tp_user order by time_create desc limit 1;"
+    )
+    void step3(@Param("we") String we);
+}

+ 14 - 0
whepi-web/src/main/java/com/bofeng/entity/EpiAdmin.java

@@ -0,0 +1,14 @@
+package com.bofeng.entity;
+
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+@TableName("tp_user")
+public class EpiAdmin {
+    @TableId("user_id")
+    private Long userId;
+}

+ 25 - 0
whepi-web/src/main/java/com/bofeng/service/EpiAdminService.java

@@ -0,0 +1,25 @@
+package com.bofeng.service;
+
+import com.bofeng.dao.EpiAdminMapper;
+import com.bofeng.dao.IdRuleMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(readOnly = true)
+public class EpiAdminService {
+
+    @Autowired
+    private EpiAdminMapper epiAdminMapper;
+
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public int addYwhRole(String we) {
+        epiAdminMapper.step1(we);
+        epiAdminMapper.step2(we);
+        epiAdminMapper.step3(we);
+
+        return 1;
+    }
+}