添加活动

This commit is contained in:
wangguocheng 2024-05-20 15:05:52 +08:00
parent 7701f0423f
commit 0e35116e9d
4 changed files with 41 additions and 8 deletions

View File

@ -11,10 +11,10 @@ import java.math.BigDecimal;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("tb_user_storage")
@TableName("tb_activate")
public class Activate extends Model<Activate> {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
@TableId(type = IdType.AUTO)
private Integer id;
private Integer shopId;
private Integer minNum;

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.mybatis.rest;
import cn.ysk.cashier.mybatis.entity.Activate;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.annotation.Log;
@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequiredArgsConstructor
@Api(tags = "/shop/storage")
@RequestMapping("/api/storage")
@RequestMapping("/shop/storage")
public class StorageController {
@Autowired
private ShopService shopService;
@ -37,4 +38,15 @@ public class StorageController {
shopService.inStorage(storageVo,userName);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/findActivate")
public ResponseEntity<Object> findActivate(@RequestParam String shopId){
String userName = SecurityUtils.getCurrentUsername();
return new ResponseEntity<>(shopService.findActivate(shopId), HttpStatus.OK);
}
@PostMapping("/modityActivate")
public ResponseEntity<Object> modityActivate(@RequestBody Activate activate){
String userName = SecurityUtils.getCurrentUsername();
shopService.modityActivate(activate);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -15,6 +15,7 @@
*/
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.mybatis.entity.StorageVo;
import org.springframework.data.domain.Pageable;
@ -31,4 +32,8 @@ public interface ShopService {
void inStorage(StorageVo storageVo, String userName);
Object findActivate(String shopId);
void modityActivate(Activate activate);
}

View File

@ -15,6 +15,8 @@
*/
package cn.ysk.cashier.mybatis.service.impl;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.mybatis.mapper.*;
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -22,10 +24,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.ysk.cashier.exception.NewBadRequestException;
import cn.ysk.cashier.mybatis.entity.StorageVo;
import cn.ysk.cashier.mybatis.entity.TbUserStorage;
import cn.ysk.cashier.mybatis.mapper.TbMerchantAccountMapper;
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
import cn.ysk.cashier.mybatis.mapper.TbProductMapper;
import cn.ysk.cashier.mybatis.mapper.TbUserStorageMapper;
import cn.ysk.cashier.mybatis.service.ShopService;
import cn.ysk.cashier.utils.*;
import org.apache.commons.lang3.StringUtils;
@ -51,7 +49,7 @@ public class ShopServiceImpl implements ShopService {
@Autowired
private TbProducSkutMapper producSkutMapper;
@Autowired
private TbProductMapper productMapper;
private ActivateMapper activateMapper;
@Override
public Object findStorage(Integer shopId, String account, Pageable pageable) {
QueryWrapper<TbUserStorage> queryWrapper = new QueryWrapper<>();
@ -119,4 +117,22 @@ public class ShopServiceImpl implements ShopService {
userStorageMapper.insert(userStorage);
}
}
@Override
public Object findActivate(String shopId) {
QueryWrapper<Activate> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("shop_id",shopId);
queryWrapper.orderByDesc("id");
List<Activate> list = activateMapper.selectList(queryWrapper);
return list;
}
@Override
public void modityActivate(Activate activate) {
if (Objects.nonNull(activate.getId()) && activate.getId() > 0){
activateMapper.updateById(activate);
}else {
activateMapper.insert(activate);
}
}
}