1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.hssx.cloudmodel.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.hssx.cloudmodel.entity.Company;
- import com.hssx.cloudmodel.entity.Role;
- import com.hssx.cloudmodel.mapper.CompanyMapper;
- import com.hssx.cloudmodel.service.CompanyService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.hssx.cloudmodel.util.HttpRespMsg;
- import com.hssx.cloudmodel.util.PageUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author 吴涛涛
- * @since 2019-07-26
- */
- @Service
- public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {
- @Autowired
- CompanyMapper companyMapper;
- @Override
- public HttpRespMsg addAndUpdateRole(Company company, Integer flag) {
- HttpRespMsg msg = new HttpRespMsg();
- if (flag == 0) {
- //添加公司
- QueryWrapper<Company> qw = new QueryWrapper<>();
- qw.eq("company_name", company.getCompanyName());
- int count = companyMapper.selectCount(qw);
- if (count > 0) {
- msg.setError("公司已存在,请勿重复添加");
- } else {
- companyMapper.insert(company);
- }
- } else if (flag == 1) {
- //更新公司信息
- companyMapper.updateById(company);
- }
- return msg;
- }
- @Override
- public HttpRespMsg pageList(PageUtil page, String keyName) {
- HttpRespMsg msg = new HttpRespMsg();
- QueryWrapper<Company> qw = new QueryWrapper<>();
- if(keyName !=null && !"".equals(keyName)){
- qw.like("company_name", keyName);
- }
- Integer start = (page.getCurrentPage()-1)*page.getPageSize();
- Integer count = companyMapper.selectCount(qw);
- page.setTotalCount(count);
- page.setTotalPage(page.getTotalCount());
- List<Company> list = companyMapper.getListByKeyName(keyName, start, page.getPageSize());
- page.setList(list);
- msg.data = page;
- return msg;
- }
- }
|