|
@@ -0,0 +1,69 @@
|
|
|
+package com.usky.dxtop.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.usky.dxtop.common.constant.UserConstants;
|
|
|
+import com.usky.dxtop.common.core.page.CommonPage;
|
|
|
+import com.usky.dxtop.common.utils.StringUtils;
|
|
|
+import com.usky.dxtop.mapper.CompanyMapper;
|
|
|
+import com.usky.dxtop.model.Company;
|
|
|
+import com.usky.dxtop.service.CompanyService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author yq
|
|
|
+ * @since 2021-09-29
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public boolean add(Company company) {
|
|
|
+ return this.save(company);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String checkNameUnique(Company company) {
|
|
|
+ Long configId = StringUtils.isNull(company.getId()) ? -1L : company.getId();
|
|
|
+ LambdaQueryWrapper<Company> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(Company::getName,company.getName())
|
|
|
+ .eq(Company::getDelFlag,0);
|
|
|
+ Company one = this.getOne(queryWrapper);
|
|
|
+ if (StringUtils.isNotNull(one) && one.getId() != configId.longValue())
|
|
|
+ {
|
|
|
+ return UserConstants.NOT_UNIQUE;
|
|
|
+ }
|
|
|
+ return UserConstants.UNIQUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<Company> list(Integer current,Integer size,String name) {
|
|
|
+ IPage<Company> page = new Page<>(current, size);
|
|
|
+ LambdaQueryWrapper<Company> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(name),Company::getName,name);
|
|
|
+ page = this.page(page,queryWrapper);
|
|
|
+ return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean remove(Long id) {
|
|
|
+ Company company = new Company();
|
|
|
+ company.setId(id);
|
|
|
+ company.setDelFlag(true);
|
|
|
+ return this.updateById(company);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|