当前位置:网站首页>Platform management background and merchant menu resource management: merchant role management design
Platform management background and merchant menu resource management: merchant role management design
2022-07-02 17:32:00 【Jue seconds of writing code】
Business role management design
The authority management of merchants is realized through role management , The role and resource energy table establish a general alliance. The general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly, the general assembly . What roles does a user have , It means that this user has
Have access to .
Role management is mainly through RoleRestService And other components access the interface provided by the merchant service , So as to manage the data configuration of roles . Role management includes the addition, deletion, modification and query of roles , The following takes the design of role modification as an example .
Managing controllers in roles MerchantRoleController in , The design of the role modification part is as follows :
@Controller
@RequestMapping("/merchantrole")
public class MerchantRoleController {
private static Logger logger =LoggerFactory.getLogger(MerchantRoleController.class);
@Autowired
private ResourceRestService resourceRestService;
@Autowired
private RoleRestService roleRestService;
@RequestMapping ("/edit/{id} ")
public String edit (CPathvariable Long id, ModelMap model,HttpServletRequestrequest) {
String json = roleRestService. findById(id);
RoleQo roleQo = new Gson() .fromJson(json,RoleQo.class);
String resources = resourceRestService.findList()
List<ResourceQo> resourceVoList = new Gson().fromJson(resources, new
TypeToken<List<ResourceQ0>>(){(}.getType());
// Cache resource list
request.getSession().setAttribute("resources", resourceVoList);
List<Long> rids = new ArrayList<>();
for(ResourceQo resource : roleQo.getResources()){
rids.add(resource.getId());
}
model.addAttribute("resources", resourceVoList);model.addAttribute( "role", roleQo);
mode1.addAttribute("rids", rids);
return""merchantrole/edit";
}
@RequestMapping (method = RequestMethod.POST, value="/update")@ResponseBody
public String update (RoleQ0 roleQ0, HttpServletRequest request)
throws
Exception {
// Through resources ID Specify the associated object
String[] rids = request. getParameterValues ("rids");// Get a list of resources
List<ResourceQo>resourceQoList = (List<ResourceQ0>)
request.getSession() .getAttribute ("resources");
List<ResourceQ0> resourceQos = new ArrayList<ResourceQo>();for (String rid :rids) {
for (ResourceQo resourceVo :resourceQoList) {
if (resourceVo.getId().compareTo(new Long(rid)) == 0)
resourceQos .add(resourceVo);
}
}
}
roleQo.setResources (resourceQ0s);
String ret =roleRestService.update (roleQo);logger.info(" modify =" +ret);
return ret;
}
}among , For resources that have been associated with roles , You can use a resource ID The list of components rids Judge the selected resources in the multi-choice drop-down list box on the page . If it is an associated role , Set it to the selected style .
Corresponding page view edit.html The implementation code is as follows :
<html xmlns:th="http://www.thymeleaf.org">
<script th:src="@(/scripts/merchantrole/edit.js}"></script><form id="saveForm" method="post">
<input type="hidden" name="id" id="id"th:value="${role.id}"/><div class="addInfBtn">
<h3 class="itemTit"><span> The role of information </span></h3><table class="addNewInfList">
<tr>
<th> name </th>
<td width="240">
<input class="inp-list w-200 clear-mr f-left" type
"text"
th: value="${role.name}" id="name" name="name" maxlength="32"/>
<span class="tipstar f-left">*</span>
</td>
<th> resources </th>
<td width="240">
<div >
<select name="rids" id="rids" multiple="multiple">
<option th:each= " resource:${resources}"
th:value="S{resource.id] "
th:text="${#strings.length (resource.name) >20?#strings.substring (resource.name,0,20)+'...':resource.name} "
th: selected="${#lists.contains (rids,
resource.id)}”
></option>
</select>
</div>
</td></tr><tr>
<th> date </th><td>
input onfocus="WdatePicker ({dateFmt:'yyyy-MM-dd
HH:mm:ss'})" type="text" class="inp-list w-200 clear-mr f-left"th:value="$ {role.created} ? $ {#dates.format (role.created, 'yyyy-MM-HH:mm:ss')}:''" id="created" name="created"/>
</td></tr>
</table>
<div class="bottomBtnBox">
<a class="btn-93x38 saveBtn" href="javascript:void (0)"> determine </a>
<a class="btn-93x38 backBtn" href="javascript:closeDialog (0)"> return
</a>
</div></ div>
</form>Use lists Function to determine whether the resource in the drop-down list box has been associated with a role , If it is , Set the selected style to true.
After finishing the design , The display effect is shown in the figure 11-6 Shown .

The data of business information and menu resource management function can be found in the project of this chapter merchant-microservice In order to get , This will make it easier for readers to test .
Summary
This paper mainly realizes the design of access control in the background of platform management 、 Business registration and its authority , And the functions of menu configuration and management . among , Business registration and its authority 、 Menu configuration and management , All through calling the business service REST API The implementation of microservices .
actually , In our microservice architecture design ,Web UI Microservices are developed by calling Rest API The implementation of microservices , When it is necessary to manage various service functions of the e-commerce platform in the platform management background , Can be achieved by calling various micro service interfaces .
The development of microservices has come to an end , Start with the next one , We will discuss the deployment of micro services and the construction of micro service operation environment from the perspective of operation and maintenance .
The content of this article is platform management background and business menu resource management : Business role management design
- The next article is about cloud service environment and Docker Deployment tools ;
- Friends who think the article is good can forward this article and pay attention to Xiaobian ;
- Thank you for your support !
边栏推荐
- SAP Commerce Cloud Storefront 框架选型:Accelerator 还是 Spartacus?
- 什么是软件开发中的 green field 和 brown field 模式 - 绿地开发和棕地开发
- 常用SQL语句(完整范例)
- How to transfer business data with BorgWarner through EDI?
- Eye of depth (III) -- determinant of matrix
- 一年頂十年
- Vscode + eslint configuration
- ROS知识点——消息过滤器 ( message_filters)
- 云通信接口更新迭代——SUBMAIL API V4正式上线
- Common SQL statements (complete example)
猜你喜欢

綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東

【GAMES101】作业4 Bézier 曲线

LeetCode:1380. Lucky number in matrix -- simple

Blog theme "text" summer fresh Special Edition

Sword finger offer 26 Substructure of tree

体验居家办公完成项目有感 | 社区征文

Use the API port of the bridge of knowledge and action to provide resources for partners to access

Income and risk of linear programming example investment

TCP congestion control details | 2 background

A case study of college entrance examination prediction based on multivariate time series
随机推荐
The construction of scalable distributed database cluster and the partition design of oneproxy sub database
From collection to output: inventory those powerful knowledge management tools - inventory of excellent note taking software (4)
[shutter] dart data type (dynamic data type)
TCP拥塞控制详解 | 2. 背景
IDEA2021.1 安装教程
Smart trash can (V) - light up OLED
QStyle实现自绘界面项目实战(二)
2022 interview questions
牛客 JS3 分隔符
泡椒凤爪制作教程
简单介绍BASE64Encoder的使用
How to create a new page for SAP Spartacus storefront
Geoserver: publishing PostGIS data sources
uniapp H5页面调用微信支付
Shutter: action feedback
[web technology] 1233 seconds understand web component
Blog theme "text" summer fresh Special Edition
博客主题 “Text“ 夏日清新特别版
Common SQL statements (complete example)
剑指 Offer 26. 树的子结构