Browse Source

提交物流公司管理模块

cangku
Houpn 3 years ago
parent
commit
6e74f5ccc9
  1. 7
      hiver-core/src/main/java/cc/hiver/core/entity/Worker.java
  2. 90
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/LogiticsCompanyController.java
  3. 33
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/dao/LogiticsCompanyDao.java
  4. 67
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/LogiticsCompany.java
  5. 44
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/service/LogiticsCompanyService.java
  6. 89
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/serviceimpl/LogiticsCompanyServiceImpl.java
  7. 10
      hiver-modules/hiver-base/src/main/java/cc/hiver/base/handler/OrderXdHandler.java

7
hiver-core/src/main/java/cc/hiver/core/entity/Worker.java

@ -120,4 +120,11 @@ public class Worker implements Serializable {
/*@OneToMany(targetEntity = Order.class,mappedBy = "orderByWorker",cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private List<Order> order;*/
/**
* 区域
*/
@Column(name = "region")
@ApiModelProperty("办公区域")
private String region;
}

90
hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/LogiticsCompanyController.java

@ -0,0 +1,90 @@
/*
Copyright [2022] [https://hiver.cc]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cc.hiver.app.controller.admin;
import cc.hiver.app.entity.Company;
import cc.hiver.app.entity.LogiticsCompany;
import cc.hiver.app.service.CompanyService;
import cc.hiver.app.service.LogiticsCompanyService;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author houpn
*/
@Slf4j
@RestController
@Api(tags = "物流管理公司接口")
@RequestMapping(value = "/hiver/app/logitics")
public class LogiticsCompanyController {
@Autowired
private LogiticsCompanyService companyService;
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "获取全部数据")
public Result<List<LogiticsCompany>> getAll() {
List<LogiticsCompany> list = companyService.getAll();
return new ResultUtil<List<LogiticsCompany>>().setData(list);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "添加")
public Result<Object> add(LogiticsCompany company) {
if (companyService.findByCompanyName(company.getCompanyName()) != null) {
return ResultUtil.error("公司名称已经存在");
}
companyService.save(company);
return ResultUtil.success("添加成功");
}
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@ResponseBody
@ApiOperation(value = "编辑")
public Result<Object> edit(LogiticsCompany company) {
companyService.update(company);
return ResultUtil.success("编辑成功");
}
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "通过id删除")
public Result<Object> delAllByIds(@RequestParam String[] ids) {
for (String id : ids) {
LogiticsCompany company = companyService.get(id);
companyService.delete(id);
}
return ResultUtil.success("删除成功");
}
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
@ApiOperation(value = "多条件分页获取公司列表")
public Result<Page<LogiticsCompany>> getByCondition(LogiticsCompany company,
PageVo pageVo) {
Page<LogiticsCompany> page = companyService.findByCondition(company, PageUtil.initPage(pageVo));
return new ResultUtil<Page<LogiticsCompany>>().setData(page);
}
}

33
hiver-modules/hiver-app/src/main/java/cc/hiver/app/dao/LogiticsCompanyDao.java

@ -0,0 +1,33 @@
/*
Copyright [2022] [https://hiver.cc]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cc.hiver.app.dao;
import cc.hiver.app.entity.Company;
import cc.hiver.app.entity.LogiticsCompany;
import cc.hiver.core.base.HiverBaseDao;
/**
* @author houpn
*/
public interface LogiticsCompanyDao extends HiverBaseDao<LogiticsCompany, String> {
/**
* 通过公司名称获得记录
*
* @param companyName
* @return
*/
LogiticsCompany findByCompanyName(String companyName);
}

67
hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/LogiticsCompany.java

@ -0,0 +1,67 @@
/*
Copyright [2022] [https://hiver.cc]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cc.hiver.app.entity;
import cc.hiver.core.base.HiverBaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 公司实体类
*
* @author Yazhi Li
*/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "t_lcompany")
@TableName("t_lcompany")
@ApiModel(value = "公司信息")
public class LogiticsCompany extends HiverBaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "公司名称")
private String companyName;
@ApiModelProperty(value = "公司电话")
private String companyTel;
@ApiModelProperty(value = "公司邮箱")
private String companyEmail;
@ApiModelProperty(value = "所在地区")
private String companyAddress;
@ApiModelProperty(value = "详细地址")
private String companyStreet;
@ApiModelProperty(value = "联系人")
private String contacts;
@ApiModelProperty(value = "联系人手机号")
private String mobile;
@ApiModelProperty(value = "办公区域")
private String region;
}

