Commit cf23db8bef7a2534817987e1a46620cef8e2bf4c
1 parent
06425c69
提交
Showing
16 changed files
with
137 additions
and
6 deletions
trash-admin/src/main/resources/application-dev.yml
trash-framework/src/main/java/com/trash/framework/config/SecurityConfig.java
| ... | ... | @@ -98,7 +98,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter |
| 98 | 98 | // 过滤请求 |
| 99 | 99 | .authorizeRequests() |
| 100 | 100 | // 对于登录login 验证码captchaImage 允许匿名访问 |
| 101 | - .antMatchers("/login", "/captchaImage","/loginByToken").anonymous() | |
| 101 | + .antMatchers("/login", "/captchaImage","/loginByToken","/user/updatePassword").anonymous() | |
| 102 | 102 | .antMatchers( |
| 103 | 103 | HttpMethod.GET, |
| 104 | 104 | "/*.html", | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageOrderController.java
| ... | ... | @@ -4,6 +4,7 @@ package com.trash.garbage.controller; |
| 4 | 4 | import cn.hutool.core.convert.Convert; |
| 5 | 5 | import cn.hutool.http.HttpRequest; |
| 6 | 6 | import com.alibaba.fastjson.JSON; |
| 7 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 7 | 8 | import com.github.pagehelper.PageHelper; |
| 8 | 9 | import com.trash.carInfo.domain.vo.CarInfoVo; |
| 9 | 10 | import com.trash.common.annotation.Log; |
| ... | ... | @@ -27,13 +28,15 @@ import com.trash.garbage.custom.BizException; |
| 27 | 28 | import com.trash.garbage.global.Result; |
| 28 | 29 | import com.trash.garbage.global.ResultCode; |
| 29 | 30 | import com.trash.garbage.pojo.domain.GarOrder; |
| 31 | +import com.trash.garbage.pojo.domain.GarOrderMatchAsk; | |
| 32 | +import com.trash.garbage.pojo.domain.GarOrderMatchDisposal; | |
| 33 | +import com.trash.garbage.service.*; | |
| 30 | 34 | import com.trash.garbage.pojo.dto.*; |
| 31 | 35 | import com.trash.garbage.pojo.vo.GarOrderMatchAskVo; |
| 32 | 36 | import com.trash.garbage.pojo.vo.OrderDetailTransportVo; |
| 33 | 37 | import com.trash.garbage.pojo.vo.OrderDetailVo; |
| 34 | 38 | import com.trash.garbage.pojo.vo.ScanDriverDetailVo; |
| 35 | -import com.trash.garbage.service.GarOrderService; | |
| 36 | -import com.trash.garbage.service.GarUserService; | |
| 39 | +import com.trash.garbage.service.impl.GarAddressServiceImpl; | |
| 37 | 40 | import lombok.extern.slf4j.Slf4j; |
| 38 | 41 | import org.apache.commons.lang3.ArrayUtils; |
| 39 | 42 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -64,9 +67,11 @@ public class GarbageOrderController { |
| 64 | 67 | @Autowired |
| 65 | 68 | private TokenService tokenService; |
| 66 | 69 | @Autowired |
| 67 | - private GarUserService garUserService; | |
| 70 | + private GarOrderMatchAskService garOrderMatchAskService; | |
| 68 | 71 | |
| 69 | 72 | private final static Integer[] USER_TYP_SELF_COMPANY = {2, 3}; |
| 73 | + @Autowired | |
| 74 | + private GarAddressService garAddressService; | |
| 70 | 75 | |
| 71 | 76 | @PostMapping("/add") |
| 72 | 77 | @Log(title = "创建订单", businessType = BusinessType.INSERT) |
| ... | ... | @@ -156,6 +161,26 @@ public class GarbageOrderController { |
| 156 | 161 | return Result.OK(garOrderService.checkValidCode(validCode)); |
| 157 | 162 | } |
| 158 | 163 | |
| 164 | + | |
| 165 | + @GetMapping("/queryGarOrderMatchAsk/{orderId}") | |
| 166 | + public Result<Integer> queryGarOrderMatchAsk(@PathVariable String orderId) { | |
| 167 | + return Result.OK(garOrderMatchAskService.queryGarOrderMatchAsk(orderId)); | |
| 168 | + } | |
| 169 | + | |
| 170 | + @GetMapping("/querySiteByTel") | |
| 171 | + public Result<List<SiteInfoDTO>> querySiteByTel() { | |
| 172 | + // 获取登录用户手机号 | |
| 173 | + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |
| 174 | + if (loginUser == null || loginUser.getUser() == null) { | |
| 175 | + return null; | |
| 176 | + } | |
| 177 | + String phoneNumber = loginUser.getUser().getPhonenumber(); | |
| 178 | + | |
| 179 | + // 使用手机号查询 | |
| 180 | + List<SiteInfoDTO> siteInfoDTO = garAddressService.querySiteByTel(phoneNumber); | |
| 181 | + return Result.OK(siteInfoDTO); | |
| 182 | + } | |
| 183 | + | |
| 159 | 184 | @GetMapping("/query/list") |
| 160 | 185 | public Result<?> queryOrderList(@RequestParam("type") Integer type, |
| 161 | 186 | @RequestParam(value = "evaluateFlag", required = false) Integer evaluateFlag, | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageUserController.java
| ... | ... | @@ -47,6 +47,14 @@ public class GarbageUserController { |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | + * 修改密码 | |
| 51 | + */ | |
| 52 | + @PostMapping("/updatePassword") | |
| 53 | + public Result<String> updatePassword(@RequestBody LoginDto loginDto) { | |
| 54 | + return Result.OK(garUserService.updatePassword(loginDto)); | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 50 | 58 | * 退出登录 |
| 51 | 59 | * |
| 52 | 60 | * @param | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarAddressMapper.java
| ... | ... | @@ -2,7 +2,12 @@ package com.trash.garbage.mapper; |
| 2 | 2 | |
| 3 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | 4 | import com.trash.garbage.pojo.domain.GarAddress; |
| 5 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | |
| 5 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 7 | +import org.apache.ibatis.annotations.Param; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | +import java.util.Map; | |
| 6 | 11 | |
| 7 | 12 | /** |
| 8 | 13 | * @author 20412 |
| ... | ... | @@ -12,6 +17,8 @@ import org.apache.ibatis.annotations.Mapper; |
| 12 | 17 | */ |
| 13 | 18 | public interface GarAddressMapper extends BaseMapper<GarAddress> { |
| 14 | 19 | |
| 20 | + List<SiteInfoDTO> querySiteByTel(@Param("tel") String tel); | |
| 21 | + | |
| 15 | 22 | } |
| 16 | 23 | |
| 17 | 24 | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderMatchAskMapper.java
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/LoginDto.java
| 1 | 1 | package com.trash.garbage.pojo.dto; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 3 | 4 | import lombok.Data; |
| 4 | 5 | import lombok.EqualsAndHashCode; |
| 5 | 6 | import lombok.ToString; |
| ... | ... | @@ -19,6 +20,29 @@ public class LoginDto { |
| 19 | 20 | private String iv; |
| 20 | 21 | private String password; |
| 21 | 22 | private int signin; |
| 23 | + | |
| 24 | + @TableField(exist = false) | |
| 25 | + private String oldPassword; | |
| 26 | + | |
| 27 | + @TableField(exist = false) | |
| 28 | + private String newPassword; | |
| 29 | + | |
| 30 | + public String getNewPassword() { | |
| 31 | + return newPassword; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setNewPassword(String newPassword) { | |
| 35 | + this.newPassword = newPassword; | |
| 36 | + } | |
| 37 | + | |
| 38 | + | |
| 39 | + public String getOldPassword() { | |
| 40 | + return oldPassword; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setOldPassword(String oldPassword) { | |
| 44 | + this.oldPassword = oldPassword; | |
| 45 | + } | |
| 22 | 46 | |
| 23 | 47 | public int getSignin() { |
| 24 | 48 | return signin; | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/SiteInfoDTO.java
0 → 100644
trash-garbage/src/main/java/com/trash/garbage/service/GarAddressService.java
| ... | ... | @@ -2,6 +2,9 @@ package com.trash.garbage.service; |
| 2 | 2 | |
| 3 | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
| 4 | 4 | import com.trash.garbage.pojo.domain.GarAddress; |
| 5 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 5 | 8 | |
| 6 | 9 | /** |
| 7 | 10 | * @author 20412 |
| ... | ... | @@ -9,5 +12,5 @@ import com.trash.garbage.pojo.domain.GarAddress; |
| 9 | 12 | * @createDate 2023-11-22 09:48:43 |
| 10 | 13 | */ |
| 11 | 14 | public interface GarAddressService extends IService<GarAddress> { |
| 12 | - | |
| 15 | + List<SiteInfoDTO> querySiteByTel(String tel); | |
| 13 | 16 | } | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderMatchAskService.java
trash-garbage/src/main/java/com/trash/garbage/service/GarUserService.java
| ... | ... | @@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.extension.service.IService; |
| 8 | 8 | import com.trash.garbage.pojo.domain.GarUserReq; |
| 9 | 9 | import com.trash.garbage.pojo.dto.AddressDto; |
| 10 | 10 | import com.trash.garbage.pojo.dto.LoginDto; |
| 11 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | |
| 11 | 12 | import com.trash.garbage.pojo.vo.LoginVo; |
| 13 | +import org.apache.ibatis.annotations.Param; | |
| 12 | 14 | |
| 13 | 15 | import javax.servlet.http.HttpServletRequest; |
| 14 | 16 | import java.util.List; |
| ... | ... | @@ -48,5 +50,7 @@ public interface GarUserService extends IService<GarUser> { |
| 48 | 50 | |
| 49 | 51 | GarUserReq reqGarUser(String phone); |
| 50 | 52 | |
| 53 | + String updatePassword(LoginDto loginDto); | |
| 54 | + | |
| 51 | 55 | |
| 52 | 56 | } | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarAddressServiceImpl.java
| ... | ... | @@ -3,9 +3,13 @@ package com.trash.garbage.service.impl; |
| 3 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 4 | 4 | import com.trash.garbage.mapper.GarAddressMapper; |
| 5 | 5 | import com.trash.garbage.pojo.domain.GarAddress; |
| 6 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | |
| 6 | 7 | import com.trash.garbage.service.GarAddressService; |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | 9 | import org.springframework.stereotype.Service; |
| 8 | 10 | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 9 | 13 | /** |
| 10 | 14 | * @author 20412 |
| 11 | 15 | * @description 针对表【gar_address(建筑垃圾-用户地址)】的数据库操作Service实现 |
| ... | ... | @@ -15,6 +19,13 @@ import org.springframework.stereotype.Service; |
| 15 | 19 | public class GarAddressServiceImpl extends ServiceImpl<GarAddressMapper, GarAddress> |
| 16 | 20 | implements GarAddressService { |
| 17 | 21 | |
| 22 | + @Autowired | |
| 23 | + GarAddressMapper garAddressMapper; | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public List<SiteInfoDTO> querySiteByTel(String tel) { | |
| 27 | + return garAddressMapper.querySiteByTel(tel); | |
| 28 | + } | |
| 18 | 29 | } |
| 19 | 30 | |
| 20 | 31 | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderMatchAskServiceImpl.java
| ... | ... | @@ -115,6 +115,11 @@ public class GarOrderMatchAskServiceImpl extends ServiceImpl<GarOrderMatchAskMap |
| 115 | 115 | { |
| 116 | 116 | return garOrderMatchAskMapper.deleteGarOrderMatchAskById(garId); |
| 117 | 117 | } |
| 118 | + | |
| 119 | + @Override | |
| 120 | + public int queryGarOrderMatchAsk(String orderId) { | |
| 121 | + return garOrderMatchAskMapper.queryGarOrderMatchAsk(orderId); | |
| 122 | + } | |
| 118 | 123 | } |
| 119 | 124 | |
| 120 | 125 | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarUserServiceImpl.java
| ... | ... | @@ -258,6 +258,29 @@ public class GarUserServiceImpl extends ServiceImpl<GarUserMapper, GarUser> |
| 258 | 258 | this.saveOrUpdate(nUser); |
| 259 | 259 | return vo; |
| 260 | 260 | } |
| 261 | + @Override | |
| 262 | + public String updatePassword(LoginDto loginDto) { | |
| 263 | + QueryWrapper<GarUser> qw = new QueryWrapper<>(); | |
| 264 | + qw.lambda().eq(GarUser::getGarUserTel, loginDto.getTel()); | |
| 265 | + GarUser user = this.getOne(qw); | |
| 266 | + | |
| 267 | + if (Objects.isNull(user)) { | |
| 268 | + throw new UsernameNotFoundException("当前用户不存在!"); | |
| 269 | + } | |
| 270 | + | |
| 271 | + if (!new BCryptPasswordEncoder().matches(loginDto.getOldPassword(), user.getPassword())) { | |
| 272 | + throw new BizException(ResultCode.CODE_400, "原密码错误!"); | |
| 273 | + } | |
| 274 | + | |
| 275 | + LambdaUpdateWrapper<GarUser> updateWrapper = new LambdaUpdateWrapper<>(); | |
| 276 | + updateWrapper.eq(GarUser::getGarUserId, user.getGarUserId()) | |
| 277 | + .set(GarUser::getPassword, new BCryptPasswordEncoder().encode(loginDto.getNewPassword())); | |
| 278 | + | |
| 279 | + this.update(updateWrapper); | |
| 280 | + | |
| 281 | + return "密码修改成功!"; | |
| 282 | + } | |
| 283 | + | |
| 261 | 284 | |
| 262 | 285 | @Override |
| 263 | 286 | public String sendVerify(String tel) throws ClientException { | ... | ... |
trash-garbage/src/main/resources/mapper/GarAddressMapper.xml
| ... | ... | @@ -21,4 +21,8 @@ |
| 21 | 21 | gar_user_default,gar_create_time,gar_update_time, |
| 22 | 22 | gar_user_contact_name,gar_user_contact_tel,gar_remark |
| 23 | 23 | </sql> |
| 24 | + | |
| 25 | + <select id="querySiteByTel" resultType="com.trash.garbage.pojo.dto.SiteInfoDTO"> | |
| 26 | + select gar_longitude,gar_latitude from gar_address where gar_user_contact_tel=#{tel} | |
| 27 | + </select> | |
| 24 | 28 | </mapper> | ... | ... |
trash-garbage/src/main/resources/mapper/GarOrderMatchAskMapper.xml
| ... | ... | @@ -194,4 +194,8 @@ |
| 194 | 194 | </foreach> |
| 195 | 195 | </delete> |
| 196 | 196 | |
| 197 | + <select id="queryGarOrderMatchAsk" resultType="java.lang.Integer"> | |
| 198 | + select COUNT(*) from gar_order_match_ask where gar_order_id = #{orderId} and transport_distance is not null | |
| 199 | + </select> | |
| 200 | + | |
| 197 | 201 | </mapper> | ... | ... |