parent
4c733a2df6
commit
45a4452f3b
@ -0,0 +1,60 @@
|
||||
package controller.console;
|
||||
|
||||
import cache.DataSet;
|
||||
import database.mongo.Company;
|
||||
import database.mongo.CompanyRepo;
|
||||
import helper.UserService;
|
||||
import message.Message;
|
||||
import message.StateCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/console/company")
|
||||
public class CompanyCtl {
|
||||
@Autowired
|
||||
private DataSet dataSet;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping
|
||||
public Message getCompany(@RequestParam(required = false) String companyId){
|
||||
Message message = new Message();
|
||||
if(companyId == null){
|
||||
return message.setMsg("操作成功")
|
||||
.setCode(StateCode.OK)
|
||||
.setData(null);
|
||||
}
|
||||
Company company = dataSet.getCompanyMap().get(companyId);
|
||||
if(company == null){
|
||||
return message.setMsg(companyId+"没有找到")
|
||||
.setCode(StateCode.NOT_FOUND)
|
||||
.setData(null);
|
||||
}
|
||||
|
||||
return message.setMsg("操作成功")
|
||||
.setCode(StateCode.OK)
|
||||
.setData(null);
|
||||
}
|
||||
|
||||
@PutMapping("/tags")
|
||||
public Message updateTags(@RequestParam String companyId,
|
||||
@RequestParam String tags){
|
||||
Message message = new Message();
|
||||
Company company = dataSet.getCompanyMap().get(companyId);
|
||||
if(company == null){
|
||||
return message.setMsg("公司"+companyId+"没有找到")
|
||||
.setCode(StateCode.NOT_FOUND)
|
||||
.setData(null);
|
||||
}
|
||||
company.setTags(userService.splitTags(tags));
|
||||
dataSet.getCompanyMap().put(companyId,company);
|
||||
return message.setMsg(companyId+"更新成功")
|
||||
.setCode(StateCode.ACCEPTED)
|
||||
.setData(null);
|
||||
}
|
||||
}
|
||||
@ -1,35 +1,49 @@
|
||||
package controller.console;
|
||||
|
||||
|
||||
import cache.DataSet;
|
||||
import database.mssql.OrderRepo;
|
||||
import database.mssql.OrdersEntity;
|
||||
import message.Message;
|
||||
import message.StateCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/console/order")
|
||||
public class OrderCtl {
|
||||
@Autowired
|
||||
private OrderRepo orderRepo;
|
||||
private DataSet dataSet;
|
||||
|
||||
|
||||
@GetMapping
|
||||
public Message getOrders(){
|
||||
Message message = new Message();
|
||||
List<OrdersEntity> orders = (List<OrdersEntity>) orderRepo.findAll();
|
||||
Collection<OrdersEntity> orders = dataSet.getOrderMap().values();
|
||||
return message.setMsg("操作成功")
|
||||
.setCode(StateCode.OK)
|
||||
.setData(orders);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public Message deleteOrder(@RequestParam String outTradeNo){
|
||||
Message message = new Message();
|
||||
ConcurrentHashMap<String,OrdersEntity> orders = dataSet.getOrderMap();
|
||||
OrdersEntity order = orders.get(outTradeNo);
|
||||
if(order == null){
|
||||
return message.setMsg(outTradeNo + "未找到")
|
||||
.setCode(StateCode.NOT_FOUND)
|
||||
.setData(null);
|
||||
}
|
||||
orders.remove(order);
|
||||
return message.setMsg("账单"+outTradeNo+"已删除")
|
||||
.setCode(StateCode.ACCEPTED)
|
||||
.setData(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue