作者 王勇

统一接口,增加公司信息业务

package com.sunyo.wlpt.dispatch.controller;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.dispatch.domain.CompanyInfo;
import com.sunyo.wlpt.dispatch.response.ResultJson;
import com.sunyo.wlpt.dispatch.service.CompanyInfoService;
import com.sunyo.wlpt.dispatch.utils.GetUUID;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author 子诚
* Description:公司信息 Controller
* 时间:2020/4/28 15:41
*/
@Api(value = "公司信息,业务", tags = "业务管理——公司信息")
@RequestMapping("dispatch/companyInfo")
@RestController
public class CompanyInfoController {
@Autowired
private CompanyInfoService companyInfoService;
@ApiOperation("分页查询,公司信息列表")
@GetMapping("/selectCompanyInfoList")
public ResultJson<PageInfo> selectCompanyInfoList(
@ApiParam(name = "companyName", value = "公司名称", required = false)
@RequestParam(value = "companyName", required = false) String companyName,
@ApiParam(name = "companyMobile", value = "公司联系方式", required = false)
@RequestParam(value = "companyMobile", required = false) String companyMobile,
@ApiParam(name = "pageNum", value = "第几页,默认为第一页", required = false)
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@ApiParam(name = "pageSize", value = "每页数量,默认10条", required = false)
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
ResultJson<PageInfo> result = new ResultJson<>();
CompanyInfo companyInfo = new CompanyInfo();
if("".equals(companyName)){
companyInfo.setCompanyName(companyName);
}
if("".equals(companyMobile)){
companyInfo.setCompanyMobile(companyMobile);
}
PageInfo pageInfo = companyInfoService.selectCompanyInfoList(companyInfo, pageNum, pageSize);
if (pageInfo.getTotal() > 0) {
result.setData(pageInfo);
result.setMsg("查询公司信息,成功");
} else {
result.setCode("400");
result.setMsg("查询公司信息,失败");
}
return result;
}
@ApiOperation("增加,公司信息")
@PostMapping("/insertCompanyInfo")
public ResultJson insertCompanyInfo(@RequestBody CompanyInfo companyInfo) {
ResultJson result = new ResultJson();
companyInfo.setId(GetUUID.getuuid());
int num = companyInfoService.insertSelective(companyInfo);
if (num > 0) {
result.setMsg("增加公司信息,成功");
} else {
result.setCode("400");
result.setMsg("增加公司信息,失败");
}
return result;
}
@ApiOperation("编辑,公司信息")
@PutMapping("/updateCompanyInfo")
public ResultJson updateCompanyInfo(@RequestBody CompanyInfo companyInfo) {
ResultJson result = new ResultJson();
int num = companyInfoService.updateByPrimaryKeySelective(companyInfo);
if (num > 0) {
result.setMsg("修改公司信息,成功");
} else {
result.setCode("400");
result.setMsg("修改公司信息,失败");
}
return result;
}
@ApiOperation("删除,公司信息")
@DeleteMapping("/deleteCompanyInfo")
public ResultJson deleteCompanyInfo(@RequestBody CompanyInfo companyInfo) {
ResultJson result = new ResultJson();
int num = companyInfoService.deleteByPrimaryKey(companyInfo.getId());
if (num > 0) {
result.setMsg("删除公司信息,成功");
} else {
result.setCode("400");
result.setMsg("删除公司信息,失败");
}
return result;
}
}
... ...
... ... @@ -21,7 +21,7 @@ import java.util.Date;
* 时间:2020/4/24 20:30
*/
@Api(value = "调度记录信息,业务", tags = "业务管理——车辆调度记录信息")
@RequestMapping("dispatchNote")
@RequestMapping("dispatch/dispatchNote")
@RestController
public class DispatchNoteController {
@Autowired
... ... @@ -95,7 +95,7 @@ public class DispatchNoteController {
}
@ApiOperation("删除调度记录信息")
@DeleteMapping("/updateDispatchNote")
@DeleteMapping("/deleteDispatchNote")
public ResultJson<DispatchNote> deleteDispatchNote(@RequestBody DispatchNote dispatchNote) {
ResultJson<DispatchNote> result = new ResultJson<>();
/**
... ...
... ... @@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
* 时间:2020/4/26 14:04
*/
@Api(value = "驾驶员信息管理", tags = "业务管理——驾驶员信息管理")
@RequestMapping("/driverInfo")
@RequestMapping("dispatch/driverInfo")
@RestController
public class DriverInfoController {
@Autowired
... ...
... ... @@ -19,7 +19,7 @@ import java.util.Date;
* 时间:2020/4/24 17:03
*/
@Api(value = "车辆信息", tags = "业务管理——车辆信息管理")
@RequestMapping("vehicleInfo")
@RequestMapping("dispatch/vehicleInfo")
@RestController
public class VehicleInfoController {
@Autowired
... ...
... ... @@ -23,7 +23,7 @@ public class CompanyInfo implements Serializable {
/**
* 公司信息编号uuid
*/
private String id = UUID.randomUUID().toString().replaceAll("-", "");
private String id;
/**
* 公司名称
... ...
package com.sunyo.wlpt.dispatch.mapper;
import com.sunyo.wlpt.dispatch.domain.CompanyInfo;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
... ... @@ -13,6 +14,14 @@ import org.apache.ibatis.annotations.Param;
*/
@Mapper
public interface CompanyInfoMapper {
/**
* 获取,公司信息列表
*
* @param record
* @return
*/
List<CompanyInfo> selectCompanyInfoList(CompanyInfo record);
int deleteByPrimaryKey(String id);
int insert(CompanyInfo record);
... ...
package com.sunyo.wlpt.dispatch.service;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.dispatch.domain.CompanyInfo;
import com.sunyo.wlpt.dispatch.domain.DispatchNote;
import java.util.List;
... ... @@ -10,7 +12,15 @@ import java.util.List;
* 时间:2020/4/21 14:29
*/
public interface CompanyInfoService {
/**
* 分页查询,公司信息
*
* @param companyInfo
* @param pageNum
* @param pageSize
* @return
*/
PageInfo selectCompanyInfoList(CompanyInfo companyInfo, Integer pageNum, Integer pageSize);
int deleteByPrimaryKey(String id);
... ...
package com.sunyo.wlpt.dispatch.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.dispatch.domain.DispatchNote;
import com.sunyo.wlpt.dispatch.domain.VehicleInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
... ... @@ -22,6 +26,24 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
@Resource
private CompanyInfoMapper companyInfoMapper;
/**
* 分页查询,调度列表
*
* @param companyInfo
* @param pageNum
* @param pageSize
* @return
*/
@Override
public PageInfo selectCompanyInfoList(CompanyInfo companyInfo, Integer pageNum, Integer pageSize) {
/* 获取,公司信息列表 */
List<CompanyInfo> companyInfoList = companyInfoMapper.selectCompanyInfoList(companyInfo);
/* 使用 PageHelper 分页插件 */
PageHelper.startPage(pageNum, pageSize);
PageInfo<VehicleInfo> pageInfo = new PageInfo(companyInfoList);
return pageInfo;
}
@Override
public int deleteByPrimaryKey(String id) {
return companyInfoMapper.deleteByPrimaryKey(id);
... ...
... ... @@ -4,12 +4,12 @@
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.dispatch.domain.CompanyInfo">
<!--@mbg.generated-->
<!--@Table company_info-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="company_name" jdbcType="VARCHAR" property="companyName" />
<result column="company_address" jdbcType="VARCHAR" property="companyAddress" />
<result column="company_mobile" jdbcType="VARCHAR" property="companyMobile" />
<result column="company_id" jdbcType="VARCHAR" property="companyId" />
<result column="company_representative" jdbcType="VARCHAR" property="companyRepresentative" />
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="company_name" jdbcType="VARCHAR" property="companyName"/>
<result column="company_address" jdbcType="VARCHAR" property="companyAddress"/>
<result column="company_mobile" jdbcType="VARCHAR" property="companyMobile"/>
<result column="company_id" jdbcType="VARCHAR" property="companyId"/>
<result column="company_representative" jdbcType="VARCHAR" property="companyRepresentative"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
... ... @@ -18,10 +18,29 @@
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from company_info
where id = #{id,jdbcType=VARCHAR}
</select>
<!-- 获取公司信息列表 -->
<select id="selectCompanyInfoList" parameterType="com.sunyo.wlpt.dispatch.domain.CompanyInfo"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from company_info
<where>
<trim suffixOverrides=",">
<!-- 用户姓名 -->
<if test="companyName != null and companyName != ''">
company_name = #{companyName,jdbcType=VARCHAR},
</if>
<!-- 用户联系方式 -->
<if test="companyMobile != null and companyMobile != ''">
AND company_mobile = #{companyMobile,jdbcType=VARCHAR}
</if>
</trim>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete from company_info
... ... @@ -200,7 +219,8 @@
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.companyName,jdbcType=VARCHAR}, #{item.companyAddress,jdbcType=VARCHAR},
#{item.companyMobile,jdbcType=VARCHAR}, #{item.companyId,jdbcType=VARCHAR}, #{item.companyRepresentative,jdbcType=VARCHAR}
#{item.companyMobile,jdbcType=VARCHAR}, #{item.companyId,jdbcType=VARCHAR},
#{item.companyRepresentative,jdbcType=VARCHAR}
)
</foreach>
</insert>
... ...