///<summery> /// (非学生用户)查看历史发布工作 /// dumei 08.23 ///</summery> ///<summery> /// 更改:增加时间变量 /// dumei 09.08 ///</summery> public static async Task <WorkItemEntity> FindHistoryWork(int provider_id) { var provide = new WorkItemEntity(); provide.total = 0; provide.workItem = new List <WorkEntity>(); var query = @"SELECT teacher_id,work_id,work_name,cover,work_description,address,salary, likes_num,collect_num,start_day,end_day,start_time,end_time,total_time,week_day FROM work WHERE teacher_id=@id"; using var connection = DatabaseConnector.Connect(); await connection.OpenAsync(); using var command = connection.CreateCommand(); command.CommandText = query; command.Parameters.AddWithValue("@id", provider_id); using var reader = await command.ExecuteReaderAsync(); while (reader.Read()) { var temp = new WorkEntity() { work_name = reader.GetString("work_name"), teacher_id = reader.GetInt32("teacher_id"), work_id = reader.GetInt32("work_id"), cover = reader.GetString("cover"), work_description = reader.GetString("work_description"), address = reader.GetString("address"), salary = reader.GetInt32("salary"), //work_time=reader.GetString("work_time"), likes_num = reader.GetInt32("likes_num"), collect_num = reader.GetInt32("collect_num"), //share_num=reader.GetInt32("num"), start_day = reader.GetString("start_day"), end_day = reader.GetString("end_day"), start_time = reader.GetString("start_time"), end_time = reader.GetString("end_time"), total_time = reader.GetDouble("total_time"), week_day = reader.GetInt32("week_day") }; provide.total++; provide.workItem.Add(temp); } return(provide); }
///<summery> /// 学生搜索个人拥有工作 /// chuckle 8.25 ///</summery> public static async Task <WorkItemEntity> FindOwnWork(string search, int id) { WorkItemEntity work = new WorkItemEntity(); work.total = 0; work.workItem = new List <WorkEntity>(); var query = "SELECT teacher_id,work_id,work_name,cover,work_description,address,salary,likes_num,collect_num,start_day,end_day,start_time,end_time,total_time,week_day FROM work JOIN takes USING (work_id) WHERE student_id=@id AND( work_name LIKE @search OR work_description LIKE @search OR address LIKE @search) "; using var connection = DatabaseConnector.Connect(); await connection.OpenAsync(); using var command = connection.CreateCommand(); command.CommandText = query; command.Parameters.AddWithValue("@search", search); command.Parameters.AddWithValue("@id", id); using var reader = await command.ExecuteReaderAsync(); while (reader.Read()) { WorkEntity temp = new WorkEntity(); temp.teacher_id = reader.GetInt32("teacher_id"); temp.work_id = reader.GetInt32("work_id"); temp.work_name = reader.GetString("work_name"); temp.cover = reader.GetString("cover"); temp.work_description = reader.GetString("work_description"); temp.address = reader.GetString("address"); temp.salary = reader.GetInt32("salary"); temp.likes_num = reader.GetInt32("likes_num"); temp.collect_num = reader.GetInt32("collect_num"); temp.start_day = reader.GetString("start_day"); temp.end_day = reader.GetString("end_day"); temp.start_time = reader.GetString("start_time"); temp.end_time = reader.GetString("end_time"); temp.total_time = reader.GetDouble("total_time"); temp.week_day = reader.GetInt32("week_day"); work.total++; work.workItem.Add(temp); } return(work); }
///<summery> /// 用户查看所有工作 /// chuckle 8.25 ///</summery> public static async Task <WorkItemEntity> FindAllWork() { WorkItemEntity work = new WorkItemEntity(); work.total = 0; work.workItem = new List <WorkEntity>(); var query = "SELECT teacher_id,work_id,work_name,cover,work_description,address,salary,likes_num,collect_num,start_day,end_day,start_time,end_time,total_time,week_day FROM work"; using var connection = DatabaseConnector.Connect(); await connection.OpenAsync(); using var command = connection.CreateCommand(); command.CommandText = query; using var reader = await command.ExecuteReaderAsync(); while (reader.Read()) { WorkEntity temp = new WorkEntity(); temp.teacher_id = reader.GetInt32("teacher_id"); temp.work_id = reader.GetInt32("work_id"); temp.work_name = reader.GetString("work_name"); temp.cover = reader.GetString("cover"); temp.work_description = reader.GetString("work_description"); temp.address = reader.GetString("address"); //temp.work_time=reader.GetString("work_time"); temp.salary = reader.GetInt32("salary"); temp.likes_num = reader.GetInt32("likes_num"); temp.collect_num = reader.GetInt32("collect_num"); temp.start_day = reader.GetString("start_day"); temp.end_day = reader.GetString("end_day"); temp.start_time = reader.GetString("start_time"); temp.end_time = reader.GetString("end_time"); temp.total_time = reader.GetDouble("total_time"); temp.week_day = reader.GetInt32("week_day"); work.total++; work.workItem.Add(temp); } return(work); }
public static async Task <WorkItemEntity> ViewInfo(int id) { WorkItemEntity work = new WorkItemEntity(); work.total = 0; work.workItem = new List <WorkEntity>(); var query = "SELECT teacher_id,work_id,work_name,cover,work_description,address,salary,work_time,likes_num,collect_num,share_num FROM work WHERE work_id=ANY (SELECT work_id FROM favorite_has_work WHERE favorite_id=@id);"; using var connection = DatabaseConnector.Connect(); await connection.OpenAsync(); using var command = connection.CreateCommand(); command.CommandText = query; command.Parameters.AddWithValue("@id", id); using var reader = await command.ExecuteReaderAsync(); while (reader.Read()) { WorkEntity temp = new WorkEntity(); temp.teacher_id = reader.GetInt32("teacher_id"); temp.work_id = reader.GetInt32("work_id"); temp.work_name = reader.GetString("work_name"); temp.cover = reader.GetString("cover"); temp.work_description = reader.GetString("work_description"); temp.address = reader.GetString("address"); temp.work_time = reader.GetString("work_time"); temp.salary = reader.GetInt32("salary"); temp.likes_num = reader.GetInt32("likes_num"); temp.collect_num = reader.GetInt32("collect_num"); temp.share_num = reader.GetInt32("share_num"); work.total++; work.workItem.Add(temp); } return(work); }