Browse Source

角色 api

weiximei 6 years ago
parent
commit
76f145ce76

+ 23
- 2
CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/SysRoleController.java View File

1
 package com.community.huiju.controller;
1
 package com.community.huiju.controller;
2
 
2
 
3
+import com.community.commom.mode.ResponseBean;
3
 import com.community.huiju.common.base.BaseController;
4
 import com.community.huiju.common.base.BaseController;
5
+import com.community.huiju.service.IToSysRoleService;
4
 import io.swagger.annotations.Api;
6
 import io.swagger.annotations.Api;
7
+import io.swagger.annotations.ApiImplicitParam;
8
+import io.swagger.annotations.ApiImplicitParams;
9
+import io.swagger.annotations.ApiOperation;
10
+import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.cloud.context.config.annotation.RefreshScope;
11
 import org.springframework.cloud.context.config.annotation.RefreshScope;
6
-import org.springframework.web.bind.annotation.RequestMapping;
7
-import org.springframework.web.bind.annotation.RestController;
12
+import org.springframework.web.bind.annotation.*;
13
+
14
+import javax.servlet.http.HttpSession;
8
 
15
 
9
 @RefreshScope
16
 @RefreshScope
10
 @RestController
17
 @RestController
12
 @Api(value = "运营角色 API", description = "运营角色 API")
19
 @Api(value = "运营角色 API", description = "运营角色 API")
13
 public class SysRoleController extends BaseController {
20
 public class SysRoleController extends BaseController {
14
 
21
 
22
+    @Autowired
23
+    private IToSysRoleService iToSysRoleService;
24
+
25
+    @RequestMapping(value = "/role/list", method = RequestMethod.POST)
26
+    @ApiOperation(value = "获取所有角色", notes = "获取所有角色")
27
+    @ApiImplicitParams({
28
+            @ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "parameter", value = "pageNum第几页;pageSize一页多少行;roleName角色名称(可选)")
29
+    })
30
+    public ResponseBean getRoleAll(@RequestBody String parameter,
31
+                                   HttpSession session){
32
+        ResponseBean responseBean = new ResponseBean();
33
+        responseBean = iToSysRoleService.getAll(parameter);
34
+        return responseBean;
35
+    }
15
 
36
 
16
 
37
 
17
 }
38
 }

+ 1
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToSysRoleMapper.java View File

33
      *
33
      *
34
      * @return
34
      * @return
35
      */
35
      */
36
-    List<ToSysRole> selectAll();
36
+    List<ToSysRole> selectAll(String roleName);
37
 }
37
 }

+ 3
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IToSysRoleService.java View File

19
 
19
 
20
     /**
20
     /**
21
      * 获取所有的角色
21
      * 获取所有的角色
22
+     *
23
+     * @param parameter
22
      * @return
24
      * @return
23
      */
25
      */
24
-    ResponseBean getAll();
26
+    ResponseBean getAll(String parameter);
25
 }
27
 }

+ 12
- 2
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToSysRoleServiceImpl.java View File

1
 package com.community.huiju.service.impl;
1
 package com.community.huiju.service.impl;
2
 
2
 
3
+import com.alibaba.fastjson.JSONObject;
3
 import com.community.commom.mode.ResponseBean;
4
 import com.community.commom.mode.ResponseBean;
4
 import com.community.huiju.dao.ToSysRoleMapper;
5
 import com.community.huiju.dao.ToSysRoleMapper;
5
 import com.community.huiju.model.ToSysRole;
6
 import com.community.huiju.model.ToSysRole;
6
 import com.community.huiju.service.IToSysRoleService;
7
 import com.community.huiju.service.IToSysRoleService;
8
+import com.github.pagehelper.PageHelper;
7
 import lombok.extern.slf4j.Slf4j;
9
 import lombok.extern.slf4j.Slf4j;
8
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.beans.factory.annotation.Autowired;
9
 import org.springframework.stereotype.Service;
11
 import org.springframework.stereotype.Service;
24
     }
26
     }
25
 
27
 
26
     @Override
28
     @Override
27
-    public ResponseBean getAll() {
29
+    public ResponseBean getAll(String parameter) {
28
         ResponseBean responseBean = new ResponseBean();
30
         ResponseBean responseBean = new ResponseBean();
29
-        responseBean.addSuccess(toSysRoleMapper.selectAll());
31
+
32
+        JSONObject jsonObject = JSONObject.parseObject(parameter);
33
+        Integer pageNum = jsonObject.getInteger("pageNum");
34
+        Integer pageSize = jsonObject.getInteger("pageSize");
35
+        String roleName = jsonObject.getString("roleName").trim();
36
+
37
+        PageHelper.startPage(pageNum, pageSize);
38
+        List<ToSysRole> roleList = toSysRoleMapper.selectAll(roleName);
39
+        responseBean.addSuccess(roleList);
30
         return responseBean;
40
         return responseBean;
31
     }
41
     }
32
 }
42
 }

+ 6
- 1
CODE/smart-community/operate-api/src/main/resources/mapper/ToSysRoleMapper.xml View File

135
   <select id="selectAll" resultMap="BaseResultMap">
135
   <select id="selectAll" resultMap="BaseResultMap">
136
     select
136
     select
137
     <include refid="Base_Column_List"/>
137
     <include refid="Base_Column_List"/>
138
-    from to_sys_role where id != 1
138
+    from to_sys_role
139
+    <where>
140
+      <if test="roleName != null and roleName != ''">
141
+        role_name = #{roleName,jdbcType=VARCHAR}
142
+      </if>
143
+    </where>
139
   </select>
144
   </select>
140
 </mapper>
145
 </mapper>

+ 10
- 0
VUECODE/smart-operate-manage/src/api/role.js View File

1
+import request from '@/utils/request'
2
+
3
+// 获取所有角色列表
4
+export function getRoleList(data) {
5
+  return request({
6
+    url: '/role/list',
7
+    method: 'post',
8
+    data
9
+  })
10
+}

+ 14
- 0
VUECODE/smart-operate-manage/src/store/modules/role.js View File

1
+import { getRoleList } from "@/api/role";
2
+
3
+const role = {
4
+
5
+  actions: {
6
+    GetRoleList() {
7
+      getRoleList().then().catch((err)=>{
8
+        
9
+      })
10
+    }
11
+  }
12
+}
13
+
14
+export default role