提交 19850694 编写于 作者: Lzw_Fight's avatar Lzw_Fight

feature: user repository function

上级 9c60fbfe
table.user=storage/user.csv=#Id,userName,password,birthday,crateDate,modifiedDate
table.goods=storage/goods.csv=#Id,goodsName,goodsDescription,autionStartTime,crateDate,modifiedDate
\ No newline at end of file
user_base_info:storage/user.csv:#userName,password,birthday,crateDate,modifiedDate
goods_base_info:storage/goods.csv:#Id,goodsName,goodsDescription,autionStartTime,crateDate,modifiedDate
\ No newline at end of file
#!/bin/bash
echo "this is for user domain service."
\ No newline at end of file
#@author Jovan Li
echo "this is for user domain service."
#parameter username,password,againPassword,birthday
function register {
#check parameter
if [ $# -ne 5]
then
echo -1
else
#verify if the same username have been already registered
#input the data to table
fi
}
\ No newline at end of file
#!/bin/bash
#@author Jovan Li
#主启动程序,居中显示
echo "main menu to satrt"
......@@ -20,7 +21,7 @@ do
done
#verify if the storage file are existing
cat config/application_files.properties | while read line || [[ -n ${line} ]]
cat config/database.properties | while read line || [[ -n ${line} ]]
do
echo $line
#avoid the comment
......@@ -30,10 +31,10 @@ do
fi
#if the file is not existing, will initialize it
storage_file=$( echo "$line" | awk -F "=" '{print $2}' )
storage_file=$( echo "$line" | awk -F ":" '{print $2}' )
if ! [ -f $storage_file ]
then
echo "$line" | awk -F "=" '{print $3}' > $storage_file
echo "$line" | awk -F ":" '{print $3}' > $storage_file
fi
done
......
#!/bin/bash
echo " this file is for read data of user"
\ No newline at end of file
#@author Jovan Li
#UserData operation repository
#Properties
userTable=$(grep -w "user_base_info" /config/database.properties | awk -F ":" '{print $2}')
userName=1
password=2
birthda=3
crateDate=4
modifiedDate=5
now=$(date +%Y-%m-%d)
#parameter username,password,birthday
function addUser {
#check parameter
if [ $# -ne 5]
then
echo false
else
echo "$1,$2,$3,$4,$now,$now" >> userTable
echo ture
fi
}
#parameter username
function verifySameUser {
username = $(awk -F "," '{print $1}' usertable | grep -w $1)
#find the same name
if [ -n $username]
exit 1
else
exit 0
fi
done
}
#parameter username,password,birthday
function modifyUser {
#get the line number of the user
lineNumber=$(awk -F "," '{print $1}' usertable | grep -wc $1)
createDate=$(sed -n "${lineNumber}p" | awk -F "," 'print $4')
#user sed command change it
sed "${lineNumber}c/$1,$2,$3,$createDate,$now"
}
#username
function deleteUser {
#get the line number of the user
lineNumber=$(awk -F "," '{print $1}' usertable | grep -wc $1)
#delete the user
sed "${lineNumber}d" usertable > usertable
echo 1
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册