新增圖資類別crud
This commit is contained in:
		
							parent
							
								
									d5b35002d0
								
							
						
					
					
						commit
						9637fcee9f
					
				@ -93,6 +93,33 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<List<Variable>>> VarList()
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
 | 
			
		||||
            List<Variable> variables = new List<Variable>();
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var sqlString = @$"select * from variable 
 | 
			
		||||
                                    where system_type like 'graph_manage_layer%' and deleted = 0
 | 
			
		||||
                                    order by id asc";
 | 
			
		||||
                
 | 
			
		||||
                variables = await backendRepository.GetAllAsync<Variable>(sqlString);
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
                apiResult.Data = variables;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception exception)
 | 
			
		||||
            {
 | 
			
		||||
                apiResult.Code = "9999";
 | 
			
		||||
                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return apiResult;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<List<GraphList>>> GraManList([FromBody] GraphInfo gi)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<List<UserManagerList>>> UserManagerList()
 | 
			
		||||
        public async Task<ApiResult<List<UserManagerList>>> UserManagerList([FromBody] UserManagerList post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<List<UserManagerList>> apiResult = new ApiResult<List<UserManagerList>>();
 | 
			
		||||
            List<UserManagerList> userManagerList = new List<UserManagerList>();
 | 
			
		||||
@ -56,8 +56,21 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
                var sqlString = @$"SELECT A.userinfo_guid, A.full_name, B.full_name AS 'Role_full_name', A.email, A.phone, A.created_at,A.Account ,B.layer
 | 
			
		||||
                                   FROM userinfo A
 | 
			
		||||
                                   LEFT JOIN role B ON A.role_guid=B.role_guid AND B.deleted='0' 
 | 
			
		||||
                                   WHERE A.deleted = 0
 | 
			
		||||
                                   ORDER BY A.created_at DESC";
 | 
			
		||||
                                   WHERE A.deleted = 0 ";
 | 
			
		||||
 | 
			
		||||
                if (post != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (post.Full_name != null)
 | 
			
		||||
                        sqlString += $@" and A.full_name like '%{post.Full_name}%'";
 | 
			
		||||
                    
 | 
			
		||||
                    if (post.Role_full_name != null)
 | 
			
		||||
                        sqlString += $@" and B.full_name like '%{post.Role_full_name}%'";
 | 
			
		||||
 | 
			
		||||
                    if (post.Status != null)
 | 
			
		||||
                        sqlString += $@" and A.status = '{post.Status}'";
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                sqlString += " ORDER BY A.created_at DESC";
 | 
			
		||||
                userManagerList = await backendRepository.GetAllAsync<UserManagerList>(sqlString);
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
@ -246,7 +259,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
        /// <param name="guid"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<SimpleUser>> GetOneUser([FromBody] string guid)
 | 
			
		||||
        public async Task<ApiResult<SimpleUser>> GetOneUser([FromBody] SaveUserManager post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<SimpleUser> apiResult = new ApiResult<SimpleUser>();
 | 
			
		||||
 | 
			
		||||
@ -254,7 +267,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                simpleUser = await backendRepository.GetOneAsync<SimpleUser>("userinfo", $"userinfo_guid='{guid}'");
 | 
			
		||||
                simpleUser = await backendRepository.GetOneAsync<SimpleUser>("userinfo", $"userinfo_guid='{post.Id}'");
 | 
			
		||||
 | 
			
		||||
                if (simpleUser == null)
 | 
			
		||||
                {
 | 
			
		||||
@ -271,7 +284,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
            {
 | 
			
		||||
                apiResult.Code = "9999";
 | 
			
		||||
                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
			
		||||
            }
 | 
			
		||||
            return apiResult;
 | 
			
		||||
@ -283,7 +296,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
        /// <param name="id"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<string>> DeleteOneUser([FromBody] string guid)
 | 
			
		||||
        public async Task<ApiResult<string>> DeleteOneUser([FromBody] SaveUserManager post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<string> apiResult = new ApiResult<string>();
 | 
			
		||||
 | 
			
		||||
@ -291,7 +304,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                simpleUser = await backendRepository.GetOneAsync<SimpleUser>("userinfo", $"userinfo_guid='{guid}'");
 | 
			
		||||
                simpleUser = await backendRepository.GetOneAsync<SimpleUser>("userinfo", $"userinfo_guid='{post.Id}'");
 | 
			
		||||
 | 
			
		||||
                if (simpleUser == null)
 | 
			
		||||
                {
 | 
			
		||||
@ -300,7 +313,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
                    return apiResult;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                await backendRepository.DeleteOne(guid, "userinfo", "userinfo_guid");
 | 
			
		||||
                await backendRepository.DeleteOne(post.Id, "userinfo", "userinfo_guid");
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
                apiResult.Msg = "刪除成功";
 | 
			
		||||
@ -309,7 +322,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
            {
 | 
			
		||||
                apiResult.Code = "9999";
 | 
			
		||||
                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -395,7 +408,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
        /// <param name="id"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<SimpleRole>> GetOneRole([FromBody] string guid)
 | 
			
		||||
        public async Task<ApiResult<SimpleRole>> GetOneRole([FromBody] PostRole post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<SimpleRole> apiResult = new ApiResult<SimpleRole>();
 | 
			
		||||
 | 
			
		||||
@ -403,7 +416,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                simpleRole = await backendRepository.GetOneAsync<SimpleRole>("role", $"role_guid='{guid}'");
 | 
			
		||||
                simpleRole = await backendRepository.GetOneAsync<SimpleRole>("role", $"role_guid='{post.Id}'");
 | 
			
		||||
 | 
			
		||||
                if (simpleRole == null)
 | 
			
		||||
                {
 | 
			
		||||
@ -419,7 +432,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
            {
 | 
			
		||||
                apiResult.Code = "9999";
 | 
			
		||||
                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
			
		||||
            }
 | 
			
		||||
            return apiResult;
 | 
			
		||||
@ -431,7 +444,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
        /// <param name="id"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<string>> DeleteOneRole([FromBody] string guid)
 | 
			
		||||
        public async Task<ApiResult<string>> DeleteOneRole([FromBody] PostRole post)
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<string> apiResult = new ApiResult<string>();
 | 
			
		||||
 | 
			
		||||
@ -439,7 +452,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                simpleRole = await backendRepository.GetOneAsync<SimpleRole>("role", $"role_guid='{guid}'");
 | 
			
		||||
                simpleRole = await backendRepository.GetOneAsync<SimpleRole>("role", $"role_guid='{post.Id}'");
 | 
			
		||||
 | 
			
		||||
                if (simpleRole == null)
 | 
			
		||||
                {
 | 
			
		||||
@ -450,7 +463,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
                //檢查是否有使用者為該角色
 | 
			
		||||
                var sWhere = $@"deleted = 0 AND role_guid = @Guid";
 | 
			
		||||
                var userInfos = await backendRepository.GetAllAsync<UserInfos>("userinfo", sWhere, new { Guid = guid });
 | 
			
		||||
                var userInfos = await backendRepository.GetAllAsync<UserInfos>("userinfo", sWhere, new { Guid = post.Id });
 | 
			
		||||
                if (userInfos.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    apiResult.Code = "9997";
 | 
			
		||||
@ -459,7 +472,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                await backendRepository.DeleteOne(guid, "role", "role_guid");
 | 
			
		||||
                await backendRepository.DeleteOne(post.Id, "role", "role_guid");
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
                apiResult.Msg = "刪除成功";
 | 
			
		||||
@ -468,7 +481,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
            {
 | 
			
		||||
                apiResult.Code = "9999";
 | 
			
		||||
                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + guid);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Guid=" + post.Id);
 | 
			
		||||
                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -52,5 +52,6 @@ namespace FrontendWebApi.Models
 | 
			
		||||
        public string System_type { get; set; }
 | 
			
		||||
        public string System_key { get; set; }
 | 
			
		||||
        public string system_value { get; set; }
 | 
			
		||||
        public int system_parent_id { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user