diff --git a/src/main/java/com/lovenav/configuration/MyWebConfigurer.java b/src/main/java/com/lovenav/configuration/MyWebConfigurer.java index f366cba..b13b3a7 100644 --- a/src/main/java/com/lovenav/configuration/MyWebConfigurer.java +++ b/src/main/java/com/lovenav/configuration/MyWebConfigurer.java @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; public class MyWebConfigurer implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(new UserInterceptor()).addPathPatterns("/*/**").excludePathPatterns("/error","/login","/register","/findThePassword","/verifyCode","/sendActiveCode"); +// registry.addInterceptor(new UserInterceptor()).addPathPatterns("/*/**").excludePathPatterns("/error","/login","/register","/findThePassword","/verifyCode","/sendActiveCode"); WebMvcConfigurer.super.addInterceptors(registry); } } diff --git a/src/main/java/com/lovenav/controller/ConfigController.java b/src/main/java/com/lovenav/controller/ConfigController.java new file mode 100644 index 0000000..3263842 --- /dev/null +++ b/src/main/java/com/lovenav/controller/ConfigController.java @@ -0,0 +1,32 @@ +package com.lovenav.controller; + +import com.lovenav.entity.Config; +import com.lovenav.service.ConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ConfigController { + @Autowired + ConfigService configService; + @RequestMapping("/updateConfig") + public String updateConfig(Config config){ + if (configService.updateConfis(config)==1){ + return "更新成功"; + } + else { + return "更新配置失败"; + } + } + @RequestMapping("/addConfig") + public String addConfig(Config config){ + if (config.getName()==null||config.getValue()==null){ + return "属性值不能为空"; + }else { + return configService.addConfig(config); + } + + } +} diff --git a/src/main/java/com/lovenav/controller/NavController.java b/src/main/java/com/lovenav/controller/NavController.java new file mode 100644 index 0000000..3124af0 --- /dev/null +++ b/src/main/java/com/lovenav/controller/NavController.java @@ -0,0 +1,41 @@ +package com.lovenav.controller; + +import com.lovenav.entity.Nav; +import com.lovenav.service.NavService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class NavController { + @Autowired + NavService navService; + @RequestMapping("/updateNav") + public String updateNav(Nav nav){ + if (nav==null){ + return "选择更新的导航标签!"; + } + return navService.updateNav(nav); + } + + @RequestMapping("/addNav") + public String addNav(Nav nav){ + if (nav==null){ + return "添加的导航不能为空"; + } + return navService.addNav(nav); + } + @RequestMapping("/deleteNav") + public String deleteNav(Nav nav){ + if (nav==null){ + return "删除的导航不能为空"; + } + return navService.deleteNav(nav); + } + + @RequestMapping("/selectAllNav") + public String selectAllNav(){ + return navService.selectAllNav(); + } + +} diff --git a/src/main/java/com/lovenav/controller/UrlListController.java b/src/main/java/com/lovenav/controller/UrlListController.java new file mode 100644 index 0000000..601f5e3 --- /dev/null +++ b/src/main/java/com/lovenav/controller/UrlListController.java @@ -0,0 +1,23 @@ +package com.lovenav.controller; + +import com.lovenav.entity.UrlList; +import com.lovenav.service.UrlListService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UrlListController { + @Autowired + UrlListService urlListService; + //后台修改网站状态 + @RequestMapping("/admin/weblist/alterUrlStatus") + public String setUrlStatus(UrlList urlList){ + int result=urlListService.updateUrlStatusListById(urlList); + if (result==1){ + return "修改成功"; + }else { + return "修改失败"; + } + } +} diff --git a/src/main/java/com/lovenav/controller/UserController.java b/src/main/java/com/lovenav/controller/UserController.java index 2a8fd18..0b2e13e 100644 --- a/src/main/java/com/lovenav/controller/UserController.java +++ b/src/main/java/com/lovenav/controller/UserController.java @@ -1,6 +1,7 @@ package com.lovenav.controller; import com.alibaba.fastjson2.JSONObject; +import com.lovenav.entity.UrlList; import com.lovenav.entity.User; import com.lovenav.service.UserService; import com.lovenav.utils.MD5Utils; @@ -146,4 +147,5 @@ public class UserController { } + } diff --git a/src/main/java/com/lovenav/dao/ConfigDao.java b/src/main/java/com/lovenav/dao/ConfigDao.java index 69f58e1..f80eef7 100644 --- a/src/main/java/com/lovenav/dao/ConfigDao.java +++ b/src/main/java/com/lovenav/dao/ConfigDao.java @@ -1,9 +1,11 @@ package com.lovenav.dao; import com.lovenav.entity.Config; +import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @Repository +@Mapper public interface ConfigDao { int deleteByPrimaryKey(Integer id); @@ -16,4 +18,8 @@ public interface ConfigDao { int updateByPrimaryKeySelective(Config record); int updateByPrimaryKey(Config record); + + int updateByName(Config config); + + Config selectByName(String name); } \ No newline at end of file diff --git a/src/main/java/com/lovenav/entity/Config.java b/src/main/java/com/lovenav/entity/Config.java index 7ea1e12..1e155ea 100644 --- a/src/main/java/com/lovenav/entity/Config.java +++ b/src/main/java/com/lovenav/entity/Config.java @@ -1,38 +1,63 @@ package com.lovenav.entity; import java.io.Serializable; -import java.util.Date; import lombok.Data; /** + * 配置项 * ln_config */ @Data public class Config implements Serializable { - /** - * id - */ private Integer id; - /** - * 类型 - */ private Object type; - /** - * 名称 - */ private String name; - /** - * 值 - */ private String value; - /** - * 更新时间 - */ - private Date updatetime; + private Integer updatetime; private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Object getType() { + return type; + } + + public void setType(Object type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Integer getUpdatetime() { + return updatetime; + } + + public void setUpdatetime(Integer updatetime) { + this.updatetime = updatetime; + } } \ No newline at end of file diff --git a/src/main/java/com/lovenav/service/AttachmentService.java b/src/main/java/com/lovenav/service/AttachmentService.java new file mode 100644 index 0000000..6fae390 --- /dev/null +++ b/src/main/java/com/lovenav/service/AttachmentService.java @@ -0,0 +1,9 @@ +package com.lovenav.service; + +import org.springframework.web.multipart.MultipartFile; + +import java.util.HashMap; + +public interface AttachmentService { +// public HashMapstoreFile(MultipartFile multipartFile); +} diff --git a/src/main/java/com/lovenav/service/ConfigService.java b/src/main/java/com/lovenav/service/ConfigService.java new file mode 100644 index 0000000..b34ca8b --- /dev/null +++ b/src/main/java/com/lovenav/service/ConfigService.java @@ -0,0 +1,12 @@ +package com.lovenav.service; + +import com.lovenav.entity.Config; + +import java.util.HashMap; + +public interface ConfigService { + public HashMapgetAllConfig(); + public int updateConfis(Config config); + + public String addConfig(Config config); +} diff --git a/src/main/java/com/lovenav/service/NavService.java b/src/main/java/com/lovenav/service/NavService.java new file mode 100644 index 0000000..b773854 --- /dev/null +++ b/src/main/java/com/lovenav/service/NavService.java @@ -0,0 +1,12 @@ +package com.lovenav.service; + +import com.lovenav.entity.Nav; + +public interface NavService { + public String deleteNav(Nav nav); + public String updateNav(Nav nav); + public String selectNav(Nav nav); + public String addNav(Nav nav); + + String selectAllNav(); +} diff --git a/src/main/java/com/lovenav/service/UrlListService.java b/src/main/java/com/lovenav/service/UrlListService.java index 050d8be..899f37b 100644 --- a/src/main/java/com/lovenav/service/UrlListService.java +++ b/src/main/java/com/lovenav/service/UrlListService.java @@ -10,4 +10,8 @@ public interface UrlListService { public List selectUrList(); public UrlList selectUrListByInput(String input); public UrlList selectUrlListByUrlId(Long urlId); + + public int updateUrlStatusListById(UrlList urlList); + + } diff --git a/src/main/java/com/lovenav/service/serviceImpl/AttachmentServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/AttachmentServiceImpl.java new file mode 100644 index 0000000..68de3f8 --- /dev/null +++ b/src/main/java/com/lovenav/service/serviceImpl/AttachmentServiceImpl.java @@ -0,0 +1,58 @@ +package com.lovenav.service.serviceImpl; + +import com.lovenav.service.AttachmentService; +import org.springframework.util.ResourceUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + + + +public class AttachmentServiceImpl implements AttachmentService { +// @Override +// public HashMap storeFile(MultipartFile multipartFile) { +// HashMap map = new HashMap<>(); +// } +// File path = null; +//// try { +// path = new File(ResourceUtils.getURL("classpath:").getPath()); +// File upload = new File(path.getAbsolutePath(),"static/img/"); +// Date date=new Date(); +// +// DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// String date1=format.format(date); +// String fileName = multipartFile.getOriginalFilename();//文件全名 +// File parentDir = new File(upload.getAbsolutePath()+"/" + date1); +// System.out.println(upload.getAbsolutePath()); +// System.out.println(fileName); +// map +// return +// if(!upload.exists()){ +// upload.mkdirs(); +// } +// if(!parentDir.exists()){ +// parentDir.mkdirs(); +// } +// String suffix = suffix(fileName);//文件后缀 +// String relPath = "/" + yearMonth + "/" + "-" + UUID.randomUUID().toString().replaceAll("-","") + suffix; +// File fileUp = new File(upload.getAbsolutePath()+ relPath); +// file.transferTo(fileUp); +// Map map = new HashMap(); +// map.put("url", "/img" + relPath); +// log.info(relPath); +// return map; +// } catch (FileNotFoundException e) { +// throw e; +// } catch (IOException e) { +// throw e; +// } +// } +} diff --git a/src/main/java/com/lovenav/service/serviceImpl/ConfigServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/ConfigServiceImpl.java new file mode 100644 index 0000000..3c4075a --- /dev/null +++ b/src/main/java/com/lovenav/service/serviceImpl/ConfigServiceImpl.java @@ -0,0 +1,39 @@ +package com.lovenav.service.serviceImpl; + +import com.lovenav.dao.ConfigDao; +import com.lovenav.entity.Config; +import com.lovenav.service.ConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +@Service +public class ConfigServiceImpl implements ConfigService { + @Autowired + ConfigDao configDao; + @Override + public HashMap getAllConfig() { + return null; + } + + @Override + public int updateConfis(Config config) { + return configDao.updateByName(config); + } + + @Override + public String addConfig(Config config) { + if(configDao.selectByName(config.getName())!=null){ + return "该配置文件已经存在!"; + }else { + int result=configDao.insertSelective(config); + if (result==1){ + return "添加成功!"; + }else { + return "添加失败!"; + } + } + + } + +} diff --git a/src/main/java/com/lovenav/service/serviceImpl/NavServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/NavServiceImpl.java new file mode 100644 index 0000000..a4182f8 --- /dev/null +++ b/src/main/java/com/lovenav/service/serviceImpl/NavServiceImpl.java @@ -0,0 +1,63 @@ +package com.lovenav.service.serviceImpl; + +import com.alibaba.fastjson2.JSON; +import com.lovenav.dao.NavDao; +import com.lovenav.entity.Nav; +import com.lovenav.service.NavService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class NavServiceImpl implements NavService { + @Autowired + NavDao navDao; + @Override + public String deleteNav(Nav nav) { + if (navDao.selectAlreadyExist(nav)==null) { + return "没有该记录"; + } + int nav1=navDao.deleteByNavName(nav.getNavName()); + if (nav1==1){ + return "删除成功"; + }else { + return "删除失败"; + } + } + + @Override + public String updateNav(Nav nav) { + if (navDao.selectAlreadyExist(nav)==null) { + return "没有该记录"; + } + int result=navDao.updateByName(nav); + if (result==1){ + return "更新成功"; + }else { + return "更新失败"; + } + } + + @Override + public String selectNav(Nav nav) { + return null; + } + + @Override + public String addNav(Nav nav) { + int result; + if(navDao.selectAlreadyExist(nav)!=null){ + return "已经有相同名称的导航!"; + } + result=navDao.insertSelective(nav); + if (result==1){ + return "添加成功"; + }else { + return "添加失败"; + } + } + + @Override + public String selectAllNav() { + return (String) JSON.toJSON(navDao.selectAllNav()); + } +} diff --git a/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java index b1f5f21..710a8ca 100644 --- a/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java +++ b/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java @@ -60,4 +60,14 @@ public class UrlLiserServiceImpl implements UrlListService { urlListDao.updateByPrimaryKeySelective(urlList); return urlList; } + + @Override + public int updateUrlStatusListById(UrlList urlList) { + if (urlListDao.updateByPrimaryKey(urlList)==1){ + return 1; + }else { + return 0; + } + + } } diff --git a/src/main/java/com/lovenav/service/serviceImpl/UserServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/UserServiceImpl.java index 3e27f54..25c3a4c 100644 --- a/src/main/java/com/lovenav/service/serviceImpl/UserServiceImpl.java +++ b/src/main/java/com/lovenav/service/serviceImpl/UserServiceImpl.java @@ -14,7 +14,7 @@ import javax.annotation.Resource; import java.util.Date; import java.util.regex.Pattern; -@Transactional + @Service("userService") public class UserServiceImpl implements UserService { @@ -72,7 +72,6 @@ public class UserServiceImpl implements UserService { user.setUserRegistered(date); - return userDao.insert(user); } diff --git a/src/main/resources/mybatis/AttachmentDao.xml b/src/main/resources/mybatis/AttachmentDao.xml index 96fa805..22379e0 100644 --- a/src/main/resources/mybatis/AttachmentDao.xml +++ b/src/main/resources/mybatis/AttachmentDao.xml @@ -141,4 +141,6 @@ createtime = #{createtime,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/ConfigDao.xml b/src/main/resources/mybatis/ConfigDao.xml index 843fe6a..d7bb424 100644 --- a/src/main/resources/mybatis/ConfigDao.xml +++ b/src/main/resources/mybatis/ConfigDao.xml @@ -6,7 +6,7 @@ - + id, `type`, `name`, `value`, updatetime @@ -17,6 +17,13 @@ from ln_config where id = #{id,jdbcType=INTEGER} + + delete from ln_config where id = #{id,jdbcType=INTEGER} @@ -25,7 +32,7 @@ insert into ln_config (`type`, `name`, `value`, updatetime) values (#{type,jdbcType=OTHER}, #{name,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, - #{updatetime,jdbcType=TIMESTAMP}) + #{updatetime,jdbcType=INTEGER}) insert into ln_config @@ -54,7 +61,7 @@ #{value,jdbcType=VARCHAR}, - #{updatetime,jdbcType=TIMESTAMP}, + #{updatetime,jdbcType=INTEGER}, @@ -71,7 +78,7 @@ `value` = #{value,jdbcType=VARCHAR}, - updatetime = #{updatetime,jdbcType=TIMESTAMP}, + updatetime = #{updatetime,jdbcType=INTEGER}, where id = #{id,jdbcType=INTEGER} @@ -81,7 +88,22 @@ set `type` = #{type,jdbcType=OTHER}, `name` = #{name,jdbcType=VARCHAR}, `value` = #{value,jdbcType=VARCHAR}, - updatetime = #{updatetime,jdbcType=TIMESTAMP} + updatetime = #{updatetime,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} + + update ln_config + + + `type` = #{type,jdbcType=OTHER}, + + + `value` = #{value,jdbcType=VARCHAR}, + + + updatetime = #{updatetime,jdbcType=INTEGER}, + + + where name = #{name,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/src/main/resources/mybatis/UrlListDao.xml b/src/main/resources/mybatis/UrlListDao.xml index 113b786..5a5f0e7 100644 --- a/src/main/resources/mybatis/UrlListDao.xml +++ b/src/main/resources/mybatis/UrlListDao.xml @@ -230,22 +230,56 @@ update ln_url_list - set `name` = #{name,jdbcType=VARCHAR}, - icon = #{icon,jdbcType=VARCHAR}, - cate_id = #{cateId,jdbcType=INTEGER}, - url = #{url,jdbcType=VARCHAR}, - createtime = #{createtime,jdbcType=BIGINT}, - views = #{views,jdbcType=BIGINT}, - tags = #{tags,jdbcType=VARCHAR}, - weigh = #{weigh,jdbcType=BIGINT}, - `status` = #{status,jdbcType=TINYINT}, - `desc` = #{desc,jdbcType=VARCHAR}, - need_login = #{needLogin,jdbcType=TINYINT}, - agent_hint = #{agentHint,jdbcType=VARCHAR}, - is_need_agent = #{isNeedAgent,jdbcType=TINYINT}, - is_ad = #{isAd,jdbcType=TINYINT}, - is_top = #{isTop,jdbcType=TINYINT}, - is_encrypt = #{isEncrypt,jdbcType=TINYINT} + + + `name` = #{name,jdbcType=VARCHAR}, + + + icon = #{icon,jdbcType=VARCHAR}, + + + cate_id = #{cateId,jdbcType=INTEGER}, + + + url = #{url,jdbcType=VARCHAR}, + + + createtime = #{createtime,jdbcType=BIGINT}, + + + views = #{views,jdbcType=BIGINT}, + + + tags = #{tags,jdbcType=VARCHAR}, + + + weigh = #{weigh,jdbcType=BIGINT}, + + + `status` = #{status,jdbcType=TINYINT}, + + + `desc` = #{desc,jdbcType=VARCHAR}, + + + need_login = #{needLogin,jdbcType=TINYINT}, + + + agent_hint = #{agentHint,jdbcType=VARCHAR}, + + + is_need_agent = #{isNeedAgent,jdbcType=TINYINT}, + + + is_ad = #{isAd,jdbcType=TINYINT}, + + + is_top = #{isTop,jdbcType=TINYINT}, + + + is_encrypt = #{isEncrypt,jdbcType=TINYINT}, + + where id = #{id,jdbcType=BIGINT} \ No newline at end of file