Commit 96cd9b7c by shj

前端使用Vue框架进行重构

parent eefc3b0e
......@@ -422,25 +422,21 @@ public class BudgetHandler {
@Autowired
private IPropertyDao propertyDao;
/**
* 修改预算中的国际交流合作费、规则中的国际交流合作费
*
* @param mode
* @param id
* @param name
* @param price
* @param property
* @param nums
* @param curd
* @param request
* @param response
*/
@RequestMapping("/Modify/Property")
public void modifyProperty(Integer mode, Integer id, String name, Double price, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) {
public void modifyProperty(Integer mode, Property property, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) {
System.out.println("/Modify/Property");
if (mode.equals(0))//修改预算
{
/*if (mode.equals(0))//修改预算
{*/
if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
......@@ -449,11 +445,17 @@ public class BudgetHandler {
Map<Property, Integer> items = null;
items = budget.getProperties();
Property mod = propertyDao.selectById(id);
if (mod != null)
items.put(mod, nums);
if(!checkService.checkProperty(property)) return;
if(curd.equals(0)){
items.put(property,nums);
}else if(curd.equals(1)){
items.remove(property);
}else{
items.remove(property);
items.put(property,nums);
}
serializeBudget(budget, getFilePath(sessionID));
} else//修改规则
/*} *//*else//修改规则
{
Property item = new Property();
item.setId(id);
......@@ -469,7 +471,7 @@ public class BudgetHandler {
{
propertyDao.updateProperty(item);
}
}
}*/
}
......
......@@ -150,4 +150,57 @@ public class DetailHandler {
e.printStackTrace();
}
}
@RequestMapping("/Power")
public void powerDetail(HttpServletRequest request,HttpServletResponse response){
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
JSONObject object=new JSONObject();
String sessionID = BudgetHandler.getSessionID(request.getCookies());
Budget budget = BudgetHandler.retrieveBudget(sessionID);
Map<Power, Integer> powers = budget.getPowers();
List<JSONObject> list=new LinkedList<>();
for (Power item : powers.keySet()) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",powers.get(item));
list.add(obj);
}
object.put("powers",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/Property")
public void propertyDetail(HttpServletRequest request,HttpServletResponse response){
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
JSONObject object=new JSONObject();
String sessionID = BudgetHandler.getSessionID(request.getCookies());
Budget budget = BudgetHandler.retrieveBudget(sessionID);
Map<Property, Integer> propertyIntegerMap = budget.getProperties();
List<JSONObject> list=new LinkedList<>();
for (Property item : propertyIntegerMap.keySet()) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",propertyIntegerMap.get(item));
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
}
package service;
import beans.Equipment;
import beans.Indirect;
import beans.Material;
import beans.Travel;
import beans.*;
public interface ICheckService {
boolean checkEquipment(Equipment equipment);
boolean checkMaterial(Material material);
boolean checkTravel(Travel travel);
boolean checkIndirect(Indirect indirect);
boolean checkProperty(Property property);
}
package service.impl;
import beans.Equipment;
import beans.Indirect;
import beans.Material;
import beans.Travel;
import beans.*;
import org.springframework.stereotype.Service;
import service.ICheckService;
@Service
......@@ -29,4 +26,9 @@ public class CheckService implements ICheckService {
public boolean checkIndirect(Indirect indirect) {
return true;
}
@Override
public boolean checkProperty(Property property) {
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment