diff --git a/src/main/java/com/jmfy/WebSecurityConfig.java b/src/main/java/com/jmfy/WebSecurityConfig.java index 4b16611..9948f5b 100644 --- a/src/main/java/com/jmfy/WebSecurityConfig.java +++ b/src/main/java/com/jmfy/WebSecurityConfig.java @@ -40,6 +40,7 @@ public class WebSecurityConfig extends WebMvcConfigurerAdapter{ addInterceptor.excludePathPatterns("/error"); addInterceptor.excludePathPatterns("/login**"); addInterceptor.excludePathPatterns("/req/**"); + addInterceptor.excludePathPatterns("/webGetChannelInfo**"); addInterceptor.addPathPatterns("/**"); } diff --git a/src/main/java/com/jmfy/controller/ChannelInfoController.java b/src/main/java/com/jmfy/controller/ChannelInfoController.java index 0a8fcce..57381c4 100644 --- a/src/main/java/com/jmfy/controller/ChannelInfoController.java +++ b/src/main/java/com/jmfy/controller/ChannelInfoController.java @@ -15,8 +15,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.List; +import java.util.*; /** * @Author hj @@ -51,6 +50,22 @@ public class ChannelInfoController { return "channelInfo"; } + /** + * 外部获取渠道信息 + * @param map + * @returnc + */ + @RequestMapping(value = "/webGetChannelInfo", method = {RequestMethod.POST, RequestMethod.GET}) + @ResponseBody + public String webGetChannelInfo(HttpServletRequest request) throws Exception { + String ccId = request.getParameter("ccId"); + ChannelInfo info = channelInfoDao.getChannelInfoById(ccId); + if (info == null){ + return "-1"; + } + return String.valueOf(info.getShielding()); + } + /** * 添加 * @param request @@ -88,6 +103,60 @@ public class ChannelInfoController { return 1; } + /** + * 修改 + * @param request + * @return + * @throws Exception + */ + @RequestMapping(value = "/updateChannel", method = {RequestMethod.POST, RequestMethod.GET}) + public @ResponseBody + int updateChannel(HttpServletRequest request) throws Exception { + HashMap map = JsonUtil.getInstence().getParameterMap(request); + // 验证权限 + boolean verifyPower = commonManager.verifyPower(request, PowersEnum.UPDATE_CHANNEL_PERMISSIONS); + if (!verifyPower){ + return 2; + } + // 参数处理 + String ccId = map.get("ccId"); + String name = map.get("name"); + int shielding = Integer.parseInt(map.get("shielding")); + // 验证是否重复 + List infos = channelInfoDao.getChannelInfosById(ccId); + if (infos == null || infos.size() != 1){ + return 0; + } + ChannelInfo info = infos.get(0); + info.setId(ccId); + info.setName(name); + info.setShielding(shielding); + // 修改 + channelInfoDao.updateChannelInfo(info); + + return 1; + } + + /** + * 修改界面 + * @param request + * @return + * @throws Exception + */ + @RequestMapping(value = "/toUpdateChannel", method = {RequestMethod.POST, RequestMethod.GET}) + public String toUpdateChannel(ModelMap model, String id) throws Exception { + List infos = channelInfoDao.getChannelInfosById(id); + if (infos == null){ + throw new Exception("id错误,渠道未找到,修改失败"); + } + if (infos.size() != 1){ + throw new Exception("id已存在,修改失败"); + } + ChannelInfo info = infos.get(0); + model.addAttribute("info", info); + return "updateChannel"; + } + /** * 删除 * @param request diff --git a/src/main/java/com/jmfy/dao/ChannelInfoDao.java b/src/main/java/com/jmfy/dao/ChannelInfoDao.java index e2d940e..9f34833 100644 --- a/src/main/java/com/jmfy/dao/ChannelInfoDao.java +++ b/src/main/java/com/jmfy/dao/ChannelInfoDao.java @@ -33,6 +33,14 @@ public interface ChannelInfoDao { */ ChannelInfo getChannelInfoById(String id) throws Exception; + /** + * 单个查询,id + * @param id + * @return + * @throws Exception + */ + List getChannelInfosById(String id) throws Exception; + /** * 添加 * @param channelInfo @@ -47,4 +55,11 @@ public interface ChannelInfoDao { */ void deleteChannelInfo(ChannelInfo channelInfo) throws Exception; + /** + * 修改 + * @param channelInfo + * @throws Exception + */ + void updateChannelInfo(ChannelInfo channelInfo) throws Exception; + } diff --git a/src/main/java/com/jmfy/dao/impl/ChannelInfoDaoImpl.java b/src/main/java/com/jmfy/dao/impl/ChannelInfoDaoImpl.java index 714d5ab..ea565e4 100644 --- a/src/main/java/com/jmfy/dao/impl/ChannelInfoDaoImpl.java +++ b/src/main/java/com/jmfy/dao/impl/ChannelInfoDaoImpl.java @@ -10,6 +10,7 @@ import com.jmfy.utils.Connect; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -44,6 +45,13 @@ public class ChannelInfoDaoImpl implements ChannelInfoDao { return mongoTemplate.findOne(query, ChannelInfo.class); } + @Override + public List getChannelInfosById(String id) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(id)); + return mongoTemplate.find(query, ChannelInfo.class); + } + @Override public void insertChannelInfo(ChannelInfo channelInfo) throws Exception { MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); @@ -55,4 +63,21 @@ public class ChannelInfoDaoImpl implements ChannelInfoDao { MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); mongoTemplate.remove(channelInfo); } + + @Override + public void updateChannelInfo(ChannelInfo channelInfo) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(channelInfo.getId())); + Update update = new Update(); + if (channelInfo.getId() != null){ + update.set("id",channelInfo.getId()); + } + if (channelInfo.getName() != null){ + update.set("name",channelInfo.getName()); + } + if (channelInfo.getShielding() >= 0){ + update.set("shielding",channelInfo.getShielding()); + } + mongoTemplate.upsert(query,update,ChannelInfo.class); + } } diff --git a/src/main/java/com/jmfy/model/ChannelInfo.java b/src/main/java/com/jmfy/model/ChannelInfo.java index d188479..e760906 100644 --- a/src/main/java/com/jmfy/model/ChannelInfo.java +++ b/src/main/java/com/jmfy/model/ChannelInfo.java @@ -17,9 +17,16 @@ public class ChannelInfo { @Field(value = "name") private String name; + @Field(value = "shielding") + private int shielding; + public ChannelInfo(String id, String name) { this.id = id; this.name = name; + this.shielding = 0; + } + + public ChannelInfo() { } public String getId() { @@ -37,4 +44,12 @@ public class ChannelInfo { public void setName(String name) { this.name = name; } + + public int getShielding() { + return shielding; + } + + public void setShielding(int shielding) { + this.shielding = shielding; + } } diff --git a/src/main/java/com/jmfy/model/vo/PowersEnum.java b/src/main/java/com/jmfy/model/vo/PowersEnum.java index 853b411..bdef8d1 100644 --- a/src/main/java/com/jmfy/model/vo/PowersEnum.java +++ b/src/main/java/com/jmfy/model/vo/PowersEnum.java @@ -93,13 +93,14 @@ public enum PowersEnum { // 游戏管理 GAME_MANAGER(1400,"游戏管理",1400,1,""), - PACKAGE_NAME_MANAGER(1401,"频道管理",1400,1,"packageInfoList"), + PACKAGE_NAME_MANAGER(1401,"频道管理(公告用)",1400,1,"packageInfoList"), ADD_PACKAGE_NAME(1402,"权限: 添加频道",1400,0,""), DELETE_PACKAGE_NAME(1403,"权限: 删除频道",1400,0,""), CHANNEL_NAME_MANAGER(1404,"渠道管理",1400,1,"channelInfoList"), ADD_CHANNEL_PERMISSIONS(1405,"权限: 添加渠道",1400,0,""), DELETE_CHANNEL_PERMISSIONS(1406,"权限: 删除渠道",1400,0,""), + UPDATE_CHANNEL_PERMISSIONS(1410,"权限: 修改渠道",1400,0,""), HAND_IN_MANAGER(1407,"提审服管理",1400,1,"tishenInfoList"), diff --git a/src/main/resources/templates/channelInfo.html b/src/main/resources/templates/channelInfo.html index 376454e..c13c069 100644 --- a/src/main/resources/templates/channelInfo.html +++ b/src/main/resources/templates/channelInfo.html @@ -42,6 +42,7 @@ ID 名称 + 是否和谐 操作 @@ -50,8 +51,12 @@ + + @@ -82,6 +87,12 @@ ] }); + // 修改密码 + function updateChannel(obj) { + var id = $(obj).attr("id"); + window.location = "/toUpdateChannel?id=" + id; + } + // 添加 function addChannel() { var name = $("#channel").val(); @@ -111,29 +122,34 @@ }) } - // 单个审核 + // 删除 function deleteChannel(obj) { var id = $(obj).attr("id"); - $.ajax({ - type: "POST", - data: { - "id": id - }, - url: "/deleteChannelInfo", - success: function (data) { - if (data === 1) { - layer.msg('操作成功!', {icon: 6, time: 1000}); - window.location.reload(); - } - if (data === 0) { - layer.msg('操作失败,数据不存在!', {icon: 6, time: 1000}); - } - if (data === 2) { - layer.msg('没有权限', {icon: 6, time: 1000}); + var msg = "您真的确定要删除id为:{" + id +"}的渠道吗?\n\n请确认!"; + if (confirm(msg) === true) { + $.ajax({ + type: "POST", + data: { + "id": id + }, + url: "/deleteChannelInfo", + success: function (data) { + if (data === 1) { + layer.msg('操作成功!', {icon: 6, time: 1000}); + window.location.reload(); + } + if (data === 0) { + layer.msg('操作失败,数据不存在!', {icon: 6, time: 1000}); + } + if (data === 2) { + layer.msg('没有权限', {icon: 6, time: 1000}); + } } } - } - ) + ) + }else { + return false; + } } diff --git a/src/main/resources/templates/updateChannel.html b/src/main/resources/templates/updateChannel.html new file mode 100644 index 0000000..b58646f --- /dev/null +++ b/src/main/resources/templates/updateChannel.html @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + 基本设置 + + + +
+
+
+
+ 修改渠道信息 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+ +
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html index 52342c2..abdfb69 100644 --- a/src/main/resources/templates/welcome.html +++ b/src/main/resources/templates/welcome.html @@ -26,9 +26,10 @@

太初行管理后台

-

更新日志[2021-10-19]

+

更新日志[2021-10-25]

1、服务器信息添加删除按钮

2、订单列表修改时间输入方式,小幅度速度优化

+

3、渠道管理添加是否和谐参数