| | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.TBoard; |
| | | import com.ruoyi.system.domain.TShop; |
| | |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static com.ruoyi.common.core.domain.AjaxResult.error; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @ApiOperation( value = "添加店铺信息") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<String> add(@RequestBody TShopDTO dto) { |
| | | SysUser user = new SysUser(); |
| | | user.setUserName(dto.getAccount()); |
| | | user.setPhonenumber(dto.getAccount()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | shopService.save(dto); |
| | | // 添加账号 |
| | | userService.addAccount(dto); |
| | | Long userId = userService.addAccount(dto); |
| | | dto.setUserId(userId); |
| | | shopService.updateById(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | @ApiOperation( value = "编辑店铺信息") |
| | | @PostMapping(value = "/edit") |
| | | public AjaxResult<String> edit(@RequestBody TShopDTO dto) { |
| | | SysUser user = new SysUser(); |
| | | user.setUserName(dto.getAccount()); |
| | | user.setPhonenumber(dto.getAccount()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | shopService.updateById(dto); |
| | | userService.updateAccount(dto); |
| | | return AjaxResult.success(); |
| | |
| | | public AjaxResult<TShop> getDetailByUserId() { |
| | | Integer roleType = tokenService.getLoginUser().getRoleType(); |
| | | if(roleType == 1){ |
| | | return AjaxResult.error("该用户不是商家账号"); |
| | | return error("该用户不是商家账号"); |
| | | } |
| | | return AjaxResult.success(shopService.getOne(Wrappers.<TShop>lambdaQuery().eq(TShop::getUserId, tokenService.getLoginUser().getUserId()) |
| | | .last("LIMIT 1"))); |