SUPPORT-8427: Fix

This commit is contained in:
Eduard Tihomirov 2024-09-04 15:31:50 +03:00
parent 1dacef1576
commit b7efe76f22
7 changed files with 77 additions and 91 deletions

View file

@ -22,4 +22,5 @@ public class OrgInfoModel {
public String empPosition;
public String mobile;
public String email;
public String userRoles;
}

View file

@ -5,10 +5,8 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import esia.model.*;
import org.bouncycastle.asn1.x509.sigi.PersonalData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author Eduard Tihomirov
@ -64,6 +62,7 @@ public class EsiaDataService {
}
} );
}
orgInfoModel.userRoles = ulDataService.getAllUserRoles(accessToken);
return orgInfoModel;
}

View file

@ -23,4 +23,6 @@ public interface UlDataService {
PersonModel getPersonData(String prnsId, String accessToken);
EsiaAccessToken readToken(String accessToken);
String getAllUserRoles(String accessToken);
}

View file

@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Base64;
import java.util.Optional;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import esia.config.EsiaConfig;
import esia.model.*;
@ -220,4 +221,37 @@ public class UlDataServiceImpl implements UlDataService {
throw new RuntimeException(e);
}
}
@Override
public String getAllUserRoles(String accessToken) {
try {
EsiaAccessToken esiaAccessToken = readToken(accessToken);
String scope = esiaAccessToken.getScope();
String orgOid = scope.substring(scope.indexOf('=') + 1, scope.indexOf(' '));
String prnsId = esiaAccessToken.getSbj_id();
String url = esiaConfig.getEsiaBaseUri() + "rs/orgs/" + orgOid + "/emps/" + prnsId + "/grps?embed=(elements)";
HttpRequest getReq = HttpRequest.newBuilder(URI.create(url))
.header(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded")
.header("Authorization", "Bearer ".concat(accessToken))
.GET()
.timeout(Duration.ofSeconds(60))
.build();
HttpResponse<String> getResp = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(30))
.build()
.send(getReq, HttpResponse.BodyHandlers.ofString());
errorHandler(getResp);
JsonNode rootNode = objectMapper.readTree(getResp.body());
JsonNode elementsNode = rootNode.path("elements");
StringBuilder names = new StringBuilder();
for (JsonNode element : elementsNode) {
String name = element.path("name").asText();
names.append(name).append("\n");
}
return names.toString();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View file

@ -85,6 +85,11 @@ export class OrgDataRoot extends Behavior{
'component.ControlWithValue');
control.setValue(orgInfoModel.email)
}
else if (orgData.dataId == 'userRoles') {
let control: ControlWithValue = orgData.getScriptInObject(orgData.getObjectId(),
'component.ControlWithValue');
control.setValue(orgInfoModel.userRoles)
}
}
});

View file

