当前位置:网站首页>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 !
边栏推荐
- After meeting a full stack developer from Tencent, I saw what it means to be proficient in MySQL tuning
- ETH数据集下载及相关问题
- From collection to output: inventory those powerful knowledge management tools - inventory of excellent note taking software (4)
- uniapp H5页面调用微信支付
- Chapter 3 of hands on deep learning - (1) linear regression is realized from scratch_ Learning thinking and exercise answers
- 牛客JS2 文件扩展名
- 智能垃圾桶(五)——点亮OLED
- Sword finger offer 25 Merge two sorted linked lists
- Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
- About me
猜你喜欢
Qstype implementation of self drawing interface project practice (II)
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
871. 最低加油次数
剑指 Offer 26. 树的子结构
TCP congestion control details | 2 background
Microservice architecture practice: Construction of scalable distributed database cluster
chrome浏览器快速访问stackoverflow
Example nonlinear integer programming
[essay solicitation activity] Dear developer, RT thread community calls you to contribute
Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
随机推荐
Schoolbag novel multithreaded crawler [easy to understand]
Alibaba Tianchi SQL learning notes - Day3
智能垃圾桶(五)——点亮OLED
ROS knowledge point - message_filters
Blog theme "text" summer fresh Special Edition
博客主题 “Text“ 夏日清新特别版
easyswoole3.2重启不成功
QStyle实现自绘界面项目实战(二)
[shutter] dart data type (dynamic data type)
After meeting a full stack developer from Tencent, I saw what it means to be proficient in MySQL tuning
Un an à dix ans
13、Darknet YOLO3
Experience home office, feel the completion of the project | community essay solicitation
一年頂十年
Does digicert SSL certificate support Chinese domain name application?
JS20 数组扁平化
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition (a sign in, B sign in, C sign in, D thinking +mst
One year is worth ten years
简单线性规划问题
Use the API port of the bridge of knowledge and action to provide resources for partners to access