package com.ibeetl.admin.console.web;
|
|
import com.ibeetl.admin.console.model.BannerModel;
|
import com.ibeetl.admin.console.model.ItemModel;
|
import com.ibeetl.admin.console.model.StorageModel;
|
import com.ibeetl.admin.console.service.RedisService;
|
import com.ibeetl.admin.console.service.SettingConsoleService;
|
import com.ibeetl.admin.console.util.PreventManyCommit;
|
import com.ibeetl.admin.console.web.query.SettingMoneyQuery;
|
import com.ibeetl.admin.core.annotation.Function;
|
import com.ibeetl.admin.core.entity.CoreSetMoney;
|
import com.ibeetl.admin.core.web.JsonResult;
|
import org.beetl.sql.core.engine.PageQuery;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import java.io.File;
|
import java.io.IOException;
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* 设置选项
|
*/
|
@Controller
|
@Configuration
|
public class SettingController {
|
|
private static final String MODEL = "/admin/setting";
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
|
@Value("${file.upload.path}")
|
String filePath;
|
|
@Value("${file.address}")
|
String fileAddress;
|
|
@Autowired
|
SettingConsoleService settingConsoleService;
|
|
|
// 金额设置开始
|
@GetMapping(MODEL + "/money/index.do")
|
@Function("setting.money")
|
ModelAndView index(){
|
ModelAndView view = new ModelAndView("/admin/setting/moneySetIndex.html");
|
return view;
|
}
|
|
@RequestMapping(MODEL + "/money/list.json")
|
@Function("setting.money")
|
@ResponseBody
|
JsonResult<PageQuery<CoreSetMoney>> list(SettingMoneyQuery condtion){
|
PageQuery<CoreSetMoney> page = condtion.getPageQuery();
|
settingConsoleService.queryByCondtion(page);
|
return JsonResult.success(page);
|
}
|
|
@PostMapping(MODEL + "/money/updateMoney.json")
|
@Function("setting.money")
|
@ResponseBody
|
@PreventManyCommit(time = 10)
|
JsonResult updateMoney(CoreSetMoney coreSetMoney){
|
settingConsoleService.updateMoney(coreSetMoney);
|
return JsonResult.success(null);
|
}
|
// 金额设置结束
|
|
// 物品分类设置开始
|
// 首页
|
@GetMapping(MODEL + "/item/index.do")
|
@Function("setting.item")
|
ModelAndView itemIndex(){
|
ModelAndView view = new ModelAndView("/admin/setting/itemSetting/index.html");
|
return view;
|
}
|
// 编辑页
|
@GetMapping(MODEL + "/item/edit.do")
|
@Function("setting.item")
|
ModelAndView editIndex(String id, @RequestParam(required = false) String parentId){
|
ModelAndView view = new ModelAndView("/admin/setting/itemSetting/edit.html");
|
view.addObject("id", id);
|
view.addObject("parentId", parentId);
|
return view;
|
}
|
// 添加页
|
@GetMapping(MODEL + "/item/add.do")
|
@Function("setting.item")
|
ModelAndView addIndex(){
|
ModelAndView view = new ModelAndView("/admin/setting/itemSetting/add.html");
|
return view;
|
}
|
// 子类页
|
@GetMapping(MODEL + "/item/child.do")
|
@Function("setting.item")
|
ModelAndView childIndex(String parentId){
|
ModelAndView view = new ModelAndView("/admin/setting/itemSetting/child.html");
|
view.addObject("parentId", parentId);
|
return view;
|
}
|
|
/**
|
* 查询
|
* @param item
|
* @return
|
*/
|
@PostMapping(MODEL + "/item/querIteml.json")
|
@Function("setting.item")
|
@ResponseBody
|
Map<String, Object> querIteml(ItemModel item){
|
updateItemForRedis();
|
return settingConsoleService.querIteml(item);
|
}
|
|
/**
|
* 插入
|
* @param item
|
* @return
|
*/
|
@PostMapping(MODEL + "/item/insertItem.json")
|
@Function("setting.item")
|
@PreventManyCommit(time = 10)
|
@ResponseBody
|
int insertItem(ItemModel item){
|
return settingConsoleService.insertItem(item);
|
}
|
|
/**
|
* 删除
|
* @param item
|
* @return
|
*/
|
@PostMapping(MODEL + "/item/delItem.json")
|
@Function("setting.item")
|
@PreventManyCommit(time = 10)
|
@ResponseBody
|
int delItem(ItemModel item){
|
return settingConsoleService.delItem(item);
|
}
|
|
/**
|
* 更新
|
* @param item
|
* @return
|
*/
|
@PostMapping(MODEL + "/item/updateItem.json")
|
@Function("setting.item")
|
@ResponseBody
|
@PreventManyCommit(time = 10)
|
int updateItem(ItemModel item){
|
return settingConsoleService.updateItem(item);
|
}
|
|
/**
|
* 更新redis里面的缓存
|
*/
|
void updateItemForRedis(){
|
settingConsoleService.updateItemForRedis();
|
}
|
// 物品设置结束
|
|
/**
|
文件上传
|
*/
|
@PostMapping(MODEL + "/item/uploadAvatar.json")
|
@Function("setting.item")
|
@PreventManyCommit(time = 10)
|
@ResponseBody
|
Map<String, Object> uploadAvatar(@PathVariable MultipartFile file){
|
if(file.isEmpty()){
|
return null;
|
}
|
//文件名
|
String fileName = file.getOriginalFilename();
|
//后缀名
|
String suffixName = fileName.substring(fileName.lastIndexOf("."));
|
//图片名
|
//String path = "/resource/static/img"; //文件存储位置 我放在了我的项目下
|
fileName=UUID.randomUUID()+suffixName;
|
File dest = new File(filePath+fileName);
|
//File dest = new File(path+"\\"+fileName);
|
if (!dest.getParentFile().exists()) {
|
dest.getParentFile().mkdirs();
|
}
|
try {
|
file.transferTo(dest);
|
String url=fileAddress+fileName;
|
//String url=address+"\\"+fileName;
|
Map map=new HashMap();
|
map.put("path",url);
|
return map;
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
// --------仓库管理------------------------------------------------
|
|
@GetMapping(MODEL + "/storage/index.do")
|
@Function("storage")
|
ModelAndView storageIndex(){
|
return new ModelAndView("/admin/setting/storage/index.html");
|
}
|
@GetMapping(MODEL + "/storage/add.do")
|
@Function("storage")
|
ModelAndView addx(){
|
return new ModelAndView("/admin/setting/storage/add.html");
|
}
|
/**
|
* 查询仓库列表
|
* @param storageModel
|
* @return
|
*/
|
@PostMapping(MODEL + "/storage/queryStorageList.json")
|
@Function("storage")
|
@ResponseBody
|
Map<String, Object> queryStorageList(StorageModel storageModel){
|
return settingConsoleService.queryStorageList(storageModel);
|
}
|
|
/**
|
* 添加仓库
|
* @param storageModel
|
* @return
|
*/
|
@PostMapping(MODEL + "/storage/addStorage.json")
|
@Function("storage")
|
@ResponseBody
|
int addStorage(StorageModel storageModel){
|
return settingConsoleService.addStorage(storageModel);
|
}
|
|
/**
|
* 更新仓库
|
* @param storageModel
|
* @return
|
*/
|
@PostMapping(MODEL + "/storage/updateStorage.json")
|
@Function("storage")
|
@ResponseBody
|
int updateStorage(StorageModel storageModel){
|
return settingConsoleService.updateStorage(storageModel);
|
}
|
|
/**
|
* 删除仓库
|
* @param storageModel
|
* @return
|
*/
|
@PostMapping(MODEL + "/storage/delStorage.json")
|
@Function("storage")
|
@ResponseBody
|
int delStorage(StorageModel storageModel){
|
return settingConsoleService.delStorage(storageModel);
|
}
|
|
|
// --banner管理----------------------------------------------
|
|
@GetMapping(MODEL + "/banner/index.do")
|
@Function("banner")
|
ModelAndView bannerIndex(){
|
return new ModelAndView("/admin/setting/banner/index.html");
|
}
|
@GetMapping(MODEL + "/banner/add.do")
|
@Function("banner")
|
ModelAndView bannerAdd(){
|
return new ModelAndView("/admin/setting/banner/add.html");
|
}
|
@GetMapping(MODEL + "/banner/edit.do")
|
@Function("banner")
|
ModelAndView bannerEdit(BannerModel bannerModel){
|
System.out.println(bannerModel.toString());
|
ModelAndView view = new ModelAndView("/admin/setting/banner/edit.html");
|
if(null!=bannerModel&&null!=bannerModel.getPicPath()){
|
bannerModel.setPicPath("/");
|
view.addObject("banner", bannerModel);
|
|
}else{
|
view.addObject("banner", bannerModel);
|
|
}
|
return view;
|
}
|
|
/**
|
* 查询
|
* @param bannerModel
|
* @return
|
*/
|
@PostMapping(MODEL + "/banner/queryBannerList.json")
|
@Function("banner")
|
@ResponseBody
|
Map<String, Object> queryBannerList(BannerModel bannerModel){
|
return settingConsoleService.queryBannerList(bannerModel);
|
}
|
|
/**
|
* 添加
|
* @param bannerModel
|
* @return
|
*/
|
@PostMapping(MODEL + "/banner/insertBanner.json")
|
@Function("banner")
|
@ResponseBody
|
JsonResult insertBanner(BannerModel bannerModel){
|
return settingConsoleService.insertBanner(bannerModel);
|
|
}
|
|
/**
|
* 更新
|
* @param bannerModel
|
* @return
|
*/
|
int updateBanner(BannerModel bannerModel){
|
return settingConsoleService.updateBanner(bannerModel);
|
}
|
|
/**
|
* 删除
|
* @param id
|
* @return
|
*/
|
@PostMapping(MODEL + "/banner/delBanner.json")
|
@Function("banner")
|
@ResponseBody
|
int delBanner(String id){
|
return settingConsoleService.delBanner(id);
|
}
|
|
}
|