1010
1111namespace APIJSON . NET . Services
1212{
13+ /// <summary>
14+ ///
15+ /// </summary>
1316 public class IdentityService : IIdentityService
1417 {
1518 private IHttpContextAccessor _context ;
1619 private List < Role > roles ;
1720
21+ /// <summary>
22+ ///
23+ /// </summary>
24+ /// <param name="context"></param>
25+ /// <param name="_roles"></param>
1826 public IdentityService ( IHttpContextAccessor context , IOptions < List < Role > > _roles )
1927 {
2028 _context = context ?? throw new ArgumentNullException ( nameof ( context ) ) ;
2129 roles = _roles . Value ;
2230 }
31+
32+ /// <summary>
33+ ///
34+ /// </summary>
35+ /// <returns></returns>
2336 public string GetUserIdentity ( )
2437 {
2538 return _context . HttpContext . User . FindFirstValue ( ClaimTypes . NameIdentifier ) ;
2639 }
2740
41+ /// <summary>
42+ ///
43+ /// </summary>
44+ /// <returns></returns>
2845 public string GetUserRoleName ( )
2946 {
3047 return _context . HttpContext . User . FindFirstValue ( ClaimTypes . Role ) ;
3148 }
49+
50+ /// <summary>
51+ ///
52+ /// </summary>
53+ /// <returns></returns>
3254 public Role GetRole ( )
3355 {
3456 var role = new Role ( ) ;
@@ -43,23 +65,37 @@ public Role GetRole()
4365 }
4466 return role ;
4567 }
46- public ( bool , string ) GetSelectRole ( string table )
68+
69+ /// <summary>
70+ ///
71+ /// </summary>
72+ /// <param name="table"></param>
73+ /// <returns></returns>
74+ public Tuple < bool , string > GetSelectRole ( string table )
4775 {
4876 var role = GetRole ( ) ;
4977 if ( role == null || role . Select == null || role . Select . Table == null )
5078 {
51- return ( false , $ "appsettings.json权限配置不正确!") ;
79+ return Tuple . Create ( false , $ "appsettings.json权限配置不正确!") ;
5280 }
5381 string tablerole = role . Select . Table . FirstOrDefault ( it => it == "*" || it . Equals ( table , StringComparison . CurrentCultureIgnoreCase ) ) ;
5482
5583 if ( string . IsNullOrEmpty ( tablerole ) )
5684 {
57- return ( false , $ "表名{ table } 没权限查询!") ;
85+ return Tuple . Create ( false , $ "表名{ table } 没权限查询!") ;
5886 }
5987 int index = Array . IndexOf ( role . Select . Table , tablerole ) ;
6088 string selectrole = role . Select . Column [ index ] ;
61- return ( true , selectrole ) ;
89+ return Tuple . Create ( true , selectrole ) ;
6290 }
91+
92+
93+ /// <summary>
94+ ///
95+ /// </summary>
96+ /// <param name="col"></param>
97+ /// <param name="selectrole"></param>
98+ /// <returns></returns>
6399 public bool ColIsRole ( string col , string [ ] selectrole )
64100 {
65101 if ( selectrole . Contains ( "*" ) )
0 commit comments