123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- package com.bofeng.service;
- import com.baomidou.mybatisplus.toolkit.IdWorker;
- import com.bofeng.dao.ShShopMapper;
- import com.bofeng.dao.ShShopMatMapper;
- import com.bofeng.entity.ShShopMat;
- import lombok.var;
- import org.joda.time.DateTime;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Propagation;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.List;
- @Service
- @Transactional(readOnly = true)
- public class ShShopMatService {
- @Autowired
- private ShShopMapper shShopMapper;
- @Autowired
- private ShShopMatMapper shShopMatMapper;
- // public List<QzTask> selectAll () {
- // return qzTaskDao.selectAll();
- // }
- //
- // public List<QzTask> queryByHouseNumber (String houseNumber, Integer status) {
- // return qzTaskDao.queryByHouseNumber(houseNumber, status);
- // }
- //
- // public QzTask queryByTaskId (Long taskId) {
- // return qzTaskDao.queryByTaskId(taskId);
- // }
- //商品的新增
- @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
- public int addShShopMat(Long userId, String matName, Integer matNum) throws Exception {
- DateTime dateTime = new DateTime();
- var shShopDb = shShopMapper.selectById(userId);
- if (null == shShopDb) {
- throw new Exception("发布失败");
- }
- var mat = new ShShopMat();
- mat.setMatId(IdWorker.getId());
- mat.setShopId(shShopDb.getShopId());
- mat.setMatName(matName);
- mat.setMatNum(matNum);
- mat.setStatus(1);
- /*long userId = Long.parseLong(JwtHelper.getUserId());
- qzTak.setUserId(userId);
- qzTak.setUserCreate(userId);*/
- mat.setTimeCreate(dateTime);
- /* qzTak.setUserUpdate(userId);*/
- mat.setTimeUpdate(dateTime);
- return shShopMatMapper.insert(mat);
- }
- //商品的修改
- @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
- public int editShShopMat(Long matId, String matName, Integer matNum) throws Exception {
- DateTime dateTime = new DateTime();
- // var shShopDb = shShopMapper.selectById(userId);
- // if (null == shShopDb) {
- // throw new Exception("发布失败");
- // }
- var shShopMatDb = shShopMatMapper.selectById(matId);
- if (null == shShopMatDb) {
- throw new Exception("修改失败");
- }
- shShopMatDb.setMatName(matName);
- shShopMatDb.setMatNum(matNum);
- shShopMatDb.setStatus(1);
- /*long userId = Long.parseLong(JwtHelper.getUserId());
- qzTak.setUserId(userId);
- qzTak.setUserCreate(userId);*/
- // mat.setTimeCreate(dateTime);
- /* qzTak.setUserUpdate(userId);*/
- shShopMatDb.setTimeUpdate(dateTime);
- return shShopMatMapper.updateById(shShopMatDb);
- }
- //商品的置顶2、下架0修改
- @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
- public int editShShopMatStatus(Long matId, Integer status) throws Exception {
- DateTime dateTime = new DateTime();
- // var shShopDb = shShopMapper.selectById(userId);
- // if (null == shShopDb) {
- // throw new Exception("发布失败");
- // }
- var shShopMatDb = shShopMatMapper.selectById(matId);
- if (null == shShopMatDb) {
- throw new Exception("修改失败");
- }
- shShopMatDb.setStatus(status);
- /*long userId = Long.parseLong(JwtHelper.getUserId());
- qzTak.setUserId(userId);
- qzTak.setUserCreate(userId);*/
- // mat.setTimeCreate(dateTime);
- /* qzTak.setUserUpdate(userId);*/
- shShopMatDb.setTimeUpdate(dateTime);
- return shShopMatMapper.updateById(shShopMatDb);
- }
- public List<ShShopMat> queryMyShShopMat(Long userId) throws Exception {
- var shShopDb = shShopMapper.selectById(userId);
- if (null == shShopDb) {
- throw new Exception("获取失败");
- }
- return shShopMatMapper.queryMyShShopMat(shShopDb.getShopId());
- }
- public List<ShShopMat> queryAllShShopMat() throws Exception {
- return shShopMatMapper.queryAllShShopMat();
- }
- }
|