github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/controllers/user/module.go (about)

     1  // Copyright 2023 IAC. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package user
    16  
    17  type LoginUserData struct {
    18  	ID       int    `json:"id"` // The user's unique ID
    19  	Username string `json:"username"`
    20  	Password string `json:"password"`
    21  	ClientID string `json:"clientid"`
    22  	Token    string `json:"token"`
    23  	Renew    bool   `json:"renew"`
    24  }
    25  
    26  type User struct {
    27  	ID         int    `json:"id"`
    28  	Username   string `json:"username"`
    29  	Password   string `json:"password"`
    30  	ClientID   string `json:"clientid"`
    31  	Token      string `json:"token"`
    32  	CreatedOn  string `json:"createdon"`
    33  	ExpirateOn string `json:"expirateon"`
    34  	Email      string `json:"email"`
    35  	Language   string `json:"language"`
    36  	TimeZone   string `json:"timezone"`
    37  }
    38  
    39  type ChangePwdData struct {
    40  	Username    string `json:"username"`
    41  	OldPassword string `json:"oldpassword"`
    42  	NewPassword string `json:"newpassword"`
    43  }
    44  
    45  var TableName string = "users"
    46  var LoginQuery string = "SELECT ID,Name,LastName, LanguageCode, TimeZoneCode, Password FROM users WHERE LoginName='%s' "
    47  
    48  //AND (Password='%s' OR Password is null OR Password='')"
    49  var GetUserImageQuery string = "SELECT PictureUrl, LoginName FROM users WHERE LoginName='%s'"
    50  
    51  var GetUserMenusQuery string = "Select ID, Name, Description, LngCode, PageType, ParentID, Page, Inputs, Icon, CASE WHEN Exists (SELECT 1 FROM menu_roles MR INNER JOIN user_roles UR ON UR.RoleID = MR.RoleID WHERE MenuID = M.ID AND UserID = %d AND COALESCE(ViewOnly,0) =0) THEN 0 ELSE 1 END As ViewOnly, Position FROM menus  M WHERE COALESCE(Mobile,0) = %d AND COALESCE(Desktop,0) = %d AND COALESCE(ParentID,0) = %d AND COALESCE(MenuShow,0) = 1 AND EXISTS (    SELECT 1 FROM menu_roles MR INNER JOIN user_roles UR ON UR.RoleID = MR.RoleID WHERE UR.UserID = %d AND MR.menuid = M.ID) Order By Position "