Update product code according to new database
This commit is contained in:
		
							parent
							
								
									50757a2832
								
							
						
					
					
						commit
						11491a0e43
					
				@ -6,42 +6,42 @@ class ProductService:
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def get_name(product_id: int):
 | 
			
		||||
		cursor.execute(f"select name from product where product.product_id = {product_id}")
 | 
			
		||||
		cursor.execute(f"select name from product where product.id = {product_id}")
 | 
			
		||||
		result = cursor.fetchone()
 | 
			
		||||
		return result['name']
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def get_manufacturer(product_id: int):
 | 
			
		||||
		cursor.execute(f"select manufacturer from product where product.product_id = {product_id}")
 | 
			
		||||
		cursor.execute(f"select user.displayname as seller from product inner join user on product.seller_id = user.id where product.id = {product_id}")
 | 
			
		||||
		result = cursor.fetchone()
 | 
			
		||||
		return result['manufacturer']
 | 
			
		||||
		return result['seller']
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def get_price(product_id: int):
 | 
			
		||||
		cursor.execute(f"select price_pc from product where product.product_id = {product_id}")
 | 
			
		||||
		cursor.execute(f"select price_pc from product where product.id = {product_id}")
 | 
			
		||||
		result = cursor['price_pc']
 | 
			
		||||
		return result[0]
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def get_image(product_id: int):
 | 
			
		||||
		cursor.execute(f"select image from product where product.product_id = {product_id}")
 | 
			
		||||
		cursor.execute(f"select image from product where product.id = {product_id}")
 | 
			
		||||
		result = cursor['image']
 | 
			
		||||
		return base64.b64encode(result[0]).decode('utf-8')
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def get_image_name(product_id: int):
 | 
			
		||||
		cursor.execute(f"select image_name from product where product.product_id = {product_id}")
 | 
			
		||||
		cursor.execute(f"select image_name from product where product.id = {product_id}")
 | 
			
		||||
		result = cursor['image_name']
 | 
			
		||||
		return result[0]
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def get_all_info(product_id: int):
 | 
			
		||||
		cursor.execute(f"select name,manufacturer,price_pc,image_name,image from product where product.product_id = {product_id}")
 | 
			
		||||
		cursor.execute(f"select name, user.displayname as seller, price_pc, image_name, image from product inner join user on product.seller_id = user.id where product.id = {product_id}")
 | 
			
		||||
		result = cursor.fetchone()
 | 
			
		||||
 | 
			
		||||
		return {
 | 
			
		||||
			"name": result['name'],
 | 
			
		||||
			"manufacturer": result['manufacturer'],
 | 
			
		||||
			"seller": result['seller'],
 | 
			
		||||
			"price": result['price_pc'],
 | 
			
		||||
			"image_name": result['image_name'],
 | 
			
		||||
			"image": base64.b64encode(result['image']).decode('utf-8')
 | 
			
		||||
 | 
			
		||||
@ -232,7 +232,7 @@ class UserService:
 | 
			
		||||
		:rtype: bool
 | 
			
		||||
		"""
 | 
			
		||||
		displayname_regex = r"^[a-zA-Z.-_]{1,64}$"
 | 
			
		||||
		return re.match(username_regex, displayname)
 | 
			
		||||
		return re.match(displayname_regex, displayname)
 | 
			
		||||
 | 
			
		||||
	@staticmethod
 | 
			
		||||
	def __verify_username(username: str) -> bool:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user