From 1e53e5f28c55ece70b28c752fa318e2fd951e643 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期三, 20 三月 2019 16:33:51 +0800 Subject: [PATCH] taobao 下dao改造以及删除dao --- fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java | 110 +++++++++++++++++++++++------------------------------- 1 files changed, 47 insertions(+), 63 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java index b0a8826..955142c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java @@ -6,8 +6,6 @@ import java.util.List; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONObject; @@ -22,7 +20,6 @@ import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.entity.bus.homemodule.SwiperBanner; import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; -import com.yeshi.fanli.entity.common.AdminUser; import com.yeshi.fanli.entity.common.JumpDetailV2; import com.yeshi.fanli.exception.banner.SwiperBannerException; import com.yeshi.fanli.exception.banner.SwiperPictureException; @@ -34,7 +31,6 @@ import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.annotation.RequestNoLogin; /** * 杞挱鍥剧鐞� @@ -366,20 +362,10 @@ * @param response * @param out */ - @RequestNoLogin() @RequestMapping(value = "uploadPicture") public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, Long uid, - SwiperPicture record, HttpServletRequest request, HttpServletResponse response, PrintWriter out) { + SwiperPicture record, PrintWriter out) { - response.setHeader("Access-Control-Allow-Origin", "*"); - response.setHeader("Access-Control-Allow-Methods", "*"); - - AdminUser admin = adminUserService.selectByPrimaryKey(uid); - - if (admin == null) { - out.print(JsonUtil.loadFalseResult("褰撳墠璐︽埛楠岃瘉澶辫触")); - return; - } if (file == null) { out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓虹┖")); @@ -398,6 +384,7 @@ record.setOrder(maxOrder + 1); // 榛樿鍋滅敤 record.setState(1); + record.setAutoControl(1); record.setCreatetime(new Date()); record.setUpdatetime(new Date()); @@ -436,20 +423,9 @@ * @param response * @param out */ - @RequestNoLogin() @RequestMapping(value = "changePicture") - public void changePicture(@RequestParam("file") CommonsMultipartFile file, Long uid, - Long id, HttpServletRequest request, HttpServletResponse response, PrintWriter out) { - - response.setHeader("Access-Control-Allow-Origin", "*"); - response.setHeader("Access-Control-Allow-Methods", "*"); - - AdminUser admin = adminUserService.selectByPrimaryKey(uid); - - if (admin == null) { - out.print(JsonUtil.loadFalseResult("褰撳墠璐︽埛楠岃瘉澶辫触")); - return; - } + public void changePicture(@RequestParam("file") CommonsMultipartFile file, Long uid, Long id, + PrintWriter out) { if (file == null) { out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓虹┖")); @@ -484,7 +460,6 @@ * @param record * @param out */ - @RequestNoLogin() @RequestMapping(value = "changePicInfo") public void changePicInfo(String callback, SwiperPicture record, String jumpType, PrintWriter out) { @@ -496,40 +471,7 @@ return; } - SwiperPicture resultObj = swiperPictureService.selectByPrimaryKey(id); - if (resultObj == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔鏁版嵁宸蹭笉瀛樺湪")); - return; - } - - String params = record.getParams(); - String remark = record.getRemark(); - if (StringUtil.isNullOrEmpty(params) && StringUtil.isNullOrEmpty(jumpType) - && StringUtil.isNullOrEmpty(remark)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔鍐呭涓嶈兘涓虹┖")); - return; - } - - - if (!StringUtil.isNullOrEmpty(params)) { - - String jumpValue = systemConfigService.get("jump"); - if (StringUtil.isNullOrEmpty(jumpValue)) { - jumpValue = "{\"url\":\"#\"}"; - } - - params = jumpValue.replace("#", params); - record.setParams(params); - } - - if (!StringUtil.isNullOrEmpty(jumpType)) { - List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType); - if (listByType !=null && listByType.size() > 0) { - record.setJumpDetail(listByType.get(0)); - } - } - - swiperPictureService.updateByPrimaryKeySelective(record); + swiperPictureService.save(record); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); @@ -614,6 +556,48 @@ e.printStackTrace(); } } + + + /** + * 鏇存柊鑷姩鎺у埗鐘舵�� + * @param callback + * @param id + * @param out + */ + @RequestMapping(value = "updateAutoControl") + public void updateAutoControl(String callback, Long id, PrintWriter out) { + try { + + if (id == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID涓嶈兘涓虹┖")); + return; + } + + SwiperPicture resultObj = swiperPictureService.selectByPrimaryKey(id); + if (resultObj == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔鏁版嵁宸蹭笉瀛樺湪")); + return; + } + + Integer state = resultObj.getAutoControl(); + if (state == null || state.equals(1) || state == 1) { + resultObj.setAutoControl(0); + } else { + resultObj.setAutoControl(1); + } + + swiperPictureService.updateByPrimaryKeySelective(resultObj); + + JSONObject data = new JSONObject(); + data.put("state", resultObj.getState()); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch (SwiperPictureException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } /** * 淇敼鎺掑簭 -- Gitblit v1.8.0