44
hiver-modules/hiver-app/src/main/java/cc/hiver/app/service/LogiticsCompanyService.java

@ -0,0 +1,44 @@
/*
Copyright [2022] [https://hiver.cc]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cc.hiver.app.service;
import cc.hiver.app.entity.Company;
import cc.hiver.app.entity.LogiticsCompany;
import cc.hiver.core.base.HiverBaseService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
/**
* @author Yazhi Li
*/
public interface LogiticsCompanyService extends HiverBaseService<LogiticsCompany, String> {
/**
* 多条件获取
*
* @param company
* @param pageable
* @return
*/
Page<LogiticsCompany> findByCondition(LogiticsCompany company, Pageable pageable);
/**
* 通过公司名称获得记录
*
* @param companyName
* @return
*/
LogiticsCompany findByCompanyName(String companyName);
}

89
hiver-modules/hiver-app/src/main/java/cc/hiver/app/serviceimpl/LogiticsCompanyServiceImpl.java

@ -0,0 +1,89 @@
/*
Copyright [2022] [https://hiver.cc]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cc.hiver.app.serviceimpl;
import cc.hiver.app.dao.CompanyDao;
import cc.hiver.app.dao.LogiticsCompanyDao;
import cc.hiver.app.entity.Company;
import cc.hiver.app.entity.LogiticsCompany;
import cc.hiver.app.service.CompanyService;
import cc.hiver.app.service.LogiticsCompanyService;
import cc.hiver.core.base.HiverBaseDao;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author houpn
*/
@Slf4j
@Service
@Transactional
public class LogiticsCompanyServiceImpl implements LogiticsCompanyService {
@Autowired
private LogiticsCompanyDao companyDao;
@Override
public HiverBaseDao<LogiticsCompany, String> getRepository() {
return companyDao;
}
@Override
public Page<LogiticsCompany> findByCondition(LogiticsCompany company, Pageable pageable) {
return companyDao.findAll(new Specification<LogiticsCompany>() {
@Nullable
@Override
public Predicate toPredicate(Root<LogiticsCompany> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
Path<String> companyNameField = root.get("companyName");
Path<String> contactsField = root.get("contacts");
Path<String> mobileField = root.get("mobile");
List<Predicate> list = new ArrayList<>();
if (StrUtil.isNotBlank(company.getCompanyName())) {
list.add(cb.like(companyNameField, '%' + company.getCompanyName() + '%'));
}
if (StrUtil.isNotBlank(company.getContacts())) {
list.add(cb.like(contactsField, '%' + company.getContacts() + '%'));
}
if (StrUtil.isNotBlank(company.getMobile())) {
list.add(cb.like(mobileField, '%' + company.getMobile() + '%'));
}
Predicate[] arr = new Predicate[list.size()];
cq.where(list.toArray(arr));
return null;
}
}, pageable);
}
@Override
public LogiticsCompany findByCompanyName(String companyName) {
return companyDao.findByCompanyName(companyName);
}
}

10
hiver-modules/hiver-base/src/main/java/cc/hiver/base/handler/OrderXdHandler.java

@ -5,8 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;
/**
* @author benjamin_5
@ -17,9 +15,11 @@ import top.javatool.canal.client.handler.EntryHandler;
//@Component
//@AllArgsConstructor
//@Slf4j
/*
public class OrderXdHandler implements EntryHandler<OrderXd> {
/*//private final RedisTemplate<Object,Object> redisTemplate;
//private final RedisTemplate<Object,Object> redisTemplate;
@Override
public void insert(OrderXd orderXd) {
@ -37,5 +37,5 @@ public class OrderXdHandler implements EntryHandler<OrderXd> {
public void delete(OrderXd orderXd) {
log.info("[删除]"+orderXd);
redisTemplate.delete("ORDER:"+orderXd.getOrderId());
}*/
}
}
}*/
Loading…
Cancel
Save