You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.9 KiB

package com.dsideal.newUniversityExamination.selectcourse.controller;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.exception.ExceptionCode;
import com.dsideal.exception.SelectCourseException;
import com.dsideal.newUniversityExamination.selectcourse.model.CampusModel;
import com.dsideal.newUniversityExamination.util.COMMON;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record;
/**
* 选课系统 校区相关 by huyue 2018-01-11
*
*/
public class CampusController extends Controller {
public void saveCampus(){
String bureau_id= getPara("bureau_id");
String campus_id=getPara("campus_id");
String campus_name=getPara("campus_name");
String b_use= getPara("b_use");
String describe = getPara("describe");
JSONObject json = new JSONObject();
try {
if (COMMON.isEmpty(campus_name)) {
throw new SelectCourseException(ExceptionCode.IV00007, "campus_name"
+ ExceptionCode.IV00007_MESSAGE);
}
if (COMMON.isEmpty(bureau_id)) {
throw new SelectCourseException(ExceptionCode.IV00007, "bureau_id"
+ ExceptionCode.IV00007_MESSAGE);
}
if (COMMON.isEmpty(b_use)) {
throw new SelectCourseException(ExceptionCode.IV00007, "b_use"
+ ExceptionCode.IV00007_MESSAGE);
}
campus_id =CampusModel.dao.saveCampus(bureau_id,campus_id,campus_name,b_use,describe);
json.put("success", true);
json.put("campus_id", campus_id);
} catch (SelectCourseException e) {
e.printStackTrace();
json.put("success", false);
json.put("info", e.getMessage());
}
renderJson(json);
return;
}
/**
* 根据单位ID获取校区列表
*/
public void getCampusList(){
int pageSize = getParaToInt("pageSize");
int pageNumber = getParaToInt("pageNumber");
String bureau_id = getPara("bureau_id");
String campus_name = getPara("campus_name");
try {
if (COMMON.isEmpty(bureau_id)) {
throw new SelectCourseException(ExceptionCode.IV00007, "bureau_id"
+ ExceptionCode.IV00007_MESSAGE);
}
} catch (SelectCourseException e) {
e.printStackTrace();
JSONObject json = new JSONObject();
json.put("success", false);
json.put("info", e.getMessage());
renderJson(json);
return;
}
String campusList = CampusModel.dao.getCampusList(pageSize,pageNumber,bureau_id,campus_name);
renderJson(campusList);
return;
}
/**
* 删除校区
*/
public void delCampus(){
String campus_ids = getPara("campus_ids");
String label= CampusModel.dao.delCampus(campus_ids);
renderJson(label);
return;
}
/**
* 根据ID获取详情 by huyue 2018-01-12
*/
public void getCampusInfoById(){
String campus_id= getPara("campus_id");
Record record = CampusModel.dao.getCampusInfoById(campus_id);
record.set("success", true);
renderJson(COMMON.convertNull2EmptyString(record));
}
}