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.

100 lines
3.7 KiB

3 years ago
package com.dsideal.FengHuang.TouPiao.Controller;
import com.dsideal.FengHuang.Interceptor.IsLoginInterface;
import com.dsideal.FengHuang.TouPiao.Model.TouPiaoModel;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
3 years ago
import com.jfinal.kit.Kv;
3 years ago
import com.jfinal.plugin.activerecord.Db;
3 years ago
import com.jfinal.plugin.activerecord.Record;
3 years ago
import com.jfinal.plugin.activerecord.SqlPara;
3 years ago
import java.util.List;
@SuppressWarnings("unchecked")
public class TouPiaoController extends Controller {
TouPiaoModel tm = new TouPiaoModel();
/**
*
*
* 2022-12-11
3 years ago
*
* http://10.10.11.124:9000/FengHuang/TouPiao/getHouXuanRenList?type_id=1
*
* http://10.10.11.124:9000/FengHuang/TouPiao/getHouXuanRenList?type_id=2
3 years ago
*/
@Before({GET.class})
@IsLoginInterface({})
public void getHouXuanRenList(int type_id) {
List<Record> list = tm.getHouXuanRenList(type_id);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
3 years ago
3 years ago
/*
3 years ago
,
3 years ago
http://10.10.11.124:9000/FengHuang/TouPiao/getTouPiaoRenInfo
*/
3 years ago
@Before({GET.class})
@IsLoginInterface({})
public void getTouPiaoRenInfo() {
String toupiaoren_tel = getCookie("toupiaoren_tel");
3 years ago
Record record = tm.getTouPiaoRenInfo(toupiaoren_tel);
renderJson(record);
}
@Before({POST.class})
@IsLoginInterface({})
public void save(String gaoji, String zhongji) {
String toupiaoren_tel = getCookie("toupiaoren_tel");
//检查中级是不是2个高级是不是3个
String[] gaojiArray = gaoji.split(",");
String[] zhongjiArray = zhongji.split(",");
if (gaojiArray.length != 3) {
Kv kv = Kv.create();
kv.set("success", false);
kv.set("message", "本次投票高级只能投3人!");
renderJson(kv);
return;
}
if (zhongjiArray.length != 2) {
Kv kv = Kv.create();
kv.set("success", false);
kv.set("message", "本次投票中级只能投2人!");
renderJson(kv);
return;
}
tm.save(toupiaoren_tel, gaojiArray, zhongjiArray);
Kv kv = Kv.create();
kv.set("success", true);
kv.set("message", "投票成功 !");
renderJson(kv);
3 years ago
}
3 years ago
3 years ago
/*
http://10.10.11.124:9000/FengHuang/TouPiao/TongJi?houxuanren_type_id=1
*/
public void TongJi(int houxuanren_type_id) {
/*
25251015
= 1.0 * / *10
= 1.0 * / *15
30
7
5232.
*/
int PingWeiHuiAllCount = tm.getTouPiaoRenSummary(1);
int QunZhongAllCount = tm.getTouPiaoRenSummary(2);
Kv kv = Kv.by("PingWeiHuiAllCount", PingWeiHuiAllCount).set("QunZhongAllCount", QunZhongAllCount).set("houxuanren_type_id", houxuanren_type_id);
SqlPara sq = Db.getSqlPara("TouPiao.TongJi", kv);
List<Record> list = Db.find(sq);
renderJson(CommonUtil.renderJsonForLayUI(list));
3 years ago
}
3 years ago
}