diff --git a/pom.xml b/pom.xml index 036d990..5743e63 100644 --- a/pom.xml +++ b/pom.xml @@ -196,6 +196,12 @@ system ${basedir}/src/main/webapp/WEB-INF/lib/fastdfs-client-java-1.25.jar + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + ifishSystem @@ -242,6 +248,7 @@ **/*.xml **/*.properties + **/*.conf diff --git a/src/main/java/com/ifish/action/AdInfoAction.java b/src/main/java/com/ifish/action/AdInfoAction.java index afb0719..e56297d 100644 --- a/src/main/java/com/ifish/action/AdInfoAction.java +++ b/src/main/java/com/ifish/action/AdInfoAction.java @@ -18,6 +18,7 @@ import com.ifish.service.AdInfoService; import com.ifish.util.IfishFileDirectory; import com.ifish.util.IfishFileUtils; import com.ifish.util.ResultUtil; +import com.ifishNew.help.FastDFSClientI; /** * 广告信息 @@ -30,7 +31,6 @@ public class AdInfoAction { @Autowired private AdInfoService adInfoService; - /** * 广告信息页面 * @@ -91,7 +91,7 @@ public class AdInfoAction { } adInfo.setAdImage(newImgName); //新增广告 - return adInfoService.addAdInfo(adInfo); + return adInfoService.addAdInfo(adInfo); } /** diff --git a/src/main/java/com/ifish/action/IfishGoodsAction.java b/src/main/java/com/ifish/action/IfishGoodsAction.java index ecd5496..05bbc92 100644 --- a/src/main/java/com/ifish/action/IfishGoodsAction.java +++ b/src/main/java/com/ifish/action/IfishGoodsAction.java @@ -23,6 +23,7 @@ import com.ifish.service.IfishShopService; import com.ifish.util.IfishFileDirectory; import com.ifish.util.IfishFileUtils; import com.ifish.util.ResultUtil; +import com.ifishNew.help.FastDFSClientI; /** * 商品管理action diff --git a/src/main/java/com/ifish/action/InformationAction.java b/src/main/java/com/ifish/action/InformationAction.java index e613d9b..a2662da 100644 --- a/src/main/java/com/ifish/action/InformationAction.java +++ b/src/main/java/com/ifish/action/InformationAction.java @@ -21,156 +21,165 @@ import com.ifish.service.InformationService; import com.ifish.util.IfishFileDirectory; import com.ifish.util.IfishFileUtils; import com.ifish.util.ResultUtil; +import com.ifishNew.help.FastDFSClientI; /** * 资讯信息 + * * @author Administrator * */ @Controller public class InformationAction { - - @Autowired - private InformationService infoService; - - /** - * 资讯信息页面 - * @return - */ - @RequestMapping(value="/information.do") - public ModelAndView information(Model model){ - model.addAttribute("ueditorMap", infoService.getUeditors()); - return new ModelAndView("information/information"); - } - - /** - * 资讯信息分页数据 - * @param pageData - * @param information - * @return - */ - @RequestMapping(value="/informationData.do") - @ResponseBody - public PageDataDto getInformationByPage(PageDataDto pageData,Information information){ - pageData.pageData(infoService.getInformationByPage(pageData, information)); - return pageData; - } - - /** - * app展示 - * @param infoId - * @param appShow - * @return - */ - @RequestMapping("/informationShowUpdate.do") - @ResponseBody - public JsonResult informationShowUpdate(@RequestParam Integer infoId,@RequestParam boolean appShow) { - return infoService.informationShowUpdate(infoId,appShow); - } - - /** - * 新增资讯 - * @param information - * @param fileUpload - * @return - */ - @RequestMapping(value="/addInformation.do") - @ResponseBody - public JsonResult addInformation(Information information,MultipartFile fileUpload){ - //上传文件不能为空 - if(fileUpload==null){ - throw new IfishException(SysUserEnum.warn114); - } - //上传图片 - String newImgName = null; - try { - //上传文件 - newImgName = String.valueOf(System.currentTimeMillis())+".png"; - IfishFileUtils.uploadFile(IfishFileDirectory.path_img_information,newImgName,fileUpload); - } catch (IfishException e){ - throw e; - } catch (Exception e) { - throw new IfishException(SysUserEnum.warn113); - } - information.setImage(newImgName); - //新增资讯 - return infoService.addInformation(information); - } - - /** - * 修改资讯信息 - * @param information - * @param fileUpload - * @return - */ - @RequestMapping(value="/updateInformation.do") - @ResponseBody - public JsonResult updateInformation(Information information,MultipartFile fileUpload){ - String newImgName = null; - //String oldImgName = information.getImage(); - //上传新资讯图 - if(fileUpload!=null){ - try { - //上传文件 - newImgName = String.valueOf(System.currentTimeMillis())+".png"; - IfishFileUtils.uploadFile(IfishFileDirectory.path_img_information,newImgName,fileUpload); - } catch (IfishException e){ - throw e; - } catch (Exception e) { - throw new IfishException(SysUserEnum.warn113); - } - information.setImage(newImgName); - } - JsonResult jsonResult = infoService.updateInformation(information); - //删除老资讯图 - /*if(newImgName!=null && StringUtils.isNotBlank(oldImgName)){ + + @Autowired + private InformationService infoService; + + /** + * 资讯信息页面 + * + * @return + */ + @RequestMapping(value = "/information.do") + public ModelAndView information(Model model) { + model.addAttribute("ueditorMap", infoService.getUeditors()); + return new ModelAndView("information/information"); + } + + /** + * 资讯信息分页数据 + * + * @param pageData + * @param information + * @return + */ + @RequestMapping(value = "/informationData.do") + @ResponseBody + public PageDataDto getInformationByPage(PageDataDto pageData, Information information) { + pageData.pageData(infoService.getInformationByPage(pageData, information)); + return pageData; + } + + /** + * app展示 + * + * @param infoId + * @param appShow + * @return + */ + @RequestMapping("/informationShowUpdate.do") + @ResponseBody + public JsonResult informationShowUpdate(@RequestParam Integer infoId, @RequestParam boolean appShow) { + return infoService.informationShowUpdate(infoId, appShow); + } + + /** + * 新增资讯 + * + * @param information + * @param fileUpload + * @return + */ + @RequestMapping(value = "/addInformation.do") + @ResponseBody + public JsonResult addInformation(Information information, MultipartFile fileUpload) { + //上传文件不能为空 + if (fileUpload == null) { + throw new IfishException(SysUserEnum.warn114); + } + //上传图片 + String newImgName = null; + try { + //上传文件 + newImgName = String.valueOf(System.currentTimeMillis()) + ".png"; + IfishFileUtils.uploadFile(IfishFileDirectory.path_img_information, newImgName, fileUpload); + } catch (IfishException e) { + throw e; + } catch (Exception e) { + throw new IfishException(SysUserEnum.warn113); + } + information.setImage(newImgName); + //新增资讯 + return infoService.addInformation(information); + } + + /** + * 修改资讯信息 + * + * @param information + * @param fileUpload + * @return + */ + @RequestMapping(value = "/updateInformation.do") + @ResponseBody + public JsonResult updateInformation(Information information, MultipartFile fileUpload) { + String newImgName = null; + //String oldImgName = information.getImage(); + //上传新资讯图 + if (fileUpload != null) { + try { + //上传文件 + newImgName = String.valueOf(System.currentTimeMillis()) + ".png"; + IfishFileUtils.uploadFile(IfishFileDirectory.path_img_information, newImgName, fileUpload); + } catch (IfishException e) { + throw e; + } catch (Exception e) { + throw new IfishException(SysUserEnum.warn113); + } + information.setImage(newImgName); + } + JsonResult jsonResult = infoService.updateInformation(information); + //删除老资讯图 + /*if(newImgName!=null && StringUtils.isNotBlank(oldImgName)){ IfishFileUtils.deleteFile(IfishFileDirectory.path_img_information, oldImgName); }*/ - return jsonResult; - } - - /** - * 删除资讯 - * @param infoId - * @return - */ - @RequestMapping(value="/deleteInformation.do") - @ResponseBody - public JsonResult deleteInformation(Integer infoId){ - String image = infoService.deleteInformation(infoId); - //删除资讯图 - if(StringUtils.isNotBlank(image)){ - IfishFileUtils.deleteFile(IfishFileDirectory.path_img_information, image); - } - return ResultUtil.success(); - } - - /** - * 根据ID查询资讯信息 - * @param infoId - * @return - */ - @RequestMapping(value="/getInformationById.do") - @ResponseBody - public Information getInformationById(Integer infoId){ - Information info = infoService.getInformationById(infoId); - if(info.getUeditorId()!=null){ - info.setSource(InformationSourceEnum.ueditor.getKey()); - } - else{ - info.setSource(InformationSourceEnum.other.getKey()); - } - return info; - } - - /** - * 根据ID查找编辑器信息 - * @param ueditorId - * @return - */ - @RequestMapping("/information/getUeditorById.do") - @ResponseBody - public Ueditor editUeditor(Integer ueditorId) { - return infoService.getUeditorById(ueditorId); - } + return jsonResult; + } + + /** + * 删除资讯 + * + * @param infoId + * @return + */ + @RequestMapping(value = "/deleteInformation.do") + @ResponseBody + public JsonResult deleteInformation(Integer infoId) { + String image = infoService.deleteInformation(infoId); + //删除资讯图 + if (StringUtils.isNotBlank(image)) { + IfishFileUtils.deleteFile(IfishFileDirectory.path_img_information, image); + } + return ResultUtil.success(); + } + + /** + * 根据ID查询资讯信息 + * + * @param infoId + * @return + */ + @RequestMapping(value = "/getInformationById.do") + @ResponseBody + public Information getInformationById(Integer infoId) { + Information info = infoService.getInformationById(infoId); + if (info.getUeditorId() != null) { + info.setSource(InformationSourceEnum.ueditor.getKey()); + } else { + info.setSource(InformationSourceEnum.other.getKey()); + } + return info; + } + + /** + * 根据ID查找编辑器信息 + * + * @param ueditorId + * @return + */ + @RequestMapping("/information/getUeditorById.do") + @ResponseBody + public Ueditor editUeditor(Integer ueditorId) { + return infoService.getUeditorById(ueditorId); + } } diff --git a/src/main/java/com/ifish/action/PublicAction.java b/src/main/java/com/ifish/action/PublicAction.java index b39a179..1e65ff5 100644 --- a/src/main/java/com/ifish/action/PublicAction.java +++ b/src/main/java/com/ifish/action/PublicAction.java @@ -25,199 +25,217 @@ import com.alibaba.fastjson.JSONObject; import com.ifish.entity.Menu; import com.ifish.entity.Role; import com.ifish.entity.SecurityUser; +import com.ifish.enums.AdTypeEnum; import com.ifish.enums.RoleEnum; import com.ifish.enums.SysUserEnum; +import com.ifish.exception.IfishException; import com.ifish.menu.IfishMenu; import com.ifish.service.AdminService; import com.ifish.service.PublicService; import com.ifish.ueditor.ActionEnter; +import com.ifish.util.IfishFileDirectory; +import com.ifish.util.IfishFileUtils; +import com.ifish.util.IfishUtil; import com.ifish.util.getRemoteAddress; +import com.ifishNew.bean.CommodityInfoBean; +import com.ifishNew.help.FastDFSClientI; +import com.ifishNew.mapper.Tbl_Commodity_Info_Mapper; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.multipart.MultipartFile; -/** - * @ClassName: PublicAction - * @Description: 公共页面 - * @author ggw +/** + * @ClassName: PublicAction + * @Description: 公共页面 + * @author ggw */ - @Controller("publicAction") @RequestMapping("/public") public class PublicAction { - - @Autowired - private PublicService publicService; - - @Autowired - private AdminService adminService; - - private static Logger log = LoggerFactory.getLogger(PublicAction.class); - - /** - * 登陆页面 - * @return - */ - @RequestMapping("/login.do") - public ModelAndView login(String status) { - return new ModelAndView("roleAll/login","status",status); - } - - /** - * 文本编辑器配置 - * @param request - * @param response - */ - @RequestMapping("/config.do") - public void config(HttpServletRequest request,HttpServletResponse response){ - try { - request.setCharacterEncoding( "utf-8" ); - response.setHeader("Content-Type" , "text/html"); - response.setContentType("application/json"); - String rootPath = request.getSession().getServletContext().getRealPath( "/" ); - String exec = new ActionEnter( request, rootPath ).exec(); - PrintWriter writer = response.getWriter(); - writer.write(exec); - writer.flush(); - writer.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 主页 - * @return - */ - @RequestMapping("/index.do") - public ModelAndView index() { - String role = null; - String userName = null; - try { - //登录用户 - UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - userName = userDetails.getUsername(); - //根据登录用户角色类型跳转 - Collection extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities(); - for(GrantedAuthority grantedAuthority : authorities) { - role = grantedAuthority.getAuthority(); - } - //菜单初始化 - if(role!=null && userName!=null){ - Role curRole = this.adminService.get(role); - List menuList = new ArrayList(); - menuList.addAll(curRole.getMenuList()); - //默认选择菜单 - IfishMenu.initChioceMenu(userName, null); - //用户菜单 - if(userName!=null){ - IfishMenu.initMenu(userName, menuList); - } - } - //重定向 - String redirect = ""; - if(role.equals(RoleEnum.admin.getKey())){ - redirect = "page/admin/home.do"; - } - else if(role.equals(RoleEnum.vender.getKey())){ - redirect = "page/vender/tmpDeviceList.do"; - } - else if(role.equals(RoleEnum.user.getKey())){ - redirect = "page/user/home.do"; - } - else if(role.equals(RoleEnum.factory.getKey())){ - redirect = "page/factory/tmpDeviceList.do"; - } - return new ModelAndView("redirect:/"+redirect); - } catch (Exception e) { - e.printStackTrace(); - log.error("index page:role:{},error message:{}",role,e.toString()); - } - return new ModelAndView("redirect:login.do"); - } - - /** - * 修改密码页面 - * @return - */ - @RequestMapping("/changePwd.do") - public ModelAndView changePwd(String status) { - return new ModelAndView("roleAll/changePwd","status",status); - } - /** - * 修改密码 - * @return - */ - @RequestMapping("/savePwd.do") - public ModelAndView savePwd(String username,String oldPassword,String newPassword) { - try { - SecurityUser securityUser = publicService.updateSecurityPwd(username, oldPassword, newPassword); - if(securityUser!=null){ - return new ModelAndView("redirect:/page/public/changePwd.do","status",SysUserEnum.success100.getKey()); - } - return new ModelAndView("redirect:/page/public/changePwd.do","status",SysUserEnum.warn105.getKey()); - } catch (Exception e) { - log.error("update password:userName:{},error message:{}",username,e.toString()); - } - return new ModelAndView("redirect:/page/public/changePwd.do","status",SysUserEnum.failed101.getKey()); - } - - /** - * 用户注册 - * @param securityUser - * @return - */ - @RequestMapping("/signup.do") - public ModelAndView signup(SecurityUser securityUser) { - try { - String code = publicService.createSysUser(securityUser); - return new ModelAndView("redirect:/page/public/login.do","status",code); - } catch (Exception e) { - log.error("securityUser register:userName:{},error message:{}",securityUser.getUsername(),e.toString()); - } - return new ModelAndView("redirect:/page/public/login.do","status",SysUserEnum.failed101.getKey()); - } - - /***********************************************测试工具接口***************************************************/ - /** - * 获取厂家列表 - * @return - */ - @RequestMapping("/getVenderList.do") - @ResponseBody - public Object getVenderList(HttpServletResponse response,String factoryCode) { - response.setHeader("Access-Control-Allow-Origin", "*"); - Map map = new HashMap(); - try { - map = publicService.getVenderList(factoryCode); - } catch (Exception e) { - log.error("get venderList information to test tool:error message:{}",e.toString()); - } - return map; - } - /** - * 保存设备mac - * @param data - * @param subStr - * @return - */ - @RequestMapping("/saveMacAddress.do") - @ResponseBody - public Object saveMacAddress(Map data,String subStr,HttpServletRequest request,HttpServletResponse response) { - response.setHeader("Access-Control-Allow-Origin", "*"); - try { - String ip = getRemoteAddress.getIp(request); - JSONObject json = JSONObject.parseObject(subStr); - String brandCode = json.getString("brandCode"); - String factoryCode = json.getString("factoryCode"); - String isBlacklist = json.getString("isBlacklist"); - String macs = json.getString("mac"); - String hardType = json.getString("hardType"); - String[] mac = macs.equals("")?null:macs.split(","); - String[] hardTypes = hardType.equals("")?null:hardType.split(","); - Map map = this.publicService.saveDevices(factoryCode,isBlacklist,brandCode,ip, mac, hardTypes); - JSONObject returnJson = new JSONObject(map); - return returnJson.toString(); - } catch (Exception e) { - log.error("save macAddress from test tool:error message:{}",e.toString()); - } - return null; - } + + @Autowired + private PublicService publicService; + + @Autowired + private AdminService adminService; + + private static Logger log = LoggerFactory.getLogger(PublicAction.class); + + /** + * 登陆页面 + * + * @return + */ + @RequestMapping("/login.do") + public ModelAndView login(String status) { + return new ModelAndView("roleAll/login", "status", status); + } + + /** + * 文本编辑器配置 + * + * @param request + * @param response + */ + @RequestMapping("/config.do") + public void config(HttpServletRequest request, HttpServletResponse response) { + try { + request.setCharacterEncoding("utf-8"); + response.setHeader("Content-Type", "text/html"); + response.setContentType("application/json"); + String rootPath = request.getSession().getServletContext().getRealPath("/"); + String exec = new ActionEnter(request, rootPath).exec(); + PrintWriter writer = response.getWriter(); + writer.write(exec); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 主页 + * + * @return + */ + @RequestMapping("/index.do") + public ModelAndView index() { + String role = null; + String userName = null; + try { + //登录用户 + UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); + userName = userDetails.getUsername(); + //根据登录用户角色类型跳转 + Collection extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities(); + for (GrantedAuthority grantedAuthority : authorities) { + role = grantedAuthority.getAuthority(); + } + //菜单初始化 + if (role != null && userName != null) { + Role curRole = this.adminService.get(role); + List menuList = new ArrayList(); + menuList.addAll(curRole.getMenuList()); + //默认选择菜单 + IfishMenu.initChioceMenu(userName, null); + //用户菜单 + if (userName != null) { + IfishMenu.initMenu(userName, menuList); + } + } + //重定向 + String redirect = ""; + if (role.equals(RoleEnum.admin.getKey())) { + redirect = "page/admin/home.do"; + } else if (role.equals(RoleEnum.vender.getKey())) { + redirect = "page/vender/tmpDeviceList.do"; + } else if (role.equals(RoleEnum.user.getKey())) { + redirect = "page/user/home.do"; + } else if (role.equals(RoleEnum.factory.getKey())) { + redirect = "page/factory/tmpDeviceList.do"; + } + return new ModelAndView("redirect:/" + redirect); + } catch (Exception e) { + e.printStackTrace(); + log.error("index page:role:{},error message:{}", role, e.toString()); + } + return new ModelAndView("redirect:login.do"); + } + + /** + * 修改密码页面 + * + * @return + */ + @RequestMapping("/changePwd.do") + public ModelAndView changePwd(String status) { + return new ModelAndView("roleAll/changePwd", "status", status); + } + + /** + * 修改密码 + * + * @return + */ + @RequestMapping("/savePwd.do") + public ModelAndView savePwd(String username, String oldPassword, String newPassword) { + try { + SecurityUser securityUser = publicService.updateSecurityPwd(username, oldPassword, newPassword); + if (securityUser != null) { + return new ModelAndView("redirect:/page/public/changePwd.do", "status", SysUserEnum.success100.getKey()); + } + return new ModelAndView("redirect:/page/public/changePwd.do", "status", SysUserEnum.warn105.getKey()); + } catch (Exception e) { + log.error("update password:userName:{},error message:{}", username, e.toString()); + } + return new ModelAndView("redirect:/page/public/changePwd.do", "status", SysUserEnum.failed101.getKey()); + } + + /** + * 用户注册 + * + * @param securityUser + * @return + */ + @RequestMapping("/signup.do") + public ModelAndView signup(SecurityUser securityUser) { + try { + String code = publicService.createSysUser(securityUser); + return new ModelAndView("redirect:/page/public/login.do", "status", code); + } catch (Exception e) { + log.error("securityUser register:userName:{},error message:{}", securityUser.getUsername(), e.toString()); + } + return new ModelAndView("redirect:/page/public/login.do", "status", SysUserEnum.failed101.getKey()); + } + + /** + * *********************************************测试工具接口************************************************** + */ + /** + * 获取厂家列表 + * + * @return + */ + @RequestMapping("/getVenderList.do") + @ResponseBody + public Object getVenderList(HttpServletResponse response, String factoryCode) { + response.setHeader("Access-Control-Allow-Origin", "*"); + Map map = new HashMap(); + try { + map = publicService.getVenderList(factoryCode); + } catch (Exception e) { + log.error("get venderList information to test tool:error message:{}", e.toString()); + } + return map; + } + + /** + * 保存设备mac + * + * @param data + * @param subStr + * @return + */ + @RequestMapping("/saveMacAddress.do") + @ResponseBody + public Object saveMacAddress(Map data, String subStr, HttpServletRequest request, HttpServletResponse response) { + response.setHeader("Access-Control-Allow-Origin", "*"); + try { + String ip = getRemoteAddress.getIp(request); + JSONObject json = JSONObject.parseObject(subStr); + String brandCode = json.getString("brandCode"); + String factoryCode = json.getString("factoryCode"); + String isBlacklist = json.getString("isBlacklist"); + String macs = json.getString("mac"); + String hardType = json.getString("hardType"); + String[] mac = macs.equals("") ? null : macs.split(","); + String[] hardTypes = hardType.equals("") ? null : hardType.split(","); + Map map = this.publicService.saveDevices(factoryCode, isBlacklist, brandCode, ip, mac, hardTypes); + JSONObject returnJson = new JSONObject(map); + return returnJson.toString(); + } catch (Exception e) { + log.error("save macAddress from test tool:error message:{}", e.toString()); + } + return null; + } } diff --git a/src/main/java/com/ifish/action/ShopsInfoAction.java b/src/main/java/com/ifish/action/ShopsInfoAction.java index 62d98f8..f676d36 100644 --- a/src/main/java/com/ifish/action/ShopsInfoAction.java +++ b/src/main/java/com/ifish/action/ShopsInfoAction.java @@ -21,6 +21,7 @@ import com.ifish.util.IfishFileUtils; import com.ifish.util.ResultUtil; import com.ifishNew.bean.CommodityInfoBean; import com.ifishNew.help.CommodityInfoHelperI; +import com.ifishNew.help.FastDFSClientI; /** * 商家信息controller @@ -36,6 +37,9 @@ public class ShopsInfoAction { @Autowired private CommodityInfoHelperI commodityInfoHelperI; + + @Autowired + private FastDFSClientI fastDFSClientI; /** * 已审核商家信息页面 @@ -130,7 +134,7 @@ public class ShopsInfoAction { try { //上传文件 newImgName = String.valueOf(System.currentTimeMillis()) + ".png"; - IfishFileUtils.uploadFile(IfishFileDirectory.path_picture4 + "/" + userId, newImgName, fileUpload); + newImgName = fastDFSClientI.uploadFile(IfishFileDirectory.path_picture4 + "/" + userId, newImgName, fileUpload); } catch (IfishException e) { throw e; } catch (Exception e) { @@ -265,8 +269,8 @@ public class ShopsInfoAction { */ @RequestMapping("/shopsInfo/updategoodsInfo.do") @ResponseBody - public JsonResult updateGoodsInfoJsonResult(CommodityInfoBean commodityInfoBean,boolean appShow) { - return commodityInfoHelperI.updateCommodityInfo(commodityInfoBean,appShow); + public JsonResult updateGoodsInfoJsonResult(CommodityInfoBean commodityInfoBean, boolean appShow) { + return commodityInfoHelperI.updateCommodityInfo(commodityInfoBean, appShow); } /** diff --git a/src/main/java/com/ifish/serviceImpl/AdminServiceImpl.java b/src/main/java/com/ifish/serviceImpl/AdminServiceImpl.java index b2de89b..e56e16c 100644 --- a/src/main/java/com/ifish/serviceImpl/AdminServiceImpl.java +++ b/src/main/java/com/ifish/serviceImpl/AdminServiceImpl.java @@ -2602,6 +2602,9 @@ public class AdminServiceImpl implements AdminService { if (StringUtils.isNotBlank(isTax)) { isTax = BooleanEnum.NO.getKey(); factoryList.setIsTax(isTax); + } else { + isTax = BooleanEnum.NO.getKey(); + factoryList.setIsTax(isTax); } //支付金额为null时 if (payMoney == null) { diff --git a/src/main/java/com/ifish/util/IfishFileUtils.java b/src/main/java/com/ifish/util/IfishFileUtils.java index ab8ff64..44dc784 100644 --- a/src/main/java/com/ifish/util/IfishFileUtils.java +++ b/src/main/java/com/ifish/util/IfishFileUtils.java @@ -13,64 +13,70 @@ import com.ifish.exception.IfishException; /** * 文件处理工具类 + * * @author Administrator * */ public class IfishFileUtils { - - /** - * 上传文件并校验尺寸 - * @param path - * @param fileName - * @param multipartFile - * @param width - * @param height - * @throws IllegalStateException - * @throws IOException - */ - public static void uploadFile(String path,String fileName,MultipartFile multipartFile,int width,int height) throws IllegalStateException, IOException{ - //检验图片尺寸 - BufferedImage sourceImg =ImageIO.read(multipartFile.getInputStream()); + + /** + * 上传文件并校验尺寸 + * + * @param path + * @param fileName + * @param multipartFile + * @param width + * @param height + * @throws IllegalStateException + * @throws IOException + */ + public static void uploadFile(String path, String fileName, MultipartFile multipartFile, int width, int height) throws IllegalStateException, IOException { + //检验图片尺寸 + BufferedImage sourceImg = ImageIO.read(multipartFile.getInputStream()); int imgWidth = sourceImg.getWidth(); int imgHeight = sourceImg.getHeight(); - if(width!=imgWidth || height!=imgHeight){ - throw new IfishException(SysUserEnum.warn115.getKey(),SysUserEnum.warn115.getValue()+"("+width+"x"+height+")"); + if (width != imgWidth || height != imgHeight) { + throw new IfishException(SysUserEnum.warn115.getKey(), SysUserEnum.warn115.getValue() + "(" + width + "x" + height + ")"); } - //文件名 - File newFile = new File(path,fileName); - if(!newFile.exists()){ - newFile.mkdirs(); - } - //传输文件 - multipartFile.transferTo(newFile); - } - /** - * 上传文件 - * @param path - * @param fileName - * @param multipartFile - * @throws IllegalStateException - * @throws IOException - */ - public static void uploadFile(String path,String fileName,MultipartFile multipartFile) throws IllegalStateException, IOException{ - //文件名 - File newFile = new File(path,fileName); - if(!newFile.exists()){ - newFile.mkdirs(); - } - //传输文件 - multipartFile.transferTo(newFile); - } - /** - * 删除文件 - * @param path - * @param fileName - */ - public static void deleteFile(String path,String fileName){ - File file = new File(path, fileName); - if(file.exists()){ - file.delete(); - } - } - + //文件名 + File newFile = new File(path, fileName); + if (!newFile.exists()) { + newFile.mkdirs(); + } + //传输文件 + multipartFile.transferTo(newFile); + } + + /** + * 上传文件 + * + * @param path + * @param fileName + * @param multipartFile + * @throws IllegalStateException + * @throws IOException + */ + public static void uploadFile(String path, String fileName, MultipartFile multipartFile) throws IllegalStateException, IOException { + //文件名 + File newFile = new File(path, fileName); + if (!newFile.exists()) { + newFile.mkdirs(); + } + //传输文件 + multipartFile.transferTo(newFile); + } + + /** + * 删除文件 + * + * @param path + * @param fileName + */ + public static void deleteFile(String path, String fileName) { + File file = new File(path, fileName); + if (file.exists()) { + file.delete(); + } + } + } diff --git a/src/main/java/com/ifishNew/config/MybatisConfig.java b/src/main/java/com/ifishNew/config/MybatisConfig.java index a1b784a..ef49c06 100644 --- a/src/main/java/com/ifishNew/config/MybatisConfig.java +++ b/src/main/java/com/ifishNew/config/MybatisConfig.java @@ -31,7 +31,6 @@ public class MybatisConfig { // //获取当前操作系统(servers_os为服务器设置的属性JAVA_OPTS=%JAVA_OPTS% -Dservers_os=online84) // String servers_os = System.getProperty("servers_os") == null ? "" : System.getProperty("servers_os"); - dataSource.setUsername("ifish"); dataSource.setPassword("ifish7pwd"); dataSource.setUrl("jdbc\\:mysql\\://localhost\\:3306/myfishdb?characterEncoding\\=UTF-8"); diff --git a/src/main/java/com/ifishNew/help/FastDFSClient.java b/src/main/java/com/ifishNew/help/FastDFSClient.java index 0111b78..5607815 100644 --- a/src/main/java/com/ifishNew/help/FastDFSClient.java +++ b/src/main/java/com/ifishNew/help/FastDFSClient.java @@ -5,8 +5,14 @@ */ package com.ifishNew.help; +import com.ifish.enums.SysUserEnum; +import com.ifish.exception.IfishException; import com.ifish.util.IfishFileDirectory; import com.ifish.util.ValidateUtil; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; import org.apache.commons.lang3.StringUtils; import org.csource.fastdfs.ClientGlobal; import org.csource.fastdfs.StorageClient1; @@ -136,10 +142,47 @@ public class FastDFSClient implements FastDFSClientI { return ""; } - return IfishFileDirectory.fastDFS_url_app + url; + if (IfishFileDirectory.env.equals("product")) { + return IfishFileDirectory.fastDFS_url_app + url; + } else { + return IfishFileDirectory.fastDFS_url_local + url; + } } catch (Exception e) { return ""; } } + + @Override + public String uploadFile(String path, String fileName, MultipartFile multipartFile, int width, int height) throws IllegalStateException, IOException { + //检验图片尺寸 + BufferedImage sourceImg = ImageIO.read(multipartFile.getInputStream()); + int imgWidth = sourceImg.getWidth(); + int imgHeight = sourceImg.getHeight(); + if (width != imgWidth || height != imgHeight) { + throw new IfishException(SysUserEnum.warn115.getKey(), SysUserEnum.warn115.getValue() + "(" + width + "x" + height + ")"); + } + //文件名 + File newFile = new File(path, fileName); + if (!newFile.exists()) { + newFile.mkdirs(); + } + //传输文件 + //multipartFile.transferTo(newFile); + String value = uploadFileToFastDFS(multipartFile); + return value; + } + + @Override + public String uploadFile(String path, String fileName, MultipartFile multipartFile) throws IllegalStateException, IOException { + //文件名 +// File newFile = new File(path, fileName); +// if (!newFile.exists()) { +// newFile.mkdirs(); +// } + //传输文件 + //multipartFile.transferTo(newFile); + String value = uploadFileToFastDFS(multipartFile); + return value; + } } diff --git a/src/main/java/com/ifishNew/help/FastDFSClientI.java b/src/main/java/com/ifishNew/help/FastDFSClientI.java index c69b844..4e078a7 100644 --- a/src/main/java/com/ifishNew/help/FastDFSClientI.java +++ b/src/main/java/com/ifishNew/help/FastDFSClientI.java @@ -6,6 +6,7 @@ package com.ifishNew.help; import com.ifish.domain.JsonResult; +import java.io.IOException; import org.springframework.web.multipart.MultipartFile; /** @@ -46,4 +47,8 @@ public interface FastDFSClientI { String uploadFile(String group_name, String local_filename, String file_ext_name) throws Exception; String uploadFileToFastDFS(MultipartFile file); + + String uploadFile(String path, String fileName, MultipartFile multipartFile, int width, int height) throws IllegalStateException, IOException; + + String uploadFile(String path, String fileName, MultipartFile multipartFile) throws IllegalStateException, IOException; } diff --git a/src/main/resources/application-security.xml b/src/main/resources/application-security.xml index 554cab2..5e7a1df 100644 --- a/src/main/resources/application-security.xml +++ b/src/main/resources/application-security.xml @@ -14,6 +14,7 @@ + diff --git a/src/main/resources/property.properties b/src/main/resources/property.properties index e2c424c..f6d5185 100644 --- a/src/main/resources/property.properties +++ b/src/main/resources/property.properties @@ -23,8 +23,8 @@ ifish_account=ifish #IM\u5b98\u65b9\u624b\u673a\u53f7 netease_phone=18501773036 #FastDFS\u6587\u4ef6URL\u8bbf\u95ee\u8def\u5f84(\u672c\u5730\u548c\u6d4b\u8bd5\u73af\u5883) -fastDFS_url_local=https://app.zhangxinyanv5.top/ +fastDFS_url_local=http://139.196.24.156:83/ #FastDFS\u6587\u4ef6URL\u8bbf\u95ee\u8def\u5f84(\u6b63\u5f0f\u73af\u5883) fastDFS_url_app=http://app.ifish7.com/ #\u73af\u5883(local:\u672c\u5730\u73af\u5883,test:\u6d4b\u8bd5\u73af\u5883,\u6b63\u5f0f\u73af\u5883:product) -env=test \ No newline at end of file +env=product \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.42-bin.jar b/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.42-bin.jar new file mode 100644 index 0000000..4c6df38 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.42-bin.jar differ diff --git a/src/main/webapp/WEB-INF/view/adInfo/adInfo.jsp b/src/main/webapp/WEB-INF/view/adInfo/adInfo.jsp index 5b22b54..9904403 100644 --- a/src/main/webapp/WEB-INF/view/adInfo/adInfo.jsp +++ b/src/main/webapp/WEB-INF/view/adInfo/adInfo.jsp @@ -2,273 +2,281 @@ <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> - - 广告信息 - - <%@ include file="../htm/script.jsp" %> - - + + 广告信息 + + <%@ include file="../htm/script.jsp" %> + - - - - 首页 - - 广告信息 - - - - - - - - ${local.value} - - - - - ID - 显示 - 广告类型 - 广告图 - 广告链接 - 排序 - 更新 - 创建 - 操作 - - - - - - - - - - - - - - - - - - × - - 新增 - - - - - 广告类型* - - - - ${local.value} - - - - - - 广告图* - - - - - - 广告链接* - - - - - - 是否显示* - - - - ${local.value} - - - - - - 排序号* - - - - - - - - - - - - - - - - - - × - - 修改 - - - - - 广告类型* - - - - - ${local.value} - - - - - - 广告图* - - - - - - - 广告链接* - - - - - - 是否显示* - - - - ${local.value} - - - - - - 排序号* - - - - - - - - - - - - - <%@ include file="../htm/setting.jsp" %> - - - + }, + "bSortable": false + }, + {"mData": function (adInfo) { + return '' + adInfo.adLink + ''; + }, + "bSortable": false + }, + {"mData": "orderNum", "bSortable": false}, + {"mData": "updateTime", "bSortable": false}, + {"mData": "createTime", "bSortable": false}, + {"mData": function (adInfo) { + return ' ' + + ''; + }, + "bSortable": false, + "sClass": "center" + } + ]); + $("#sample-table-2_length").append(' 是否显示:' + + '请选择' + + '' + + '${local.value}' + + '' + + '' + ); + $(".searchBtn").click(function () { + $("button[name='adType']").removeClass("searchClass"); + $(this).addClass("searchClass"); + dt.fnDraw(); + }); + //自动查询 + $(".searchClass").change(function () { + dt.fnDraw(); + }); + //异步提交新增表单 + myModule.addAjaxFrom("#addSubmitBtn", '#form-add', dt); + //异步提交修改表单 + myModule.updateAjaxFrom("#updateSubmitBtn", '#form-update', dt); + }); + //修改 + function findById(el, adId) { + //重置表单 + $("#form-update").data('bootstrapValidator').resetForm(true); + //数据 + var jsonData = {"adId": adId}; + //赋值属性 + var columns = ["adId", "adType", "adLink", "isShow", "adImage", "orderNum"]; + myModule.findByIdFunction(el, '#updateModal', jsonData, columns); + } + //删除 + function deleteById(el, adId) { + var jsonData = {"adId": adId}; + myModule.deleteFunction(el, jsonData, dt); + } + + + + + + <%@ include file="../htm/header.jsp" %> + + + + + <%@ include file="../htm/sidebar.jsp" %> + + + + + + + + 首页 + + 广告信息 + + + + + + + + ${local.value} + + + + + ID + 显示 + 广告类型 + 广告图 + 广告链接 + 排序 + 更新 + 创建 + 操作 + + + + + + + + + + + + + + + + + + × + + 新增 + + + + + 广告类型* + + + + ${local.value} + + + + + + 广告图* + + + + + + 广告链接* + + + + + + 是否显示* + + + + ${local.value} + + + + + + 排序号* + + + + + + + + + + + + + + + + + + × + + 修改 + + + + + 广告类型* + + + + + ${local.value} + + + + + + 广告图* + + + + + + + 广告链接* + + + + + + 是否显示* + + + + ${local.value} + + + + + + 排序号* + + + + + + + + + + + + + <%@ include file="../htm/setting.jsp" %> + + +