123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package com.hssx.cloudmodel.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.hssx.cloudmodel.entity.Mould;
- import com.hssx.cloudmodel.entity.User;
- import com.hssx.cloudmodel.mapper.MouldMapper;
- import com.hssx.cloudmodel.service.MouldService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.hssx.cloudmodel.util.HttpRespMsg;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author 吴涛涛
- * @since 2019-07-30
- */
- @Service
- public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements MouldService {
- @Resource
- MouldMapper mouldMapper;
- @Override
- public HttpRespMsg addAndUpdateMould(Mould mould, User user) {
- HttpRespMsg msg = new HttpRespMsg();
- if(mould.getId() != null){
- //修改
- Mould m = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
- if((m != null && m.getId()==mould.getId()) || m == null){
- mouldMapper.updateById(mould);
- }else{
- msg.setError("当前模具编号已存在,请重新输入其他模具编号");
- }
- }else{
- //查询当前模具编号的模具是否存在
- Integer count = mouldMapper.selectCount(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
- if(count>0){
- msg.setError("当前模具编号已存在,请重新输入其他模具编号");
- }else{
- mould.setCreatorId(user.getId());
- mouldMapper.insert(mould);
- }
- }
- return msg;
- }
- }
|