@ -32,7 +32,7 @@ export class LogOutComponent {
}
public logout(): void {
this.cookieService.remove("isAuth");
this.cookieService.remove("is_auth");
this.router.navigateByUrl("/");
}
@ -41,7 +41,7 @@ export class LogOutComponent {
}
public getIsAuth(): boolean {
return this.cookieService.get("isAuth") != null;
return this.cookieService.get("is_auth") != null;
}
public getOrgUnitName(): string {

View file

@ -323,117 +323,62 @@
</properties>
</scripts>
</children>
<children id="5e633339-5878-4b19-9f56-8b97b5f0f5aa">
<prototypeId>16071adb-3bdf-4c33-b29b-886876016415</prototypeId>
<componentRootId>5e633339-5878-4b19-9f56-8b97b5f0f5aa</componentRootId>
<name>Таблица</name>
<container>true</container>
<children id="9d823f8b-f6c0-4767-a262-717d2d80f69f">
<prototypeId>ba24d307-0b91-4299-ba82-9d0b52384ff2</prototypeId>
<componentRootId>9d823f8b-f6c0-4767-a262-717d2d80f69f</componentRootId>
<name>Роли пользователя</name>
<container>false</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered>
<scripts id="07201df9-ff33-4c71-9aae-a2cfdd028234">
<scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c">
<properties>
<entry>
<key>autoStretchColumns</key>
<value>
<simple>true</simple>
</value>
</entry>
<entry>
<key>cssClasses</key>
<value>
<item id="a3216735-fb23-4653-a3f7-226a28b9a127" removed="false">
<item id="7a2b1d18-0ea1-49c8-b6bf-5d91761ca0a0" removed="false">
<value>
<simple>"okved-list"</simple>
</value>
</item>
<item id="1bca3aba-624d-4edf-a3c3-7f9de8b21fdc" removed="false">
<value>
<simple>"mute"</simple>
<simple>"font-bold"</simple>
</value>
</item>
</value>
</entry>
<entry>
<key>disabled</key>
<value>
<simple>true</simple>
</value>
</entry>
<entry>
<key>rowClickSelectionType</key>
<key>initialValue</key>
<value>
<simple>null</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="1996166f-7922-4f28-a571-9646d956ef37">
<scripts id="737b67e2-295f-4356-a1e1-9419344d8c85"/>
<scripts id="a6ccccd9-354c-4725-9d34-c716cf626048"/>
<scripts id="d38c1af5-2bfe-41cd-ab0f-67040f498127"/>
<scripts id="f203f156-be32-4131-9c86-4d6bac6d5d56">
<enabled>false</enabled>
</scripts>
<scripts id="899a1e40-2d2f-492c-ba74-2d04c4d02e73">
<classRef type="TS">
<className>OrgData</className>
<packageName>esia</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>gridService</key>
<key>dataId</key>
<value>
<complex>
<entry>
<key>loadDao</key>
<value>
<complex>
<entry>
<key>graph</key>
<value>
<simple>{"conditionGroup":{"operator":"AND","conditions":[],"groups":[]},"nodeByIndex":{"0":{"tableName":"org_okved","schemaName":"public","x":387.20000000000005,"y":282.4,"alias":"org_okved","conditionGroup":{"operator":"AND","conditions":[{"column":{"schema":"public","table":"org_okved","entity":"org_okved","name":"code"},"operation":"EQUAL","typeCode":"CONST","values":["\"5\""]}],"groups":[]},"emptyEntityAction":"IGNORE_OR_DELETE"}},"nodes":[{"tableName":"org_okved","schemaName":"public","x":387.20000000000005,"y":282.4,"alias":"org_okved","conditionGroup":{"operator":"AND","conditions":[{"column":{"schema":"public","table":"org_okved","entity":"org_okved","name":"code"},"operation":"EQUAL","typeCode":"CONST","values":["\"5\""]}],"groups":[]},"emptyEntityAction":"IGNORE_OR_DELETE"}],"nodeByEntityName":{"org_okved":{"tableName":"org_okved","schemaName":"public","x":387.20000000000005,"y":282.4,"alias":"org_okved","conditionGroup":{"operator":"AND","conditions":[{"column":{"schema":"public","table":"org_okved","entity":"org_okved","name":"code"},"operation":"EQUAL","typeCode":"CONST","values":["\"5\""]}],"groups":[]},"emptyEntityAction":"IGNORE_OR_DELETE"}},"matrix":[[null]],"mainNodeIndex":0}</simple>
</value>
</entry>
</complex>
</value>
</entry>
</complex>
<simple>"userRoles"</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="be8fe0e1-4909-4224-8664-be55168595c6"/>
<children id="2d713b90-9e5a-428c-a40f-b3d164790032">
<prototypeId>364c8faa-5e56-46cd-9203-d2ec6ef2dc74</prototypeId>
<componentRootId>2d713b90-9e5a-428c-a40f-b3d164790032</componentRootId>
<name>Столбец</name>
<container>false</container>
<childrenReordered>false</childrenReordered>
<scripts id="9c5c7a86-dc40-4b30-a5a7-5e7b4c7ea1e1"/>
<scripts id="fd653fca-12f9-4e35-baa4-b6b5dd3f6d59">
<properties>
<entry>
<key>disableHiding</key>
<value>
<simple>true</simple>
</value>
</entry>
<entry>
<key>displayColumns</key>
<value>
<item id="1fcc8084-6f93-42fd-80f4-61defe451897" removed="true"/>
<item id="4b348c07-e14d-46cc-8c1d-0e079ebebc4c" removed="true"/>
</value>
</entry>
<entry>
<key>displayPopup</key>
<value>
<simple>false</simple>
</value>
</entry>
<entry>
<key>displayType</key>
<value>
<simple>"ONE_COLUMN"</simple>
</value>
</entry>
<entry>
<key>field</key>
<value>
<simple>{"schema":"public","table":"org_okved","entity":"org_okved","name":"okved"}</simple>
</value>
</entry>
</properties>
</scripts>
</children>
</children>
<children id="5e633339-5878-4b19-9f56-8b97b5f0f5aa">
<prototypeId>16071adb-3bdf-4c33-b29b-886876016415</prototypeId>
<componentRootId>5e633339-5878-4b19-9f56-8b97b5f0f5aa</componentRootId>
<name>Таблица</name>
<container>true</container>
<removed>true</removed>
</children>
<children id="20801b92-c2bb-4410-bb65-148130805f1c">
<prototypeId>ba24d307-0b91-4299-ba82-9d0b52384ff2</prototypeId>