|
|
|
@ -1,8 +1,13 @@
|
|
|
|
|
package com.dsideal.resource.Base.Controller;
|
|
|
|
|
|
|
|
|
|
import com.dsideal.resource.Base.Model.BaseModel;
|
|
|
|
|
import com.dsideal.resource.Interceptor.EmptyInterface;
|
|
|
|
|
import com.dsideal.resource.Interceptor.IsNumericInterface;
|
|
|
|
|
import com.dsideal.resource.Util.RetKit;
|
|
|
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
import com.jfinal.core.Controller;
|
|
|
|
|
import com.jfinal.ext.interceptor.GET;
|
|
|
|
|
import com.jfinal.ext.interceptor.POST;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
@ -14,13 +19,86 @@ public class BaseController extends Controller {
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取学段列表
|
|
|
|
|
*/
|
|
|
|
|
@Before({GET.class})
|
|
|
|
|
public void getStageList() {
|
|
|
|
|
List<Record> list = bm.getStageList();
|
|
|
|
|
Page<Record> page=new Page<>();
|
|
|
|
|
Page<Record> page = new Page<>();
|
|
|
|
|
page.setList(list);
|
|
|
|
|
page.setPageSize(20);
|
|
|
|
|
page.setTotalRow(list.size());
|
|
|
|
|
page.setPageNumber(1);
|
|
|
|
|
renderJson(RetKit.renderSuccess(page));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:增加科目
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@EmptyInterface({"subject_name", "subject_code"})
|
|
|
|
|
@IsNumericInterface({"sort_id", "stage_id"})
|
|
|
|
|
public void addSubject(String subject_name, String subject_code, int stage_id, int sort_id) {
|
|
|
|
|
//1、检查科目名称是不是已经在指定学段下存在,存在的不能继续添加
|
|
|
|
|
if (!bm.checkSubjectName(subject_name, stage_id)) {
|
|
|
|
|
renderJson(RetKit.renderFail("该科目名称已存在"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//2、检查科目代码是不是在指定学段下存在,存在的不能继续添加
|
|
|
|
|
if (!bm.checkSubjectCode(subject_code, stage_id)) {
|
|
|
|
|
renderJson(RetKit.renderFail("该科目代码已存在"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//3、可以正确添加
|
|
|
|
|
bm.addSubject(subject_name, subject_code, stage_id, sort_id);
|
|
|
|
|
renderJson(RetKit.renderSuccess("操作成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:删除科目
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsNumericInterface({"subject_id"})
|
|
|
|
|
public void delSubject(int subject_id) {
|
|
|
|
|
bm.delSubject(subject_id);
|
|
|
|
|
renderJson(RetKit.renderSuccess("操作成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:修改科目
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@EmptyInterface({"subject_name", "subject_code"})
|
|
|
|
|
@IsNumericInterface({"sort_id", "stage_id", "subject_id"})
|
|
|
|
|
public void updateSubject(int subject_id, String subject_name, String subject_code, int stage_id, int sort_id) {
|
|
|
|
|
//1、检查科目名称是不是已经在指定学段下存在,存在的不能继续添加
|
|
|
|
|
if (!bm.checkSubjectName(subject_id, subject_name, stage_id)) {
|
|
|
|
|
renderJson(RetKit.renderFail("该科目名称已存在"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//2、检查科目代码是不是在指定学段下存在,存在的不能继续添加
|
|
|
|
|
if (!bm.checkSubjectCode(subject_id, subject_code, stage_id)) {
|
|
|
|
|
renderJson(RetKit.renderFail("该科目代码已存在"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//3、可以正确修改
|
|
|
|
|
bm.updateSubject(subject_id, subject_name, subject_code, stage_id, sort_id);
|
|
|
|
|
renderJson(RetKit.renderSuccess("操作成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:科目列表
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
public void listSubject(int stage_id, int page, int limit) {
|
|
|
|
|
Page<Record> listPage = bm.listSubject(stage_id, page, limit);
|
|
|
|
|
renderJson(RetKit.renderSuccess(listPage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取科目信息
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
public void getSubject(int subject_id) {
|
|
|
|
|
Record record=bm.getSubject(subject_id);
|
|
|
|
|
renderJson(RetKit.renderSuccess(record));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|