diff --git a/amms_front/jsconfig.json b/amms_front/jsconfig.json new file mode 100644 index 0000000..5a1f2d2 --- /dev/null +++ b/amms_front/jsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "paths": { + "@/*": ["./src/*"] + } + }, + "exclude": ["node_modules", "dist"] +} diff --git a/amms_front/src/api/itemCollection.js b/amms_front/src/api/itemCollection.js new file mode 100644 index 0000000..9a1c292 --- /dev/null +++ b/amms_front/src/api/itemCollection.js @@ -0,0 +1,41 @@ +import axios from '@/utils/request' + +// 查询收藏列表 +export function listItemCollection(query) { + return axios.get('/itemCollection/list',{ + params: { + ...query + } + }) +} + +// 查询全部收藏列表 +export function listAllItemCollection(query) { + return axios.get('/itemCollection/listAll', { + params: { + ...query + } + }) +} + +// 查询收藏详细 +export function getItemCollection(id) { + return axios.get('/itemCollection/info/' + id) +} + +// 新增收藏 +export function addItemCollection(data) { + return axios.post('/itemCollection/add', { + ...data + }) +} + +// 修改收藏 +export function updateItemCollection(data) { + return axios.put('/itemCollection', data) +} + +// 删除收藏 +export function delItemCollection(id) { + return axios.delete('/itemCollection/' + id) +} diff --git a/amms_front/src/api/login.js b/amms_front/src/api/login.js new file mode 100644 index 0000000..762b6d5 --- /dev/null +++ b/amms_front/src/api/login.js @@ -0,0 +1,14 @@ +import request from '@/utils/request' + +// 登录方法 +export function login(username, password) { + const data = { + username, + password + } + return request({ + url: '/sysUser/login', + method: 'post', + data: data + }) +} diff --git a/amms_front/src/components/Layout.vue b/amms_front/src/components/Layout.vue new file mode 100644 index 0000000..91dd800 --- /dev/null +++ b/amms_front/src/components/Layout.vue @@ -0,0 +1,319 @@ + + + + + diff --git a/amms_front/src/views/login.vue b/amms_front/src/views/login.vue new file mode 100644 index 0000000..699acf7 --- /dev/null +++ b/amms_front/src/views/login.vue @@ -0,0 +1,195 @@ + + + + + diff --git a/amms_front/src/views/tourist/tourist/index.vue b/amms_front/src/views/tourist/tourist/index.vue new file mode 100644 index 0000000..967d252 --- /dev/null +++ b/amms_front/src/views/tourist/tourist/index.vue @@ -0,0 +1,273 @@ + + + diff --git a/c32384beca854744bdf160dace5b3d79.jpg b/c32384beca854744bdf160dace5b3d79.jpg deleted file mode 100644 index 784fbbb..0000000 Binary files a/c32384beca854744bdf160dace5b3d79.jpg and /dev/null differ diff --git a/src/main/java/com/amms/controller/ItemCollectionController.java b/src/main/java/com/amms/controller/ItemCollectionController.java new file mode 100644 index 0000000..402e01c --- /dev/null +++ b/src/main/java/com/amms/controller/ItemCollectionController.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.ItemCollection; +import com.amms.service.IItemCollectionService; + +import java.util.List; + +/** + * 收藏Controller + */ +@RestController +@RequestMapping("/itemCollection") +public class ItemCollectionController { + + @Autowired + private IItemCollectionService itemCollectionService; + + /** + * 查询收藏列表 + */ + @GetMapping("/list") + public PageInfo list(ItemCollection itemCollection, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) { + PageHelper.startPage(pageNum, pageSize); + List itemCollections = itemCollectionService.selectItemCollectionList(itemCollection); + return new PageInfo(itemCollections); + } + + /** + * 查询全部收藏列表 + */ + @GetMapping("/listAll") + public List listAll(ItemCollection itemCollection) { + return itemCollectionService.selectItemCollectionList(itemCollection); + } + + /** + * 获取收藏详细信息 + */ + @GetMapping(value = "/info/{id}") + public Result getInfo(@PathVariable("id") Long id) { + return Result.success(itemCollectionService.selectItemCollectionById(id)); + } + + /** + * 新增收藏 + */ + @PostMapping("/add") + public Result add(@RequestBody ItemCollection itemCollection) { + return itemCollectionService.insertItemCollection(itemCollection) > 0 ? Result.success("新增成功") : Result.error("新增失败"); + } + + /** + * 修改收藏 + */ + @PutMapping + public Result update(@RequestBody ItemCollection itemCollection) { + return itemCollectionService.updateItemCollection(itemCollection) > 0 ? Result.success("修改成功") : Result.error("修改失败"); + } + + /** + * 删除收藏 + */ + @DeleteMapping("/{id}") + public Result delete(@PathVariable Long id) { + return itemCollectionService.deleteItemCollectionById(id) > 0 ? Result.success("删除成功") : Result.error("删除失败"); + } +} diff --git a/src/main/java/com/amms/domain/ItemCollection.java b/src/main/java/com/amms/domain/ItemCollection.java new file mode 100644 index 0000000..d34bb46 --- /dev/null +++ b/src/main/java/com/amms/domain/ItemCollection.java @@ -0,0 +1,71 @@ +package com.amms.domain; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 收藏对象 item_collection + */ +public class ItemCollection { + + /** 收藏id */ + private Long id; + + /** 用户id */ + private Long userId; + + /** 藏品id */ + private Long itemId; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Long getUserId() { + return userId; + } + + public void setItemId(Long itemId) { + this.itemId = itemId; + } + + public Long getItemId() { + return itemId; + } + + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return "ItemCollection{" + + "id=" + id + + ", userId=" + userId + + ", itemId=" + itemId + + ", createTime=" + createTime + + '}'; + } +} diff --git a/src/main/java/com/amms/mapper/ItemCollectionMapper.java b/src/main/java/com/amms/mapper/ItemCollectionMapper.java new file mode 100644 index 0000000..b3d15f6 --- /dev/null +++ b/src/main/java/com/amms/mapper/ItemCollectionMapper.java @@ -0,0 +1,52 @@ +package com.amms.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import com.amms.domain.ItemCollection; + +/** + * 收藏Mapper接口 + */ +@Mapper +public interface ItemCollectionMapper { + /** + * 查询收藏 + * + * @param id 收藏主键 + * @return 收藏 + */ + public ItemCollection selectItemCollectionById(Long id); + + /** + * 查询收藏列表 + * + * @param itemCollection 收藏 + * @return 收藏集合 + */ + public List selectItemCollectionList(ItemCollection itemCollection); + + /** + * 新增收藏 + * + * @param itemCollection 收藏 + * @return 结果 + */ + public int insertItemCollection(ItemCollection itemCollection); + + /** + * 修改收藏 + * + * @param itemCollection 收藏 + * @return 结果 + */ + public int updateItemCollection(ItemCollection itemCollection); + + /** + * 删除收藏 + * + * @param id 收藏主键 + * @return 结果 + */ + public int deleteItemCollectionById(Long id); + +} diff --git a/src/main/java/com/amms/security/JwtAuthenticationFilter.java b/src/main/java/com/amms/security/JwtAuthenticationFilter.java new file mode 100644 index 0000000..d4fd433 --- /dev/null +++ b/src/main/java/com/amms/security/JwtAuthenticationFilter.java @@ -0,0 +1,96 @@ +package com.amms.security; + +import com.amms.domain.SysUser; +import com.amms.domain.vo.Result; +import com.amms.util.JsonUtils; +import com.amms.util.RedisUtils; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.ExpiredJwtException; +import io.jsonwebtoken.SignatureException; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +@Component +public class JwtAuthenticationFilter extends OncePerRequestFilter { + + @Autowired + private JwtUtils jwtUtils; + + @Autowired + private RedisUtils redisUtils; + + @Value("${token.expireTime}") + private Long expireTime; + + /** + * @param request + * @param response + * @param filterChain + * @throws ServletException + * @throws IOException + */ + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + // 获取token + String token = request.getHeader("Authorization"); + // 没有token,即未登录,放行,交给下一步处理 + if(token == null) { + doFilter(request,response,filterChain); + return; + } + // 有token,通过jwt工具类,解析tokenId + Claims claims = null; + try { + claims = jwtUtils.parseToken(token); + } catch (SignatureException e){ + // 需要返回401,重新登陆 + response.getWriter().write("验签失败!!!"); + return; + } catch (ExpiredJwtException e) { + // 需要返回401,重新登陆 + Result result = Result.error(401, "登录失效,请重新登录!"); + + response.getWriter().write(JsonUtils.toJson(result)); + return; + } + // 在jwt中获取tokenId + String tokenId = claims.get("tokenId", String.class); + + if (tokenId == null) { + // 放行 + doFilter(request,response,filterChain); + } + + // 在redis中根据tokenId获取用户信息 + SysUser sysUser = redisUtils.get(tokenId, SysUser.class); + if (sysUser != null) { // 用户已登录 + // 将用户信息放到SecurityContext中 + UsernamePasswordAuthenticationToken authentication = + new UsernamePasswordAuthenticationToken(sysUser, null, null); + SecurityContextHolder.getContext().setAuthentication(authentication); + + // 重新将用户信息存储到redis中 + redisUtils.set(tokenId, sysUser, expireTime, TimeUnit.MINUTES); + + } else { // 用户登录失效 + // 需要返回401,重新登陆 + Result result = Result.error(401, "登录失效,请重新登录!"); + + response.getWriter().write(JsonUtils.toJson(result)); + return; + } + // 放行 + doFilter(request,response,filterChain); + } +} diff --git a/src/main/java/com/amms/security/JwtUtils.java b/src/main/java/com/amms/security/JwtUtils.java new file mode 100644 index 0000000..dedd904 --- /dev/null +++ b/src/main/java/com/amms/security/JwtUtils.java @@ -0,0 +1,42 @@ +package com.amms.security; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.Map; + +@Component +public class JwtUtils { + + @Value("${token.secret}") + private String secret; + + /** + * 生成token + */ + public String createToken(Map map) { + String token = Jwts.builder() + .setClaims(map) + .setIssuedAt(new Date()) + .setExpiration(new Date(System.currentTimeMillis() + 30 * 60 * 1000)) + .signWith(SignatureAlgorithm.HS256, secret) + .compact(); + return token; + } + + /** + * 根据token解析出用户信息 + */ + public Claims parseToken(String token) { + // 解析token,需要使用和创建token时相同的秘钥 + Claims claims = Jwts.parser().setSigningKey(secret) + .parseClaimsJws(token) + .getBody(); + return claims; + } + +} diff --git a/src/main/java/com/amms/service/IRelicService.java b/src/main/java/com/amms/service/IRelicService.java new file mode 100644 index 0000000..aa374b7 --- /dev/null +++ b/src/main/java/com/amms/service/IRelicService.java @@ -0,0 +1,49 @@ +package com.amms.service; + +import java.util.List; +import com.amms.domain.Relic; + +/** + * 藏品Service接口 + */ +public interface IRelicService { + /** + * 查询藏品列表 + * + * @param relic 藏品 + * @return 藏品集合 + */ + public List selectRelicList(Relic relic); + + /** + * 查询藏品 + * + * @param id 藏品主键 + * @return 藏品 + */ + public Relic selectRelicById(Long id); + + /** + * 新增藏品 + * + * @param relic 藏品 + * @return 结果 + */ + public int insertRelic(Relic relic); + + /** + * 修改藏品 + * + * @param relic 藏品 + * @return 结果 + */ + public int updateRelic(Relic relic); + + /** + * 删除藏品信息 + * + * @param id 藏品主键 + * @return 结果 + */ + public int deleteRelicById(Long id); +} diff --git a/src/main/java/com/amms/service/IReservationService.java b/src/main/java/com/amms/service/IReservationService.java new file mode 100644 index 0000000..3a0dba2 --- /dev/null +++ b/src/main/java/com/amms/service/IReservationService.java @@ -0,0 +1,75 @@ +package com.amms.service; + +import java.util.List; +import com.amms.domain.Reservation; + +/** + * 预约Service接口 + */ +public interface IReservationService { + /** + * 查询预约列表 + * + * @param reservation 预约 + * @return 预约集合 + */ + public List selectReservationList(Reservation reservation); + + /** + * 查询预约 + * + * @param id 预约主键 + * @return 预约 + */ + public Reservation selectReservationById(Long id); + + /** + * 新增预约 + * + * @param reservation 预约 + * @return 结果 + */ + public int insertReservation(Reservation reservation); + + /** + * 修改预约 + * + * @param reservation 预约 + * @return 结果 + */ + public int updateReservation(Reservation reservation); + + /** + * 删除预约信息 + * + * @param id 预约主键 + * @return 结果 + */ + public int deleteReservationById(Long id); + + /** + * 审核预约(通过/驳回)。 + * + * 审核通过时生成整单核验二维码(Reservation.qrCode)以及每位游客个人核验二维码(ReservationVisitor.visitorQrCode)。 + * + * @param reservation 预约(需包含 id、status、remark) + * @return 结果 + */ + public int auditReservation(Reservation reservation); + + /** + * 整单核验:将该预约下所有游客核验状态置为1。 + * + * @param reservationId 预约ID + * @return 更新条数 + */ + public int verifyAllVisitors(Long reservationId); + + /** + * 游客个人核验:将该游客核验状态置为1。 + * + * @param visitorId 游客ID + * @return 结果 + */ + public int verifyVisitor(Long visitorId); +} diff --git a/src/main/java/com/amms/service/IReservationTimeSlotService.java b/src/main/java/com/amms/service/IReservationTimeSlotService.java new file mode 100644 index 0000000..42361ee --- /dev/null +++ b/src/main/java/com/amms/service/IReservationTimeSlotService.java @@ -0,0 +1,55 @@ +package com.amms.service; + +import java.util.Date; +import java.util.List; +import com.amms.domain.ReservationTimeSlot; + +/** + * 预约时段Service接口 + */ +public interface IReservationTimeSlotService { + /** + * 查询预约时段列表 + * + * @param reservationTimeSlot 预约时段 + * @return 预约时段集合 + */ + public List selectReservationTimeSlotList(ReservationTimeSlot reservationTimeSlot); + + /** + * 查询预约时段 + * + * @param id 预约时段主键 + * @return 预约时段 + */ + public ReservationTimeSlot selectReservationTimeSlotById(Long id); + + /** + * 新增预约时段 + * + * @param reservationTimeSlot 预约时段 + * @return 结果 + */ + public int insertReservationTimeSlot(ReservationTimeSlot reservationTimeSlot); + + /** + * 修改预约时段 + * + * @param reservationTimeSlot 预约时段 + * @return 结果 + */ + public int updateReservationTimeSlot(ReservationTimeSlot reservationTimeSlot); + + /** + * 删除预约时段信息 + * + * @param id 预约时段主键 + * @return 结果 + */ + public int deleteReservationTimeSlotById(Long id); + + /** + * 批量新增预约时段(根据日期范围) + */ + public int batchInsertReservationTimeSlots(Date startDate, Date endDate, Date startTime, Date endTime, Integer maxPeople, Long status); +} diff --git a/src/main/java/com/amms/service/ITouristService.java b/src/main/java/com/amms/service/ITouristService.java new file mode 100644 index 0000000..b405bb6 --- /dev/null +++ b/src/main/java/com/amms/service/ITouristService.java @@ -0,0 +1,49 @@ +package com.amms.service; + +import java.util.List; +import com.amms.domain.Tourist; + +/** + * 普通用户子Service接口 + */ +public interface ITouristService { + /** + * 查询普通用户子列表 + * + * @param tourist 普通用户子 + * @return 普通用户子集合 + */ + public List selectTouristList(Tourist tourist); + + /** + * 查询普通用户子 + * + * @param id 普通用户子主键 + * @return 普通用户子 + */ + public Tourist selectTouristById(Long id); + + /** + * 新增普通用户子 + * + * @param tourist 普通用户子 + * @return 结果 + */ + public int insertTourist(Tourist tourist); + + /** + * 修改普通用户子 + * + * @param tourist 普通用户子 + * @return 结果 + */ + public int updateTourist(Tourist tourist); + + /** + * 删除普通用户子信息 + * + * @param id 普通用户子主键 + * @return 结果 + */ + public int deleteTouristById(Long id); +} diff --git a/src/main/java/com/amms/service/impl/ItemCategoryServiceImpl.java b/src/main/java/com/amms/service/impl/ItemCategoryServiceImpl.java new file mode 100644 index 0000000..9ed1523 --- /dev/null +++ b/src/main/java/com/amms/service/impl/ItemCategoryServiceImpl.java @@ -0,0 +1,80 @@ +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.ItemCategoryMapper; +import com.amms.domain.ItemCategory; +import com.amms.service.IItemCategoryService; +import com.amms.security.SecurityUtils; + +/** + * 藏品分类Service业务层处理 + */ +@Service +public class ItemCategoryServiceImpl implements IItemCategoryService { + + @Autowired + private ItemCategoryMapper itemCategoryMapper; + + /** + * 查询藏品分类列表 + * + * @param itemCategory 藏品分类 + * @return 藏品分类 + */ + @Override + public List selectItemCategoryList(ItemCategory itemCategory) { + return itemCategoryMapper.selectItemCategoryList(itemCategory); + } + + /** + * 查询藏品分类 + * + * @param id 藏品分类主键 + * @return 藏品分类 + */ + @Override + public ItemCategory selectItemCategoryById(Long id) { + return itemCategoryMapper.selectItemCategoryById(id); + } + + /** + * 新增藏品分类 + * + * @param itemCategory 藏品分类 + * @return 结果 + */ + @Override + public int insertItemCategory(ItemCategory itemCategory) { + itemCategory.setCreateTime(new Date()); + itemCategory.setCreator(SecurityUtils.getCurrentUser().getId()); + return itemCategoryMapper.insertItemCategory(itemCategory); + } + + /** + * 修改藏品分类 + * + * @param itemCategory 藏品分类 + * @return 结果 + */ + @Override + public int updateItemCategory(ItemCategory itemCategory) { + itemCategory.setUpdateTime(new Date()); + itemCategory.setUpdater(SecurityUtils.getCurrentUser().getId()); + return itemCategoryMapper.updateItemCategory(itemCategory); + } + + /** + * 删除藏品分类信息 + * + * @param id 藏品分类主键 + * @return 结果 + */ + @Override + public int deleteItemCategoryById(Long id) { + return itemCategoryMapper.deleteItemCategoryById(id); + } + +} diff --git a/src/main/java/com/amms/service/impl/ItemCollectionServiceImpl.java b/src/main/java/com/amms/service/impl/ItemCollectionServiceImpl.java new file mode 100644 index 0000000..cbdb004 --- /dev/null +++ b/src/main/java/com/amms/service/impl/ItemCollectionServiceImpl.java @@ -0,0 +1,79 @@ +package com.amms.service.impl; + +import java.util.List; +import java.util.Date; + +import com.amms.security.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.amms.mapper.ItemCollectionMapper; +import com.amms.domain.ItemCollection; +import com.amms.service.IItemCollectionService; + +/** + * 收藏Service业务层处理 + */ +@Service +public class ItemCollectionServiceImpl implements IItemCollectionService { + + @Autowired + private ItemCollectionMapper itemCollectionMapper; + + /** + * 查询收藏列表 + * + * @param itemCollection 收藏 + * @return 收藏 + */ + @Override + public List selectItemCollectionList(ItemCollection itemCollection) { + return itemCollectionMapper.selectItemCollectionList(itemCollection); + } + + /** + * 查询收藏 + * + * @param id 收藏主键 + * @return 收藏 + */ + @Override + public ItemCollection selectItemCollectionById(Long id) { + return itemCollectionMapper.selectItemCollectionById(id); + } + + /** + * 新增收藏 + * + * @param itemCollection 收藏 + * @return 结果 + */ + @Override + public int insertItemCollection(ItemCollection itemCollection) { + itemCollection.setUserId(SecurityUtils.getCurrentUser().getId()); + itemCollection.setCreateTime(new Date()); + return itemCollectionMapper.insertItemCollection(itemCollection); + } + + /** + * 修改收藏 + * + * @param itemCollection 收藏 + * @return 结果 + */ + @Override + public int updateItemCollection(ItemCollection itemCollection) { + return itemCollectionMapper.updateItemCollection(itemCollection); + } + + /** + * 删除收藏信息 + * + * @param id 收藏主键 + * @return 结果 + */ + @Override + public int deleteItemCollectionById(Long id) { + return itemCollectionMapper.deleteItemCollectionById(id); + } + +} diff --git a/src/main/java/com/amms/util/JsonUtils.java b/src/main/java/com/amms/util/JsonUtils.java new file mode 100644 index 0000000..c50c2de --- /dev/null +++ b/src/main/java/com/amms/util/JsonUtils.java @@ -0,0 +1,18 @@ +package com.amms.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JsonUtils { + + private static ObjectMapper objectMapper = new ObjectMapper(); + + public static String toJson(Object obj) throws JsonProcessingException { + return objectMapper.writeValueAsString(obj); + } + + public static T fromJson(String json, Class clazz) throws JsonProcessingException { + return objectMapper.readValue(json, clazz); + } + +} diff --git a/src/main/resources/mapper/ItemCollectionMapper.xml b/src/main/resources/mapper/ItemCollectionMapper.xml new file mode 100644 index 0000000..cf6bd3f --- /dev/null +++ b/src/main/resources/mapper/ItemCollectionMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + select id, user_id, item_id, create_time from item_collection + + + + + + + + insert into item_collection + + user_id, + item_id, + create_time, + + + #{userId}, + #{itemId}, + #{createTime}, + + + + + update item_collection + + user_id = #{userId}, + item_id = #{itemId}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from item_collection where id = #{id} + +