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,7 +98,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter | ||
| 98 | // 过滤请求 | 98 | // 过滤请求 |
| 99 | .authorizeRequests() | 99 | .authorizeRequests() |
| 100 | // 对于登录login 验证码captchaImage 允许匿名访问 | 100 | // 对于登录login 验证码captchaImage 允许匿名访问 |
| 101 | - .antMatchers("/login", "/captchaImage","/loginByToken").anonymous() | 101 | + .antMatchers("/login", "/captchaImage","/loginByToken","/user/updatePassword").anonymous() |
| 102 | .antMatchers( | 102 | .antMatchers( |
| 103 | HttpMethod.GET, | 103 | HttpMethod.GET, |
| 104 | "/*.html", | 104 | "/*.html", |
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageOrderController.java
| @@ -4,6 +4,7 @@ package com.trash.garbage.controller; | @@ -4,6 +4,7 @@ package com.trash.garbage.controller; | ||
| 4 | import cn.hutool.core.convert.Convert; | 4 | import cn.hutool.core.convert.Convert; |
| 5 | import cn.hutool.http.HttpRequest; | 5 | import cn.hutool.http.HttpRequest; |
| 6 | import com.alibaba.fastjson.JSON; | 6 | import com.alibaba.fastjson.JSON; |
| 7 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 7 | import com.github.pagehelper.PageHelper; | 8 | import com.github.pagehelper.PageHelper; |
| 8 | import com.trash.carInfo.domain.vo.CarInfoVo; | 9 | import com.trash.carInfo.domain.vo.CarInfoVo; |
| 9 | import com.trash.common.annotation.Log; | 10 | import com.trash.common.annotation.Log; |
| @@ -27,13 +28,15 @@ import com.trash.garbage.custom.BizException; | @@ -27,13 +28,15 @@ import com.trash.garbage.custom.BizException; | ||
| 27 | import com.trash.garbage.global.Result; | 28 | import com.trash.garbage.global.Result; |
| 28 | import com.trash.garbage.global.ResultCode; | 29 | import com.trash.garbage.global.ResultCode; |
| 29 | import com.trash.garbage.pojo.domain.GarOrder; | 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 | import com.trash.garbage.pojo.dto.*; | 34 | import com.trash.garbage.pojo.dto.*; |
| 31 | import com.trash.garbage.pojo.vo.GarOrderMatchAskVo; | 35 | import com.trash.garbage.pojo.vo.GarOrderMatchAskVo; |
| 32 | import com.trash.garbage.pojo.vo.OrderDetailTransportVo; | 36 | import com.trash.garbage.pojo.vo.OrderDetailTransportVo; |
| 33 | import com.trash.garbage.pojo.vo.OrderDetailVo; | 37 | import com.trash.garbage.pojo.vo.OrderDetailVo; |
| 34 | import com.trash.garbage.pojo.vo.ScanDriverDetailVo; | 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 | import lombok.extern.slf4j.Slf4j; | 40 | import lombok.extern.slf4j.Slf4j; |
| 38 | import org.apache.commons.lang3.ArrayUtils; | 41 | import org.apache.commons.lang3.ArrayUtils; |
| 39 | import org.springframework.beans.factory.annotation.Autowired; | 42 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -64,9 +67,11 @@ public class GarbageOrderController { | @@ -64,9 +67,11 @@ public class GarbageOrderController { | ||
| 64 | @Autowired | 67 | @Autowired |
| 65 | private TokenService tokenService; | 68 | private TokenService tokenService; |
| 66 | @Autowired | 69 | @Autowired |
| 67 | - private GarUserService garUserService; | 70 | + private GarOrderMatchAskService garOrderMatchAskService; |
| 68 | 71 | ||
| 69 | private final static Integer[] USER_TYP_SELF_COMPANY = {2, 3}; | 72 | private final static Integer[] USER_TYP_SELF_COMPANY = {2, 3}; |
| 73 | + @Autowired | ||
| 74 | + private GarAddressService garAddressService; | ||
| 70 | 75 | ||
| 71 | @PostMapping("/add") | 76 | @PostMapping("/add") |
| 72 | @Log(title = "创建订单", businessType = BusinessType.INSERT) | 77 | @Log(title = "创建订单", businessType = BusinessType.INSERT) |
| @@ -156,6 +161,26 @@ public class GarbageOrderController { | @@ -156,6 +161,26 @@ public class GarbageOrderController { | ||
| 156 | return Result.OK(garOrderService.checkValidCode(validCode)); | 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 | @GetMapping("/query/list") | 184 | @GetMapping("/query/list") |
| 160 | public Result<?> queryOrderList(@RequestParam("type") Integer type, | 185 | public Result<?> queryOrderList(@RequestParam("type") Integer type, |
| 161 | @RequestParam(value = "evaluateFlag", required = false) Integer evaluateFlag, | 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,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 | * @param | 60 | * @param |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarAddressMapper.java
| @@ -2,7 +2,12 @@ package com.trash.garbage.mapper; | @@ -2,7 +2,12 @@ package com.trash.garbage.mapper; | ||
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | import com.trash.garbage.pojo.domain.GarAddress; | 4 | import com.trash.garbage.pojo.domain.GarAddress; |
| 5 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | ||
| 5 | import org.apache.ibatis.annotations.Mapper; | 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 | * @author 20412 | 13 | * @author 20412 |
| @@ -12,6 +17,8 @@ import org.apache.ibatis.annotations.Mapper; | @@ -12,6 +17,8 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 12 | */ | 17 | */ |
| 13 | public interface GarAddressMapper extends BaseMapper<GarAddress> { | 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
| @@ -62,6 +62,8 @@ public interface GarOrderMatchAskMapper extends BaseMapper<GarOrderMatchAsk> { | @@ -62,6 +62,8 @@ public interface GarOrderMatchAskMapper extends BaseMapper<GarOrderMatchAsk> { | ||
| 62 | * @return 结果 | 62 | * @return 结果 |
| 63 | */ | 63 | */ |
| 64 | int deleteGarOrderMatchAskByIds(String[] garIds); | 64 | int deleteGarOrderMatchAskByIds(String[] garIds); |
| 65 | + | ||
| 66 | + int queryGarOrderMatchAsk(String orderId); | ||
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | 69 |
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/LoginDto.java
| 1 | package com.trash.garbage.pojo.dto; | 1 | package com.trash.garbage.pojo.dto; |
| 2 | 2 | ||
| 3 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 3 | import lombok.Data; | 4 | import lombok.Data; |
| 4 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| 5 | import lombok.ToString; | 6 | import lombok.ToString; |
| @@ -19,6 +20,29 @@ public class LoginDto { | @@ -19,6 +20,29 @@ public class LoginDto { | ||
| 19 | private String iv; | 20 | private String iv; |
| 20 | private String password; | 21 | private String password; |
| 21 | private int signin; | 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 | public int getSignin() { | 47 | public int getSignin() { |
| 24 | return signin; | 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,6 +2,9 @@ package com.trash.garbage.service; | ||
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.extension.service.IService; | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
| 4 | import com.trash.garbage.pojo.domain.GarAddress; | 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 | * @author 20412 | 10 | * @author 20412 |
| @@ -9,5 +12,5 @@ import com.trash.garbage.pojo.domain.GarAddress; | @@ -9,5 +12,5 @@ import com.trash.garbage.pojo.domain.GarAddress; | ||
| 9 | * @createDate 2023-11-22 09:48:43 | 12 | * @createDate 2023-11-22 09:48:43 |
| 10 | */ | 13 | */ |
| 11 | public interface GarAddressService extends IService<GarAddress> { | 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
| @@ -61,4 +61,6 @@ public interface GarOrderMatchAskService extends IService<GarOrderMatchAsk> { | @@ -61,4 +61,6 @@ public interface GarOrderMatchAskService extends IService<GarOrderMatchAsk> { | ||
| 61 | * @return 结果 | 61 | * @return 结果 |
| 62 | */ | 62 | */ |
| 63 | int deleteGarOrderMatchAskById(String garId); | 63 | int deleteGarOrderMatchAskById(String garId); |
| 64 | + | ||
| 65 | + int queryGarOrderMatchAsk(String orderId); | ||
| 64 | } | 66 | } |
trash-garbage/src/main/java/com/trash/garbage/service/GarUserService.java
| @@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.extension.service.IService; | @@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.extension.service.IService; | ||
| 8 | import com.trash.garbage.pojo.domain.GarUserReq; | 8 | import com.trash.garbage.pojo.domain.GarUserReq; |
| 9 | import com.trash.garbage.pojo.dto.AddressDto; | 9 | import com.trash.garbage.pojo.dto.AddressDto; |
| 10 | import com.trash.garbage.pojo.dto.LoginDto; | 10 | import com.trash.garbage.pojo.dto.LoginDto; |
| 11 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | ||
| 11 | import com.trash.garbage.pojo.vo.LoginVo; | 12 | import com.trash.garbage.pojo.vo.LoginVo; |
| 13 | +import org.apache.ibatis.annotations.Param; | ||
| 12 | 14 | ||
| 13 | import javax.servlet.http.HttpServletRequest; | 15 | import javax.servlet.http.HttpServletRequest; |
| 14 | import java.util.List; | 16 | import java.util.List; |
| @@ -48,5 +50,7 @@ public interface GarUserService extends IService<GarUser> { | @@ -48,5 +50,7 @@ public interface GarUserService extends IService<GarUser> { | ||
| 48 | 50 | ||
| 49 | GarUserReq reqGarUser(String phone); | 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,9 +3,13 @@ package com.trash.garbage.service.impl; | ||
| 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 4 | import com.trash.garbage.mapper.GarAddressMapper; | 4 | import com.trash.garbage.mapper.GarAddressMapper; |
| 5 | import com.trash.garbage.pojo.domain.GarAddress; | 5 | import com.trash.garbage.pojo.domain.GarAddress; |
| 6 | +import com.trash.garbage.pojo.dto.SiteInfoDTO; | ||
| 6 | import com.trash.garbage.service.GarAddressService; | 7 | import com.trash.garbage.service.GarAddressService; |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| 8 | 10 | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 9 | /** | 13 | /** |
| 10 | * @author 20412 | 14 | * @author 20412 |
| 11 | * @description 针对表【gar_address(建筑垃圾-用户地址)】的数据库操作Service实现 | 15 | * @description 针对表【gar_address(建筑垃圾-用户地址)】的数据库操作Service实现 |
| @@ -15,6 +19,13 @@ import org.springframework.stereotype.Service; | @@ -15,6 +19,13 @@ import org.springframework.stereotype.Service; | ||
| 15 | public class GarAddressServiceImpl extends ServiceImpl<GarAddressMapper, GarAddress> | 19 | public class GarAddressServiceImpl extends ServiceImpl<GarAddressMapper, GarAddress> |
| 16 | implements GarAddressService { | 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,6 +115,11 @@ public class GarOrderMatchAskServiceImpl extends ServiceImpl<GarOrderMatchAskMap | ||
| 115 | { | 115 | { |
| 116 | return garOrderMatchAskMapper.deleteGarOrderMatchAskById(garId); | 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,6 +258,29 @@ public class GarUserServiceImpl extends ServiceImpl<GarUserMapper, GarUser> | ||
| 258 | this.saveOrUpdate(nUser); | 258 | this.saveOrUpdate(nUser); |
| 259 | return vo; | 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 | @Override | 285 | @Override |
| 263 | public String sendVerify(String tel) throws ClientException { | 286 | public String sendVerify(String tel) throws ClientException { |
trash-garbage/src/main/resources/mapper/GarAddressMapper.xml
| @@ -21,4 +21,8 @@ | @@ -21,4 +21,8 @@ | ||
| 21 | gar_user_default,gar_create_time,gar_update_time, | 21 | gar_user_default,gar_create_time,gar_update_time, |
| 22 | gar_user_contact_name,gar_user_contact_tel,gar_remark | 22 | gar_user_contact_name,gar_user_contact_tel,gar_remark |
| 23 | </sql> | 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 | </mapper> | 28 | </mapper> |
trash-garbage/src/main/resources/mapper/GarOrderMatchAskMapper.xml
| @@ -194,4 +194,8 @@ | @@ -194,4 +194,8 @@ | ||
| 194 | </foreach> | 194 | </foreach> |
| 195 | </delete> | 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 | </mapper> | 201 | </mapper> |