Commit 96cd9b7c by shj

前端使用Vue框架进行重构

parent eefc3b0e
...@@ -422,25 +422,21 @@ public class BudgetHandler { ...@@ -422,25 +422,21 @@ public class BudgetHandler {
@Autowired @Autowired
private IPropertyDao propertyDao; private IPropertyDao propertyDao;
/** /**
* 修改预算中的国际交流合作费、规则中的国际交流合作费
* *
* @param mode * @param mode
* @param id * @param property
* @param name
* @param price
* @param nums * @param nums
* @param curd * @param curd
* @param request * @param request
* @param response * @param response
*/ */
@RequestMapping("/Modify/Property") @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"); System.out.println("/Modify/Property");
if (mode.equals(0))//修改预算 /*if (mode.equals(0))//修改预算
{ {*/
if (nums < 0) return; if (nums < 0) return;
String sessionID = getSessionID(request.getCookies()); String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID); Budget budget = retrieveBudget(sessionID);
...@@ -449,11 +445,17 @@ public class BudgetHandler { ...@@ -449,11 +445,17 @@ public class BudgetHandler {
Map<Property, Integer> items = null; Map<Property, Integer> items = null;
items = budget.getProperties(); items = budget.getProperties();
Property mod = propertyDao.selectById(id); if(!checkService.checkProperty(property)) return;
if (mod != null) if(curd.equals(0)){
items.put(mod, nums); items.put(property,nums);
}else if(curd.equals(1)){
items.remove(property);
}else{
items.remove(property);
items.put(property,nums);
}
serializeBudget(budget, getFilePath(sessionID)); serializeBudget(budget, getFilePath(sessionID));
} else//修改规则 /*} *//*else//修改规则
{ {
Property item = new Property(); Property item = new Property();
item.setId(id); item.setId(id);
...@@ -469,7 +471,7 @@ public class BudgetHandler { ...@@ -469,7 +471,7 @@ public class BudgetHandler {
{ {
propertyDao.updateProperty(item); propertyDao.updateProperty(item);
} }
} }*/
} }
......
...@@ -150,4 +150,57 @@ public class DetailHandler { ...@@ -150,4 +150,57 @@ public class DetailHandler {
e.printStackTrace(); 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; package service;
import beans.Equipment; import beans.*;
import beans.Indirect;
import beans.Material;
import beans.Travel;
public interface ICheckService { public interface ICheckService {
boolean checkEquipment(Equipment equipment); boolean checkEquipment(Equipment equipment);
boolean checkMaterial(Material material); boolean checkMaterial(Material material);
boolean checkTravel(Travel travel); boolean checkTravel(Travel travel);
boolean checkIndirect(Indirect indirect); boolean checkIndirect(Indirect indirect);
boolean checkProperty(Property property);
} }
package service.impl; package service.impl;
import beans.Equipment; import beans.*;
import beans.Indirect;
import beans.Material;
import beans.Travel;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import service.ICheckService; import service.ICheckService;
@Service @Service
...@@ -29,4 +26,9 @@ public class CheckService implements ICheckService { ...@@ -29,4 +26,9 @@ public class CheckService implements ICheckService {
public boolean checkIndirect(Indirect indirect) { public boolean checkIndirect(Indirect indirect) {
return true; 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