diff --git a/amms_front/eslint.config.js b/amms_front/eslint.config.js new file mode 100644 index 0000000..5a1d59c --- /dev/null +++ b/amms_front/eslint.config.js @@ -0,0 +1,17 @@ +import js from '@eslint/js' +import pluginVue from 'eslint-plugin-vue' + +export default [ + { + name: 'app/files-to-lint', + files: ['**/*.{js,mjs,jsx,vue}'], + }, + + { + name: 'app/files-to-ignore', + ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], + }, + + js.configs.recommended, + ...pluginVue.configs['flat/essential'], +] diff --git a/amms_front/public/favicon.ico b/amms_front/public/favicon.ico new file mode 100644 index 0000000..df36fcf Binary files /dev/null and b/amms_front/public/favicon.ico differ diff --git a/amms_front/src/api/carousel.js b/amms_front/src/api/carousel.js new file mode 100644 index 0000000..c5c671c --- /dev/null +++ b/amms_front/src/api/carousel.js @@ -0,0 +1,41 @@ +import axios from '@/utils/request' + +// 查询轮播图列表 +export function listCarousel(query) { + return axios.get('/carousel/list',{ + params: { + ...query + } + }) +} + +// 查询全部轮播图列表 +export function listAllCarousel(query) { + return axios.get('/carousel/listAll', { + params: { + ...query + } + }) +} + +// 查询轮播图详细 +export function getCarousel(id) { + return axios.get('/carousel/info/' + id) +} + +// 新增轮播图 +export function addCarousel(data) { + return axios.post('/carousel/add', { + ...data + }) +} + +// 修改轮播图 +export function updateCarousel(data) { + return axios.put('/carousel', data) +} + +// 删除轮播图 +export function delCarousel(id) { + return axios.delete('/carousel/' + id) +} diff --git a/amms_front/src/api/file.js b/amms_front/src/api/file.js new file mode 100644 index 0000000..d95ed38 --- /dev/null +++ b/amms_front/src/api/file.js @@ -0,0 +1,2 @@ +import request from '@/utils/request' + diff --git a/amms_front/src/assets/home1.png b/amms_front/src/assets/home1.png new file mode 100644 index 0000000..a229e7f Binary files /dev/null and b/amms_front/src/assets/home1.png differ diff --git a/amms_front/src/components/Editor.vue b/amms_front/src/components/Editor.vue new file mode 100644 index 0000000..a029d4a --- /dev/null +++ b/amms_front/src/components/Editor.vue @@ -0,0 +1,152 @@ + + + + diff --git a/amms_front/src/components/HLayout.vue b/amms_front/src/components/HLayout.vue new file mode 100644 index 0000000..184876c --- /dev/null +++ b/amms_front/src/components/HLayout.vue @@ -0,0 +1,276 @@ + + + + + diff --git a/amms_front/src/utils/common.js b/amms_front/src/utils/common.js new file mode 100644 index 0000000..59f5adb --- /dev/null +++ b/amms_front/src/utils/common.js @@ -0,0 +1,32 @@ +import moment from "moment"; + +/** +* 参数处理 +* @param {*} params 参数 +*/ +export function tansParams(params) { + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName]; + const part = encodeURIComponent(propName) + "="; + if (value !== null && value !== "" && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { + const params = propName + '[' + key + ']'; + const subPart = encodeURIComponent(params) + "="; + result += subPart + encodeURIComponent(value[key]) + "&"; + } + } + } else { + result += part + encodeURIComponent(value) + "&"; + } + } + } + return result +} + +// 日期格式化 +export function parseTime(time, pattern) { + return moment(time).format(pattern || 'YYYY-MM-DD HH:mm:ss') +} \ No newline at end of file diff --git a/amms_front/src/views/tourist/relic/detail.vue b/amms_front/src/views/tourist/relic/detail.vue new file mode 100644 index 0000000..e73e482 --- /dev/null +++ b/amms_front/src/views/tourist/relic/detail.vue @@ -0,0 +1,338 @@ + + + + + diff --git a/src/main/java/com/amms/controller/CarouselController.java b/src/main/java/com/amms/controller/CarouselController.java new file mode 100644 index 0000000..718133d --- /dev/null +++ b/src/main/java/com/amms/controller/CarouselController.java @@ -0,0 +1,72 @@ +package com.amms.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.amms.domain.vo.Result; +import com.amms.domain.Carousel; +import com.amms.service.ICarouselService; + +import java.util.List; + +/** + * 轮播图Controller + */ +@RestController +@RequestMapping("/carousel") +public class CarouselController { + + @Autowired + private ICarouselService carouselService; + + /** + * 查询轮播图列表 + */ + @GetMapping("/list") + public PageInfo list(Carousel carousel, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) { + PageHelper.startPage(pageNum, pageSize); + List carousels = carouselService.selectCarouselList(carousel); + return new PageInfo(carousels); + } + + /** + * 查询全部轮播图列表 + */ + @GetMapping("/listAll") + public List listAll(Carousel carousel) { + return carouselService.selectCarouselList(carousel); + } + + /** + * 获取轮播图详细信息 + */ + @GetMapping(value = "/info/{id}") + public Result getInfo(@PathVariable("id") Long id) { + return Result.success(carouselService.selectCarouselById(id)); + } + + /** + * 新增轮播图 + */ + @PostMapping("/add") + public Result add(@RequestBody Carousel carousel) { + return carouselService.insertCarousel(carousel) > 0 ? Result.success("新增成功") : Result.error("新增失败"); + } + + /** + * 修改轮播图 + */ + @PutMapping + public Result update(@RequestBody Carousel carousel) { + return carouselService.updateCarousel(carousel) > 0 ? Result.success("修改成功") : Result.error("修改失败"); + } + + /** + * 删除轮播图 + */ + @DeleteMapping("/{id}") + public Result delete(@PathVariable Long id) { + return carouselService.deleteCarouselById(id) > 0 ? Result.success("删除成功") : Result.error("删除失败"); + } +} diff --git a/src/main/java/com/amms/controller/FilesController.java b/src/main/java/com/amms/controller/FilesController.java new file mode 100644 index 0000000..73adb6f --- /dev/null +++ b/src/main/java/com/amms/controller/FilesController.java @@ -0,0 +1,161 @@ +package com.amms.controller; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.net.URLEncoder; +import java.util.UUID; + +/** + * 文件处理controller + */ +@Controller +@RequestMapping("/files") +public class FilesController { + + private static Logger logger = LoggerFactory.getLogger(FilesController.class); + + @Value("${files.path}") + private String path; + + /** + * 文件上传 + * @param file + * @return + * @throws IOException + */ + @PostMapping("/upload") + @ResponseBody + public String upload(@RequestParam("file") MultipartFile file ,@RequestParam(name = "filePath" ,required = false) String filePath) throws IOException { + logger.info("上传文件:{}", file.getName()); + File fileUploadPath = null; + // 创建目标路径 + if (!filePath.equals("") && filePath != null) { + fileUploadPath = new File(path, filePath); + } else { + fileUploadPath = new File(path); + } + if (!fileUploadPath.exists()) { + fileUploadPath.mkdirs(); + } + // 新文件名 + String newFileName = UUID.randomUUID().toString().replace("-", "") + "-" + file.getOriginalFilename(); + file.transferTo(new File(fileUploadPath, newFileName)); + // 判断参数中filePath时候为null 不为空则拼接到新文件名前 + if (!filePath.equals("") && filePath != null) { + if (filePath.endsWith("/")) { + newFileName = filePath + newFileName; + } else { + newFileName = filePath + "/" + newFileName; + } + } + return newFileName; + } + + byte[] buffer = new byte[1024]; + BufferedInputStream bis = null; + OutputStream os = null; + + /** + * 获取文件(图片) + * @param fileName + * @param response + * @throws UnsupportedEncodingException + */ + @GetMapping("/get") + public void getImage(@RequestParam("fileName") String fileName, HttpServletResponse response) throws UnsupportedEncodingException { + logger.debug("加载图片,文件名:" + fileName); + File file = new File(path, fileName); + // 判断文件是否存在 + if (!file.exists()) { + logger.error("文件【" + file.getAbsolutePath() + "】不存在!"); + response.setStatus(404); + return; + } + response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") ); + response.setContentType("image/jpeg"); + response.setContentLength((int)file.length()); + FileInputStream is = null; + OutputStream os = null; + try { + is = new FileInputStream(file); + os = response.getOutputStream(); + + byte[] buf = new byte[8192]; + int rd; + while ((rd = is.read(buf)) > 0) + os.write(buf, 0, rd); + + } catch (IOException e) { + logger.error(e.getMessage()); + } finally { + try { + if (is!=null) is.close(); + if (os!=null) { + os.flush(); + os.close(); + } + } catch (IOException e) { + logger.error(e.getMessage()); + } + } + } + + + /** + * 删除文件 + * @param fileName + * @param response + * @throws UnsupportedEncodingException + */ + @GetMapping("/delete") + public void delete(@RequestParam("fileName") String fileName, HttpServletResponse response) throws UnsupportedEncodingException { + logger.error("删除文件,文件名:" + fileName); + File file = new File(path + fileName); + if (!file.exists()) { + logger.error("文件【" + fileName + "】不存在!"); + response.setStatus(404); + return; + } + try { + file.delete(); + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + + /** + * 下载文件 + * @param fileName + * @param request + * @param response + * @throws IOException + */ + @GetMapping("/download") + public void download(String fileName, HttpServletRequest request, HttpServletResponse response) throws IOException { + logger.info("下载文件:{}", fileName); + File fileUploadPathFile = new File(path); + if (!fileUploadPathFile.exists()) { + fileUploadPathFile.mkdir(); + } + File file = new File(fileUploadPathFile, fileName); + + response.setContentType("application/octet-stream;charset=UTF-8"); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition","attachment;filename="+fileName); + response.setCharacterEncoding("UTF-8"); + os = response.getOutputStream(); + bis = new BufferedInputStream(new FileInputStream(file)); + while(bis.read(buffer) != -1){ + os.write(buffer); + } + } +} diff --git a/src/main/java/com/amms/domain/Carousel.java b/src/main/java/com/amms/domain/Carousel.java new file mode 100644 index 0000000..8709032 --- /dev/null +++ b/src/main/java/com/amms/domain/Carousel.java @@ -0,0 +1,119 @@ +package com.amms.domain; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 轮播图对象 carousel + */ +public class Carousel { + + /** 轮播图id */ + private Long id; + + /** 标题 */ + private String title; + + /** 图片地址 */ + private String imageUrl; + + /** 跳转链接 */ + private String link; + + /** 排序序号 */ + private Integer sort; + + /** 状态(0隐藏 1显示) */ + private Long status; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTitle() { + return title; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setLink(String link) { + this.link = link; + } + + public String getLink() { + return link; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public Integer getSort() { + return sort; + } + + public void setStatus(Long status) { + this.status = status; + } + + public Long getStatus() { + return status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return "Carousel{" + + "id=" + id + + ", title=" + title + + ", imageUrl=" + imageUrl + + ", link=" + link + + ", sort=" + sort + + ", status=" + status + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + '}'; + } +} diff --git a/src/main/java/com/amms/mapper/CarouselMapper.java b/src/main/java/com/amms/mapper/CarouselMapper.java new file mode 100644 index 0000000..8694424 --- /dev/null +++ b/src/main/java/com/amms/mapper/CarouselMapper.java @@ -0,0 +1,52 @@ +package com.amms.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import com.amms.domain.Carousel; + +/** + * 轮播图Mapper接口 + */ +@Mapper +public interface CarouselMapper { + /** + * 查询轮播图 + * + * @param id 轮播图主键 + * @return 轮播图 + */ + public Carousel selectCarouselById(Long id); + + /** + * 查询轮播图列表 + * + * @param carousel 轮播图 + * @return 轮播图集合 + */ + public List selectCarouselList(Carousel carousel); + + /** + * 新增轮播图 + * + * @param carousel 轮播图 + * @return 结果 + */ + public int insertCarousel(Carousel carousel); + + /** + * 修改轮播图 + * + * @param carousel 轮播图 + * @return 结果 + */ + public int updateCarousel(Carousel carousel); + + /** + * 删除轮播图 + * + * @param id 轮播图主键 + * @return 结果 + */ + public int deleteCarouselById(Long id); + +} diff --git a/src/main/java/com/amms/service/impl/CarouselServiceImpl.java b/src/main/java/com/amms/service/impl/CarouselServiceImpl.java new file mode 100644 index 0000000..eed7e27 --- /dev/null +++ b/src/main/java/com/amms/service/impl/CarouselServiceImpl.java @@ -0,0 +1,77 @@ +package com.amms.service.impl; + +import java.util.List; +import java.util.Date; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.amms.mapper.CarouselMapper; +import com.amms.domain.Carousel; +import com.amms.service.ICarouselService; + +/** + * 轮播图Service业务层处理 + */ +@Service +public class CarouselServiceImpl implements ICarouselService { + + @Autowired + private CarouselMapper carouselMapper; + + /** + * 查询轮播图列表 + * + * @param carousel 轮播图 + * @return 轮播图 + */ + @Override + public List selectCarouselList(Carousel carousel) { + return carouselMapper.selectCarouselList(carousel); + } + + /** + * 查询轮播图 + * + * @param id 轮播图主键 + * @return 轮播图 + */ + @Override + public Carousel selectCarouselById(Long id) { + return carouselMapper.selectCarouselById(id); + } + + /** + * 新增轮播图 + * + * @param carousel 轮播图 + * @return 结果 + */ + @Override + public int insertCarousel(Carousel carousel) { + carousel.setCreateTime(new Date()); + return carouselMapper.insertCarousel(carousel); + } + + /** + * 修改轮播图 + * + * @param carousel 轮播图 + * @return 结果 + */ + @Override + public int updateCarousel(Carousel carousel) { + carousel.setUpdateTime(new Date()); + return carouselMapper.updateCarousel(carousel); + } + + /** + * 删除轮播图信息 + * + * @param id 轮播图主键 + * @return 结果 + */ + @Override + public int deleteCarouselById(Long id) { + return carouselMapper.deleteCarouselById(id); + } + +} diff --git a/src/main/resources/mapper/CarouselMapper.xml b/src/main/resources/mapper/CarouselMapper.xml new file mode 100644 index 0000000..3d2db50 --- /dev/null +++ b/src/main/resources/mapper/CarouselMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + select id, title, image_url, link, sort, status, create_time, update_time from carousel + + + + + + + + insert into carousel + + title, + image_url, + link, + sort, + status, + create_time, + update_time, + + + #{title}, + #{imageUrl}, + #{link}, + #{sort}, + #{status}, + #{createTime}, + #{updateTime}, + + + + + update carousel + + title = #{title}, + image_url = #{imageUrl}, + link = #{link}, + sort = #{sort}, + status = #{status}, + create_time = #{createTime}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from carousel where id = #{id} + +