Commit 3b9ce698 by zhanghj

V1.0.0--提交门店发起订单接口

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17406 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent bce2842d
...@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan("com.glsx") @ComponentScan("com.glsx")
@ServletComponentScan @ServletComponentScan
@EnableEurekaClient @EnableEurekaClient
@EnableTransactionManagement
@EnableFeignClients(basePackages = {"com.glsx.common.feign.client"}) @EnableFeignClients(basePackages = {"com.glsx.common.feign.client"})
@MapperScan(basePackages={"com.glsx.ordercenter.mapper"}) @MapperScan(basePackages={"com.glsx.ordercenter.mapper"})
public class Application extends SpringBootServletInitializer{ public class Application extends SpringBootServletInitializer{
......
package com.glsx.ordercenter.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
/**
*
* @Title BaseController.java
* @Package com.glsx.manager.controller
* @Description TODO
* @author zhanghj
* @date 2019年1月3日 下午4:51:03
* @version 1.0.0
*/
public class BaseController {
public Logger logger = LoggerFactory.getLogger(getClass());
/**
* hibernate-validator参数校验返回错误方法
* @param result
* @return
*/
public Map<String, String> getErrors(BindingResult result) {
Map<String, String> map = new HashMap<String, String>();
List<FieldError> list = result.getFieldErrors();
for (FieldError error : list) {
map.put(error.getField(), error.getDefaultMessage());
}
return map;
}
/**
* hibernate-validator对于特殊参数格式的校验方式
* @param object
* @return
*/
public Map<String, String> getErrors(Object object) {
Map<String, String> map = new HashMap<String, String>();
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object);
for (ConstraintViolation<Object> constraintViolation : constraintViolations) {
String key = constraintViolation.getPropertyPath().toString();
String value = constraintViolation.getMessage();
map.put(key, value);
}
return map;
}
}
...@@ -30,8 +30,11 @@ import java.util.List; ...@@ -30,8 +30,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -61,7 +64,7 @@ import com.glsx.ordercenter.service.IOrderService; ...@@ -61,7 +64,7 @@ import com.glsx.ordercenter.service.IOrderService;
@AuthCheck @AuthCheck
@RestController @RestController
@RequestMapping("/order") @RequestMapping("/order")
public class OrderController { public class OrderController extends BaseController{
@Autowired @Autowired
private IOrderService orderService; private IOrderService orderService;
...@@ -88,8 +91,14 @@ public class OrderController { ...@@ -88,8 +91,14 @@ public class OrderController {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
} }
@RequestMapping(value = "/add", method = { RequestMethod.GET, RequestMethod.POST }) @RequestMapping(value = "/save", method = {RequestMethod.POST })
public ResultObject add(SysOrder sysOrder) { public ResultObject add(HttpServletRequest request, @Validated(value={Default.class}) SysOrder sysOrder, BindingResult bindingResult){
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
sysOrder.setCreateTime(new Date());
sysOrder.setCreateBy(UserUtils.getUserName(request));
orderService.insertSelective(sysOrder); orderService.insertSelective(sysOrder);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null);
} }
......
...@@ -3,6 +3,12 @@ package com.glsx.ordercenter.pojo; ...@@ -3,6 +3,12 @@ package com.glsx.ordercenter.pojo;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import org.springframework.format.annotation.DateTimeFormat;
import com.glsx.ordercenter.dto.MachanicInfo; import com.glsx.ordercenter.dto.MachanicInfo;
import com.glsx.ordercenter.dto.MerchantInfo; import com.glsx.ordercenter.dto.MerchantInfo;
...@@ -19,29 +25,55 @@ public class SysOrder { ...@@ -19,29 +25,55 @@ public class SysOrder {
private Integer shopId; private Integer shopId;
/**
* 订单服务区域(默认是门店地址)
*/
@NotNull(message="{param.not.null}", groups={Default.class})
private Integer district; private Integer district;
/**
* 详细地址
*/
@NotBlank(message="{param.not.null}", groups={Default.class})
private String address; private String address;
/**
* 联系人姓名
*/
@NotBlank(message="{param.not.null}", groups={Default.class})
private String contact; private String contact;
/**
private Integer phoneNumber; * 联系人电话
*/
@NotBlank(message="{param.not.null}", groups={Default.class})
private String phoneNumber;
private String carBrand; private String carBrand;
private String carType; private String carType;
/**
* 车架号
*/
private String vinNo; private String vinNo;
/**
* 车辆颜色
*/
@NotBlank(message="{param.not.null}", groups={Default.class})
private String carColor; private String carColor;
/**
* 安装日期
*/
@NotNull(message="{param.not.null}", groups={Default.class})
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date installDate; private Date installDate;
/**
* 服务类型
*/
@NotBlank(message="{param.not.null}", groups={Default.class})
private String serviceType; private String serviceType;
private String carOwner; private String carOwner;
private Integer carOwnerPhone; private String carOwnerPhone;
private Date cancelTime; private Date cancelTime;
...@@ -191,14 +223,6 @@ public class SysOrder { ...@@ -191,14 +223,6 @@ public class SysOrder {
this.contact = contact == null ? null : contact.trim(); this.contact = contact == null ? null : contact.trim();
} }
public Integer getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(Integer phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getCarBrand() { public String getCarBrand() {
return carBrand; return carBrand;
} }
...@@ -255,11 +279,19 @@ public class SysOrder { ...@@ -255,11 +279,19 @@ public class SysOrder {
this.carOwner = carOwner == null ? null : carOwner.trim(); this.carOwner = carOwner == null ? null : carOwner.trim();
} }
public Integer getCarOwnerPhone() { public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getCarOwnerPhone() {
return carOwnerPhone; return carOwnerPhone;
} }
public void setCarOwnerPhone(Integer carOwnerPhone) { public void setCarOwnerPhone(String carOwnerPhone) {
this.carOwnerPhone = carOwnerPhone; this.carOwnerPhone = carOwnerPhone;
} }
......
...@@ -120,7 +120,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -120,7 +120,7 @@ public class OrderServiceImpl implements IOrderService {
*/ */
@Override @Override
public int insertSelective(SysOrder record) { public int insertSelective(SysOrder record) {
return orderDao.insert(record); return orderDao.insertSelective(record);
} }
@Override @Override
......
param.not.null=\u53c2\u6570\u4e0d\u80fd\u4e3a\u7a7a
\ No newline at end of file \ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<result column="district" jdbcType="INTEGER" property="district" /> <result column="district" jdbcType="INTEGER" property="district" />
<result column="address" jdbcType="VARCHAR" property="address" /> <result column="address" jdbcType="VARCHAR" property="address" />
<result column="contact" jdbcType="VARCHAR" property="contact" /> <result column="contact" jdbcType="VARCHAR" property="contact" />
<result column="phone_number" jdbcType="INTEGER" property="phoneNumber" /> <result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
<result column="car_brand" jdbcType="VARCHAR" property="carBrand" /> <result column="car_brand" jdbcType="VARCHAR" property="carBrand" />
<result column="car_type" jdbcType="VARCHAR" property="carType" /> <result column="car_type" jdbcType="VARCHAR" property="carType" />
<result column="vin_no" jdbcType="VARCHAR" property="vinNo" /> <result column="vin_no" jdbcType="VARCHAR" property="vinNo" />
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<result column="install_date" jdbcType="TIMESTAMP" property="installDate" /> <result column="install_date" jdbcType="TIMESTAMP" property="installDate" />
<result column="service_type" jdbcType="VARCHAR" property="serviceType" /> <result column="service_type" jdbcType="VARCHAR" property="serviceType" />
<result column="car_owner" jdbcType="VARCHAR" property="carOwner" /> <result column="car_owner" jdbcType="VARCHAR" property="carOwner" />
<result column="car_owner_phone" jdbcType="INTEGER" property="carOwnerPhone" /> <result column="car_owner_phone" jdbcType="VARCHAR" property="carOwnerPhone" />
<result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime" /> <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime" />
<result column="active_status_array" jdbcType="VARCHAR" property="activeStatusArray" /> <result column="active_status_array" jdbcType="VARCHAR" property="activeStatusArray" />
<result column="merchant_id" jdbcType="INTEGER" property="merchantId" /> <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
...@@ -121,10 +121,10 @@ ...@@ -121,10 +121,10 @@
) )
values (#{orderSn,jdbcType=VARCHAR}, #{activeStatus,jdbcType=TINYINT}, #{canceled,jdbcType=TINYINT}, values (#{orderSn,jdbcType=VARCHAR}, #{activeStatus,jdbcType=TINYINT}, #{canceled,jdbcType=TINYINT},
#{orderType,jdbcType=TINYINT}, #{shopId,jdbcType=INTEGER}, #{district,jdbcType=INTEGER}, #{orderType,jdbcType=TINYINT}, #{shopId,jdbcType=INTEGER}, #{district,jdbcType=INTEGER},
#{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR},
#{carBrand,jdbcType=VARCHAR}, #{carType,jdbcType=VARCHAR}, #{vinNo,jdbcType=VARCHAR}, #{carBrand,jdbcType=VARCHAR}, #{carType,jdbcType=VARCHAR}, #{vinNo,jdbcType=VARCHAR},
#{carColor,jdbcType=VARCHAR}, #{installDate,jdbcType=TIMESTAMP}, #{serviceType,jdbcType=VARCHAR}, #{carColor,jdbcType=VARCHAR}, #{installDate,jdbcType=TIMESTAMP}, #{serviceType,jdbcType=VARCHAR},
#{carOwner,jdbcType=VARCHAR}, #{carOwnerPhone,jdbcType=INTEGER}, #{cancelTime,jdbcType=TIMESTAMP}, #{carOwner,jdbcType=VARCHAR}, #{carOwnerPhone,jdbcType=VARCHAR}, #{cancelTime,jdbcType=TIMESTAMP},
#{activeStatusArray,jdbcType=VARCHAR}, #{merchantId,jdbcType=INTEGER}, #{mechanicId,jdbcType=INTEGER}, #{activeStatusArray,jdbcType=VARCHAR}, #{merchantId,jdbcType=INTEGER}, #{mechanicId,jdbcType=INTEGER},
#{repairReason,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{repairReason,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR} #{updateTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
#{contact,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR},
</if> </if>
<if test="phoneNumber != null"> <if test="phoneNumber != null">
#{phoneNumber,jdbcType=INTEGER}, #{phoneNumber,jdbcType=VARCHAR},
</if> </if>
<if test="carBrand != null"> <if test="carBrand != null">
#{carBrand,jdbcType=VARCHAR}, #{carBrand,jdbcType=VARCHAR},
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
#{carOwner,jdbcType=VARCHAR}, #{carOwner,jdbcType=VARCHAR},
</if> </if>
<if test="carOwnerPhone != null"> <if test="carOwnerPhone != null">
#{carOwnerPhone,jdbcType=INTEGER}, #{carOwnerPhone,jdbcType=VARCHAR},
</if> </if>
<if test="cancelTime != null"> <if test="cancelTime != null">
#{cancelTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP},
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
contact = #{contact,jdbcType=VARCHAR}, contact = #{contact,jdbcType=VARCHAR},
</if> </if>
<if test="phoneNumber != null"> <if test="phoneNumber != null">
phone_number = #{phoneNumber,jdbcType=INTEGER}, phone_number = #{phoneNumber,jdbcType=VARCHAR},
</if> </if>
<if test="carBrand != null"> <if test="carBrand != null">
car_brand = #{carBrand,jdbcType=VARCHAR}, car_brand = #{carBrand,jdbcType=VARCHAR},
...@@ -357,7 +357,7 @@ ...@@ -357,7 +357,7 @@
car_owner = #{carOwner,jdbcType=VARCHAR}, car_owner = #{carOwner,jdbcType=VARCHAR},
</if> </if>
<if test="carOwnerPhone != null"> <if test="carOwnerPhone != null">
car_owner_phone = #{carOwnerPhone,jdbcType=INTEGER}, car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
</if> </if>
<if test="cancelTime != null"> <if test="cancelTime != null">
cancel_time = #{cancelTime,jdbcType=TIMESTAMP}, cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
...@@ -408,7 +408,7 @@ ...@@ -408,7 +408,7 @@
district = #{district,jdbcType=INTEGER}, district = #{district,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR},
contact = #{contact,jdbcType=VARCHAR}, contact = #{contact,jdbcType=VARCHAR},
phone_number = #{phoneNumber,jdbcType=INTEGER}, phone_number = #{phoneNumber,jdbcType=VARCHAR},
car_brand = #{carBrand,jdbcType=VARCHAR}, car_brand = #{carBrand,jdbcType=VARCHAR},
car_type = #{carType,jdbcType=VARCHAR}, car_type = #{carType,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR}, vin_no = #{vinNo,jdbcType=VARCHAR},
...@@ -416,7 +416,7 @@ ...@@ -416,7 +416,7 @@
install_date = #{installDate,jdbcType=TIMESTAMP}, install_date = #{installDate,jdbcType=TIMESTAMP},
service_type = #{serviceType,jdbcType=VARCHAR}, service_type = #{serviceType,jdbcType=VARCHAR},
car_owner = #{carOwner,jdbcType=VARCHAR}, car_owner = #{carOwner,jdbcType=VARCHAR},
car_owner_phone = #{carOwnerPhone,jdbcType=INTEGER}, car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
cancel_time = #{cancelTime,jdbcType=TIMESTAMP}, cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
active_status_array = #{activeStatusArray,jdbcType=VARCHAR}, active_status_array = #{activeStatusArray,jdbcType=VARCHAR},
merchant_id = #{merchantId,jdbcType=INTEGER}, merchant_id = #{merchantId,jdbcType=INTEGER},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!