Commit c5fb9040 by hewei

Merge branch 'future/strokeList' into 'master'

Future/stroke list

See merge request hewei/Jumeirah!9
parents cffd6411 2484b0a0
...@@ -13,10 +13,11 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -13,10 +13,11 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
/** /**
*
* Hello World Controller * Hello World Controller
**/ **/
@Slf4j @Slf4j
@Api(value = "Hello World2", tags = {"APP Hello World2"}) @Api(value = "权限测试", tags = {"APP Hello World2"})
@RestController @RestController
@RequestMapping("/app") @RequestMapping("/app")
//@Module("api-app") //@Module("api-app")
......
package com.jumeirah.api.app.controller; package com.jumeirah.api.app.controller;
import com.jumeirah.api.app.service.AppUserApiService; import com.jumeirah.api.app.service.AppUserApiService;
import com.jumeirah.common.entity.AppUser;
import com.jumeirah.common.param.AppUserPageParam;
import com.jumeirah.common.param.app.AppSmsRegisterParam; import com.jumeirah.common.param.app.AppSmsRegisterParam;
import com.jumeirah.common.param.app.AppUserInfoParam; import com.jumeirah.common.param.app.AppUserInfoParam;
import com.jumeirah.common.service.AppUserService; import com.jumeirah.common.service.AppUserService;
import com.jumeirah.common.vo.AppUserQueryVo;
import com.jumeirah.common.vo.app.LoginAppUserTokenVo; import com.jumeirah.common.vo.app.LoginAppUserTokenVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.Module; import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
...@@ -60,9 +51,9 @@ public class AppUserController extends BaseController { ...@@ -60,9 +51,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** /* *//**
* 添加APP用户 * 添加APP用户
*/ *//*
@PostMapping("/add") @PostMapping("/add")
@OperationLog(name = "添加APP用户", type = OperationLogType.ADD) @OperationLog(name = "添加APP用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加APP用户", response = ApiResult.class) @ApiOperation(value = "添加APP用户", response = ApiResult.class)
...@@ -72,9 +63,9 @@ public class AppUserController extends BaseController { ...@@ -72,9 +63,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** *//**
* 修改APP用户 * 修改APP用户
*/ *//*
@PostMapping("/update") @PostMapping("/update")
@OperationLog(name = "修改APP用户", type = OperationLogType.UPDATE) @OperationLog(name = "修改APP用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改APP用户", response = ApiResult.class) @ApiOperation(value = "修改APP用户", response = ApiResult.class)
...@@ -84,9 +75,9 @@ public class AppUserController extends BaseController { ...@@ -84,9 +75,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** *//**
* 删除APP用户 * 删除APP用户
*/ *//*
@PostMapping("/delete/{id}") @PostMapping("/delete/{id}")
@OperationLog(name = "删除APP用户", type = OperationLogType.DELETE) @OperationLog(name = "删除APP用户", type = OperationLogType.DELETE)
@ApiOperation(value = "删除APP用户", response = ApiResult.class) @ApiOperation(value = "删除APP用户", response = ApiResult.class)
...@@ -96,9 +87,9 @@ public class AppUserController extends BaseController { ...@@ -96,9 +87,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** *//**
* 获取APP用户详情 * 获取APP用户详情
*/ *//*
@GetMapping("/info/{id}") @GetMapping("/info/{id}")
@OperationLog(name = "APP用户详情", type = OperationLogType.INFO) @OperationLog(name = "APP用户详情", type = OperationLogType.INFO)
@ApiOperation(value = "APP用户详情", response = AppUserQueryVo.class) @ApiOperation(value = "APP用户详情", response = AppUserQueryVo.class)
...@@ -108,9 +99,11 @@ public class AppUserController extends BaseController { ...@@ -108,9 +99,11 @@ public class AppUserController extends BaseController {
return ApiResult.ok(appUserQueryVo); return ApiResult.ok(appUserQueryVo);
} }
*/
/** /**
* APP用户分页列表 * APP用户分页列表
*/ *//*
@PostMapping("/getPageList") @PostMapping("/getPageList")
@OperationLog(name = "APP用户分页列表", type = OperationLogType.PAGE) @OperationLog(name = "APP用户分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "APP用户分页列表", response = AppUserQueryVo.class) @ApiOperation(value = "APP用户分页列表", response = AppUserQueryVo.class)
...@@ -118,8 +111,7 @@ public class AppUserController extends BaseController { ...@@ -118,8 +111,7 @@ public class AppUserController extends BaseController {
public ApiResult<Paging<AppUserQueryVo>> getAppUserPageList(@Validated @RequestBody AppUserPageParam appUserPageParam) throws Exception { public ApiResult<Paging<AppUserQueryVo>> getAppUserPageList(@Validated @RequestBody AppUserPageParam appUserPageParam) throws Exception {
Paging<AppUserQueryVo> paging = appUserService.getAppUserPageList(appUserPageParam); Paging<AppUserQueryVo> paging = appUserService.getAppUserPageList(appUserPageParam);
return ApiResult.ok(paging); return ApiResult.ok(paging);
} }*/
@PostMapping("/registerOrLogin") @PostMapping("/registerOrLogin")
@ApiOperation(value = "手机号注册+登陆", notes = "app用户注册+登陆", response = LoginAppUserTokenVo.class) @ApiOperation(value = "手机号注册+登陆", notes = "app用户注册+登陆", response = LoginAppUserTokenVo.class)
public ApiResult<LoginAppUserTokenVo> registerOrLogin(@Validated @RequestBody AppSmsRegisterParam appSmsRegisterParam, @RequestHeader(required = false) String language) throws Exception { public ApiResult<LoginAppUserTokenVo> registerOrLogin(@Validated @RequestBody AppSmsRegisterParam appSmsRegisterParam, @RequestHeader(required = false) String language) throws Exception {
......
package com.jumeirah.api.app.controller; package com.jumeirah.api.app.controller;
import cn.hutool.core.date.DateUtil;
import com.jumeirah.api.app.entity.vo.StrokeAddBackAndForthVo; import com.jumeirah.api.app.entity.vo.StrokeAddBackAndForthVo;
import com.jumeirah.api.app.entity.vo.StrokeAddFreightVo; import com.jumeirah.api.app.entity.vo.StrokeAddFreightVo;
import com.jumeirah.api.app.entity.vo.StrokeAddMedicalTreatmentVo; import com.jumeirah.api.app.entity.vo.StrokeAddMedicalTreatmentVo;
import com.jumeirah.api.app.entity.vo.StrokeAddOneWayVo; import com.jumeirah.api.app.entity.vo.StrokeAddOneWayVo;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.service.StrokeService;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import lombok.extern.slf4j.Slf4j;
import com.jumeirah.common.param.StrokePageParam; import com.jumeirah.common.param.StrokePageParam;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import com.jumeirah.common.service.StrokeService;
import com.jumeirah.common.vo.StrokeDetailVo;
import com.jumeirah.common.vo.StrokeQueryVo; import com.jumeirah.common.vo.StrokeQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.common.param.IdParam;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.core.validator.groups.Add; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 行程表 控制器 * 行程表 控制器
...@@ -37,7 +38,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -37,7 +38,6 @@ import org.springframework.web.bind.annotation.*;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/stroke") @RequestMapping("/stroke")
@Module("${cfg.module}")
@Api(value = "行程表API", tags = {"行程表"}) @Api(value = "行程表API", tags = {"行程表"})
public class StrokeController extends BaseController { public class StrokeController extends BaseController {
...@@ -110,16 +110,16 @@ public class StrokeController extends BaseController { ...@@ -110,16 +110,16 @@ public class StrokeController extends BaseController {
} }
/** // /**
* 修改行程表 // * 修改行程表
*/ // */
@PostMapping("/update") // @PostMapping("/update")
@OperationLog(name = "修改行程表", type = OperationLogType.UPDATE) // @OperationLog(name = "修改行程表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改行程表", response = ApiResult.class) // @ApiOperation(value = "修改行程表", response = ApiResult.class)
public ApiResult<Boolean> updateStroke(@Validated(Update.class) @RequestBody Stroke stroke) throws Exception { // public ApiResult<Boolean> updateStroke(@Validated(Update.class) @RequestBody Stroke stroke) throws Exception {
boolean flag = strokeService.updateStroke(stroke); // boolean flag = strokeService.updateStroke(stroke);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
/** /**
* 删除行程表 * 删除行程表
...@@ -137,19 +137,30 @@ public class StrokeController extends BaseController { ...@@ -137,19 +137,30 @@ public class StrokeController extends BaseController {
*/ */
@GetMapping("/info/{id}") @GetMapping("/info/{id}")
@OperationLog(name = "行程表详情", type = OperationLogType.INFO) @OperationLog(name = "行程表详情", type = OperationLogType.INFO)
@ApiOperation(value = "行程表详情", response = StrokeQueryVo.class) @ApiOperation(value = "行程表详情", response = StrokeDetailVo.class)
public ApiResult<StrokeQueryVo> getStroke(@PathVariable("id") Long id) throws Exception { public ApiResult<StrokeDetailVo> getStroke(@PathVariable("id") Long id) throws Exception {
StrokeQueryVo strokeQueryVo = strokeService.getStrokeById(id); StrokeDetailVo strokeQueryVo = strokeService.getStrokeById(id);
return ApiResult.ok(strokeQueryVo); return ApiResult.ok(strokeQueryVo);
} }
// /**
// * 行程表分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "行程表分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "行程表分页列表", response = StrokeQueryVo.class)
// public ApiResult<Paging<StrokeQueryVo>> getStrokePageList(@Validated @RequestBody StrokePageParam strokePageParam) throws Exception {
// Paging<StrokeQueryVo> paging = strokeService.getStrokePageList(strokePageParam);
// return ApiResult.ok(paging);
// }
/** /**
* 行程表分页列表 * 行程表分页列表
*/ */
@PostMapping("/getPageList") @PostMapping("/getMyStrokePageList")
@OperationLog(name = "行程分页列表", type = OperationLogType.PAGE) @OperationLog(name = "行程分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "行程分页列表", response = StrokeQueryVo.class) @ApiOperation(value = "行程分页列表", response = StrokeQueryVo.class)
public ApiResult<Paging<StrokeQueryVo>> getStrokePageList(@Validated @RequestBody StrokePageParam strokePageParam) throws Exception { public ApiResult<Paging<StrokeQueryVo>> getMyStrokePageList(@Validated @RequestBody StrokePageParam strokePageParam) throws Exception {
Paging<StrokeQueryVo> paging = strokeService.getStrokePageList(strokePageParam); Paging<StrokeQueryVo> paging = strokeService.getStrokePageList(strokePageParam);
return ApiResult.ok(paging); return ApiResult.ok(paging);
} }
......
...@@ -15,7 +15,7 @@ public interface AppUserApiService { ...@@ -15,7 +15,7 @@ public interface AppUserApiService {
* @throws Exception * @throws Exception
*/ */
ApiResult<LoginAppUserTokenVo> register(AppSmsRegisterParam loginParam, String language) throws Exception; ApiResult<LoginAppUserTokenVo> register(AppSmsRegisterParam loginParam, String language) throws Exception;
ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception; // ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception;
/** /**
* 修改或补充用户信息 * 修改或补充用户信息
......
...@@ -29,7 +29,7 @@ public class AppUserApiServiceImpl implements AppUserApiService { ...@@ -29,7 +29,7 @@ public class AppUserApiServiceImpl implements AppUserApiService {
// 校验验证码 // 校验验证码
boolean equalsRegisterCode = appSmsService.equalsRegisterCode(loginParam.getPhoneArea(), loginParam.getPhone(), loginParam.getSmsCode()); boolean equalsRegisterCode = appSmsService.equalsRegisterCode(loginParam.getPhoneArea(), loginParam.getPhone(), loginParam.getSmsCode());
if (!equalsRegisterCode) { if (!equalsRegisterCode) {
return ApiResult.fail(ApiCode.FAIL, new LoginAppUserTokenVo()); return ApiResult.fail(ApiCode.SMS_CODE_ERROR, new LoginAppUserTokenVo());
} }
// 删除已使用的验证码 // 删除已使用的验证码
appSmsService.deleteRegisterCode(loginParam.getPhoneArea(), loginParam.getPhone()); appSmsService.deleteRegisterCode(loginParam.getPhoneArea(), loginParam.getPhone());
...@@ -45,17 +45,17 @@ public class AppUserApiServiceImpl implements AppUserApiService { ...@@ -45,17 +45,17 @@ public class AppUserApiServiceImpl implements AppUserApiService {
appUser.setPhone(loginParam.getPhone()); appUser.setPhone(loginParam.getPhone());
boolean isDbOk = appUserService.saveAppUser(appUser); boolean isDbOk = appUserService.saveAppUser(appUser);
if (!isDbOk) { if (!isDbOk) {
return ApiResult.fail(ApiCode.FAIL, new LoginAppUserTokenVo()); return ApiResult.fail(ApiCode.SPRING_BOOT_PLUS_EXCEPTION, new LoginAppUserTokenVo());
} }
// 走登陆的代码 // 走登陆的代码
return appUserService.login(loginParam, language, false); return appUserService.login(loginParam, language, false);
} }
@Override // @Override
public ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception { // public ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception {
return null; // return null;
} // }
@Override @Override
public boolean updateAppUser(AppUserInfoParam appUserInfoParam) throws Exception { public boolean updateAppUser(AppUserInfoParam appUserInfoParam) throws Exception {
......
package com.jumeirah.common.entity; package com.jumeirah.common.entity;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -16,8 +14,6 @@ import lombok.experimental.Accessors; ...@@ -16,8 +14,6 @@ import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
/** /**
* 行程表 * 行程表
* *
...@@ -40,6 +36,10 @@ public class Stroke extends BaseEntity { ...@@ -40,6 +36,10 @@ public class Stroke extends BaseEntity {
@ApiModelProperty("出发城市id") @ApiModelProperty("出发城市id")
private Long cityOutsetId; private Long cityOutsetId;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
@TableLogic
private Integer deleted;
@NotBlank(message = "出发城市名称不能为空") @NotBlank(message = "出发城市名称不能为空")
@ApiModelProperty("出发城市名称") @ApiModelProperty("出发城市名称")
private String cityOutsetName; private String cityOutsetName;
......
package com.jumeirah.common.enums;
/**
* 状态,0-审核中,1-进行中,2-已完成,99-取消
*/
public enum StrokeStatusEnum {
UNDER_REVIEW(0, "审核中"),
PROCESSING(1, "进行中"),
COMPLETED(2, "已完成"),
CANCEL(99, "取消");
/**
* 编号
*/
private final Integer id;
/**
* 名称
*/
private final String name;
StrokeStatusEnum(Integer id, String name) {
this.id = id;
this.name = name;
}
}
package com.jumeirah.common.enums;
/**
* 行程类型,0-单程,1-往返行程,2-货运,3-医疗
*/
public enum StrokeTypeEnum {
ONE_WAY(0, "单程"),
ROUND_TRIP(1, "往返"),
CARGO_FLIGHT(2, "货运"),
MEDICAL_FLIGHT(3, "医疗");
/**
* 编号
*/
private final Integer id;
/**
* 名称
*/
private final String name;
StrokeTypeEnum(Integer id, String name) {
this.id = id;
this.name = name;
}
}
package com.jumeirah.common.mapper; package com.jumeirah.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.param.StrokePageParam; import com.jumeirah.common.param.StrokePageParam;
import com.jumeirah.common.vo.StrokeDetailVo;
import com.jumeirah.common.vo.StrokeQueryVo; import com.jumeirah.common.vo.StrokeQueryVo;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable; import java.io.Serializable;
...@@ -28,7 +27,7 @@ public interface StrokeMapper extends BaseMapper<Stroke> { ...@@ -28,7 +27,7 @@ public interface StrokeMapper extends BaseMapper<Stroke> {
* @param id * @param id
* @return * @return
*/ */
StrokeQueryVo getStrokeById(Serializable id); StrokeDetailVo getStrokeById(Serializable id);
/** /**
* 获取分页对象 * 获取分页对象
...@@ -37,6 +36,6 @@ public interface StrokeMapper extends BaseMapper<Stroke> { ...@@ -37,6 +36,6 @@ public interface StrokeMapper extends BaseMapper<Stroke> {
* @param strokePageParam * @param strokePageParam
* @return * @return
*/ */
IPage<StrokeQueryVo> getStrokePageList(@Param("page") Page page,@Param("param") StrokePageParam strokePageParam); IPage<StrokeQueryVo> getStrokePageList(@Param("page") Page page, @Param("param") StrokePageParam strokePageParam, @Param("userId") Long userId);
} }
package com.jumeirah.common.param; package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/** /**
* <pre> * <pre>
...@@ -18,6 +19,10 @@ import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam; ...@@ -18,6 +19,10 @@ import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value = "行程表分页参数") @ApiModel(value = "行程表分页参数")
public class StrokePageParam extends BasePageOrderParam{ public class StrokePageParam extends BasePageOrderParam {
private static final long serialVersionUID=1L; private static final long serialVersionUID = 1L;
}
@ApiModelProperty("行程状态,-1=全部, 0-审核中,1-进行中,2-已完成")//99-取消
private Integer status;
}
...@@ -2,8 +2,9 @@ package com.jumeirah.common.service; ...@@ -2,8 +2,9 @@ package com.jumeirah.common.service;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.param.StrokePageParam; import com.jumeirah.common.param.StrokePageParam;
import io.geekidea.springbootplus.framework.common.service.BaseService; import com.jumeirah.common.vo.StrokeDetailVo;
import com.jumeirah.common.vo.StrokeQueryVo; import com.jumeirah.common.vo.StrokeQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
/** /**
...@@ -48,7 +49,7 @@ public interface StrokeService extends BaseService<Stroke> { ...@@ -48,7 +49,7 @@ public interface StrokeService extends BaseService<Stroke> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
StrokeQueryVo getStrokeById(Long id) throws Exception; StrokeDetailVo getStrokeById(Long id) throws Exception;
/** /**
* 获取分页对象 * 获取分页对象
......
...@@ -27,7 +27,6 @@ import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo; ...@@ -27,7 +27,6 @@ import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -93,13 +92,15 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser> ...@@ -93,13 +92,15 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser>
if (appUser == null) { if (appUser == null) {
log.error("登录失败,用户名或密码错误 loginParam:{}", loginParam); log.error("登录失败,用户名或密码错误 loginParam:{}", loginParam);
return ApiResult.fail(ApiCode.PWD_OR_USERNAME_ERROR, language); return ApiResult.fail(ApiCode.USER_NOT_FOUND, language);
} }
if (StateEnum.DISABLE.getCode().equals(appUser.getState())) { if (StateEnum.DISABLE.getCode().equals(appUser.getState())) {
throw new AuthenticationException("账号已禁用"); // throw new AuthenticationException("账号已禁用");
} log.error("登录失败,账号已禁用 loginParam:{}", loginParam);
return ApiResult.fail(ApiCode.USER_NOT_FOUND, language);
// 将系统用户对象转换成登录用户对象 }
// 将系统用户对象转换成登录用户对象
LoginUserVo loginSysUserVo = new LoginUserVo(); LoginUserVo loginSysUserVo = new LoginUserVo();
loginSysUserVo.setId(appUser.getId()); loginSysUserVo.setId(appUser.getId());
...@@ -140,7 +141,7 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser> ...@@ -140,7 +141,7 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser>
loginAppUserTokenVo.setToken(token); loginAppUserTokenVo.setToken(token);
loginAppUserTokenVo.setId(appUser.getId()); loginAppUserTokenVo.setId(appUser.getId());
loginAppUserTokenVo.setHasRegister(hasRegister); loginAppUserTokenVo.setHasRegister(hasRegister);
return ApiResult.ok(loginAppUserTokenVo, language); return ApiResult.ok(loginAppUserTokenVo);
} }
......
...@@ -184,7 +184,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -184,7 +184,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
// 设置token响应头 // 设置token响应头
response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken()); response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken());
return ApiResult.ok(loginSysUserTokenVo, language); return ApiResult.ok(loginSysUserTokenVo);
} }
......
package com.jumeirah.common.service.impl; package com.jumeirah.common.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.mapper.StrokeMapper; import com.jumeirah.common.mapper.StrokeMapper;
import com.jumeirah.common.service.StrokeService;
import com.jumeirah.common.param.StrokePageParam; import com.jumeirah.common.param.StrokePageParam;
import com.jumeirah.common.service.StrokeService;
import com.jumeirah.common.vo.StrokeDetailVo;
import com.jumeirah.common.vo.StrokeQueryVo; import com.jumeirah.common.vo.StrokeQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl; import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo; import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 行程表 服务实现类 * 行程表 服务实现类
...@@ -44,18 +47,29 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp ...@@ -44,18 +47,29 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean deleteStroke(Long id) throws Exception { public boolean deleteStroke(Long id) throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
Stroke byId = super.getById(id);
// 判断该记录是否属于此用户
if (!byId.getUserId().equals(jwtToken.getUserId())) {
return false;
}
return super.removeById(id); return super.removeById(id);
} }
@Override @Override
public StrokeQueryVo getStrokeById(Long id) throws Exception { public StrokeDetailVo getStrokeById(Long id) throws Exception {
return strokeMapper.getStrokeById(id); return strokeMapper.getStrokeById(id);
} }
@Override @Override
public Paging<StrokeQueryVo> getStrokePageList(StrokePageParam strokePageParam) throws Exception { public Paging<StrokeQueryVo> getStrokePageList(StrokePageParam strokePageParam) throws Exception {
Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.desc(getLambdaColumn(Stroke::getCreateTime))); Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.asc(getLambdaColumn(Stroke::getCreateTime)));
IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageList(page, strokePageParam);
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageList(page, strokePageParam, jwtToken.getUserId());
return new Paging<StrokeQueryVo>(iPage); return new Paging<StrokeQueryVo>(iPage);
} }
......
...@@ -189,7 +189,7 @@ public class SysLoginServiceImpl implements SysLoginService { ...@@ -189,7 +189,7 @@ public class SysLoginServiceImpl implements SysLoginService {
// 设置token响应头 // 设置token响应头
response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken()); response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken());
return ApiResult.ok(loginSysUserTokenVo, language); return ApiResult.ok(loginSysUserTokenVo);
} }
@Override @Override
......
package com.jumeirah.common.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* <pre>
* 行程表 查询结果对象
* </pre>
*
* @author wei
* @date 2020-09-29
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "StrokeDetailVo对象")
public class StrokeDetailVo implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "出发城市id不能为空")
@ApiModelProperty("出发城市id")
private Long cityOutsetId;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
@TableLogic
private Integer deleted;
@NotBlank(message = "出发城市名称不能为空")
@ApiModelProperty("出发城市名称")
private String cityOutsetName;
@NotNull(message = "到达城市id不能为空")
@ApiModelProperty("到达城市id")
private Long cityArriveId;
@NotBlank(message = "到达城市名称不能为空")
@ApiModelProperty("到达城市名称")
private String cityArriveName;
@NotNull(message = "人数不能为空")
@ApiModelProperty("人数")
private Integer peopleMun;
@NotNull(message = "飞机型号ID不能为空")
@ApiModelProperty("飞机型号ID")
private Long plainTypeId;
@NotNull(message = "出发时间不能为空")
@ApiModelProperty("出发时间")
private Long outsetTime;
@ApiModelProperty("返程时间")
private Long returnTime;
@NotNull(message = "行程类型,0-单程,1-往返行程,2-货运,3-医疗不能为空")
@ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗")
private Integer type;
@NotNull(message = "状态,0-审核中,1-进行中,2-已完成,99-取消不能为空")
@ApiModelProperty("状态,0-审核中,1-进行中,2-已完成,99-取消")
private Integer status;
@NotNull(message = "创建时间不能为空")
@ApiModelProperty("创建时间")
private Long createTime;
@ApiModelProperty("更新时间")
private Long updateTime;
@ApiModelProperty("货物名称")
private String goodsName;
@ApiModelProperty("货物体积(长*宽*高) 单位:CM,例如:100*102*120")
private String goodsSize;
@ApiModelProperty("货物重量,单位:吨")
private Double goodsWeight;
@ApiModelProperty("病人疾病名称")
private String diseaseName;
@ApiModelProperty("病人病情诊断书")
private String medicalCertificateUrl;
@ApiModelProperty("配备器械(格式:1,2,3)逗号分隔")
private String instruments;
@ApiModelProperty("医护人员,0-医生,1-护士,2-护工(格式:0,1,2)逗号分隔")
private String medicalPersons;
@ApiModelProperty("备注")
private String remarks;
@ApiModelProperty("价格,单位:分")
private Long money;
@NotNull(message = "用户ID不能为空")
@ApiModelProperty("用户ID")
private Long userId;
@NotNull(message = "商家id不能为空")
@ApiModelProperty("商家id")
private Long mcId;
@NotNull(message = "用户选择机型不能为空")
@ApiModelProperty("用户选择机型")
private Long choosePlainType;
}
\ No newline at end of file
package com.jumeirah.common.vo; package com.jumeirah.common.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <pre> * <pre>
...@@ -18,75 +18,36 @@ import java.util.Date; ...@@ -18,75 +18,36 @@ import java.util.Date;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value = "StrokeQueryVo对象") @ApiModel(value = "StrokeQueryVo对象")
public class StrokeQueryVo implements Serializable{ public class StrokeQueryVo implements Serializable {
private static final long serialVersionUID=1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID") @ApiModelProperty("主键ID")
private Long id; private Long id;
@ApiModelProperty("出发城市id")
private Long cityOutsetId;
@ApiModelProperty("出发城市名称") @ApiModelProperty("出发城市名称")
private String cityOutsetName; private String cityOutsetName;
@ApiModelProperty("到达城市id")
private Long cityArriveId;
@ApiModelProperty("到达城市名称") @ApiModelProperty("到达城市名称")
private String cityArriveName; private String cityArriveName;
@ApiModelProperty("人数")
private Integer peopleMun;
@ApiModelProperty("飞机型号ID")
private Long plainTypeId;
@ApiModelProperty("出发时间") @ApiModelProperty("出发时间")
private Date outsetTime; private Long outsetTime;
@ApiModelProperty("返程时间") @ApiModelProperty("返程时间")
private Date returnTime; private Long returnTime;
@ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗") @ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗")
private Integer type; private Integer type;
@ApiModelProperty("状态,0-审核中,1-进行中,2-已完成,99-取消") @ApiModelProperty("状态,0-审核中,1-进行中,2-已完成,99-取消")
private Integer status; private Integer status;
@ApiModelProperty("创建时间")
private Long createTime;
@ApiModelProperty("更新时间")
private Long updateTime;
@ApiModelProperty("货物名称")
private String goodsName;
@ApiModelProperty("货物体积(长*宽*高) 单位:CM,例如:100*102*120")
private String goodsSize;
@ApiModelProperty("货物重量,单位:吨")
private Double goodsWeight;
@ApiModelProperty("病人疾病名称")
private String diseaseName;
@ApiModelProperty("病人病情诊断书")
private String aegerUrl;
@ApiModelProperty("配备器械(格式:1,2,3)逗号分隔")
private String instruments;
@ApiModelProperty("医护人员,0-医生,1-护士,2-护工(格式:0,1,2)逗号分隔")
private String medicalPersons;
@ApiModelProperty("备注") @ApiModelProperty("备注")
private String remarks; private String remarks;
@ApiModelProperty("价格,单位:分") @ApiModelProperty("价格,单位:分")
private Long money; private Long money;
@ApiModelProperty("用户ID") @ApiModelProperty("用户ID")
private Long userId; private Long userId;
} }
\ No newline at end of file
...@@ -3,20 +3,35 @@ ...@@ -3,20 +3,35 @@
<mapper namespace="com.jumeirah.common.mapper.StrokeMapper"> <mapper namespace="com.jumeirah.common.mapper.StrokeMapper">
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Page_Column_List">
id, city_outset_id, city_outset_name, city_arrive_id, city_arrive_name, people_mun, plain_type_id, outset_time, return_time, type, status, money, user_id
</sql>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, city_outset_id, city_outset_name, city_arrive_id, city_arrive_name, people_mun, plain_type_id, outset_time, return_time, type, status, create_time, update_time, goods_name, goods_size, goods_weight, disease_name, aeger_url, instruments, medical_persons, remarks, money, user_id id, city_outset_id, deleted, city_outset_name, city_arrive_id, city_arrive_name, people_mun, plain_type_id, outset_time, return_time, type, status, create_time, update_time, goods_name, goods_size, goods_weight, disease_name, instruments, medical_persons, remarks, money, user_id
</sql> </sql>
<select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeQueryVo"> <select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeDetailVo">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from stroke where id = #{id} from stroke where id = #{id}
</select> </select>
<select id="getStrokePageList" parameterType="com.jumeirah.common.param.StrokePageParam" resultType="com.jumeirah.common.vo.StrokeQueryVo"> <select id="getStrokePageList" parameterType="com.jumeirah.common.param.StrokePageParam"
resultType="com.jumeirah.common.vo.StrokeQueryVo">
select select
<include refid="Base_Column_List"/> <include refid="Page_Column_List"/>
from stroke from stroke
<where>
and user_id = #{userId}
and deleted = 0
<if test="param.status != -1">
-- -1: 查询全部
and `status` = #{param.status}
</if>
</where>
</select> </select>
</mapper> </mapper>
#/** #/**
#* 操作成功 #* 操作成功
#**/ #**/
api.response.code.SUCCESS=SUCCESS api.response.code.SUCCESS=success
#/** #/**
#* 非法访问 #* 非法访问
#**/ #**/
...@@ -76,3 +76,5 @@ api.response.code.JWTDECODE_EXCEPTION=JWTDECODE_EXCEPTION ...@@ -76,3 +76,5 @@ api.response.code.JWTDECODE_EXCEPTION=JWTDECODE_EXCEPTION
#*/ #*/
api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION
api.response.code.user.PWD_OR_USERNAME_ERROR=password or phone number error api.response.code.user.PWD_OR_USERNAME_ERROR=password or phone number error
api.response.code.user.SMS_CODE_ERROR=sms code error
api.response.code.user.USER_NOT_FOUND=user not found
\ No newline at end of file
...@@ -76,3 +76,5 @@ api.response.code.JWTDECODE_EXCEPTION=JWTDECODE_EXCEPTION ...@@ -76,3 +76,5 @@ api.response.code.JWTDECODE_EXCEPTION=JWTDECODE_EXCEPTION
#*/ #*/
api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION
api.response.code.user.PWD_OR_USERNAME_ERROR=password or phone number error KH api.response.code.user.PWD_OR_USERNAME_ERROR=password or phone number error KH
api.response.code.user.SMS_CODE_ERROR=sms code error
api.response.code.user.USER_NOT_FOUND=user not found
\ No newline at end of file
...@@ -76,3 +76,5 @@ api.response.code.JWTDECODE_EXCEPTION=Token解析异常 ...@@ -76,3 +76,5 @@ api.response.code.JWTDECODE_EXCEPTION=Token解析异常
#*/ #*/
api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=默认的异常处理 api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=默认的异常处理
api.response.code.user.PWD_OR_USERNAME_ERROR=账号或密码错误 api.response.code.user.PWD_OR_USERNAME_ERROR=账号或密码错误
api.response.code.user.SMS_CODE_ERROR=验证码错误
api.response.code.user.USER_NOT_FOUND=用户不存在
\ No newline at end of file
...@@ -107,7 +107,16 @@ public enum ApiCode { ...@@ -107,7 +107,16 @@ public enum ApiCode {
/** /**
* 账号或密码错误 * 账号或密码错误
*/ */
PWD_OR_USERNAME_ERROR(6001, "api.response.code.user.PWD_OR_USERNAME_ERROR"); PWD_OR_USERNAME_ERROR(6001, "api.response.code.user.PWD_OR_USERNAME_ERROR"),
/**
* 验证码错误
*/
SMS_CODE_ERROR(6002, "api.response.code.user.SMS_CODE_ERROR"),
/**
* 用户不存在
*/
USER_NOT_FOUND(6003, "api.response.code.user.USER_NOT_FOUND");
private final int code; private final int code;
private final String message; private final String message;
......
...@@ -18,11 +18,13 @@ package io.geekidea.springbootplus.framework.common.api; ...@@ -18,11 +18,13 @@ package io.geekidea.springbootplus.framework.common.api;
import io.geekidea.springbootplus.framework.config.il8n.I18nMessageUtil; import io.geekidea.springbootplus.framework.config.il8n.I18nMessageUtil;
import io.geekidea.springbootplus.framework.config.il8n.LanguageEnum; import io.geekidea.springbootplus.framework.config.il8n.LanguageEnum;
import io.geekidea.springbootplus.framework.util.HttpServletRequestUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
...@@ -82,25 +84,30 @@ public class ApiResult<T> implements Serializable { ...@@ -82,25 +84,30 @@ public class ApiResult<T> implements Serializable {
return fail(); return fail();
} }
public static ApiResult<Boolean> result(ApiCode apiCode) { public static ApiResult<Boolean> result(ApiCode apiCode) {
return result(apiCode, null); return result(apiCode, null);
} }
public static <T> ApiResult<T> result(ApiCode apiCode, T data) { public static <T> ApiResult<T> result(ApiCode apiCode, T data) {
return result(apiCode, null, data, null); return result(apiCode, null, data);
} }
public static <T> ApiResult<T> result(ApiCode apiCode, T data, String language) { public static <T> ApiResult<T> result(ApiCode apiCode, T data, String language) {
return result(apiCode, null, data, language); return result(apiCode, null, data);
} }
public static <T> ApiResult<T> result(ApiCode apiCode, String message, T data, String language) { public static <T> ApiResult<T> result(ApiCode apiCode, String message, T data) {
// boolean success = false; // boolean success = false;
// if (apiCode.getCode() == ApiCode.SUCCESS.getCode()) { // if (apiCode.getCode() == ApiCode.SUCCESS.getCode()) {
// success = true; // success = true;
// } // }
// 多语言国际化,根据http上下文, 取得heard中的language语言属性,实现不用在业务代码中传递语言字段
HttpServletRequest request = HttpServletRequestUtil.getRequest();
String language = request.getHeader("language");
String success = "SUCCESS"; String success = "SUCCESS";
try { try {
message = I18nMessageUtil.getMessage(LanguageEnum.getLanguageType(language), apiCode.getMessage(), success); message = I18nMessageUtil.getMessage(LanguageEnum.getLanguageType(language), apiCode.getMessage(), success);
...@@ -126,9 +133,6 @@ public class ApiResult<T> implements Serializable { ...@@ -126,9 +133,6 @@ public class ApiResult<T> implements Serializable {
return result(ApiCode.SUCCESS, data); return result(ApiCode.SUCCESS, data);
} }
public static <T> ApiResult<T> ok(T data, String language) {
return result(ApiCode.SUCCESS, data, language);
}
// public static <T> ApiResult<T> ok(T data, String message) { // public static <T> ApiResult<T> ok(T data, String message) {
// return result(ApiCode.SUCCESS, message, data); // return result(ApiCode.SUCCESS, message, data);
...@@ -145,20 +149,15 @@ public class ApiResult<T> implements Serializable { ...@@ -145,20 +149,15 @@ public class ApiResult<T> implements Serializable {
} }
public static <T> ApiResult<T> fail(ApiCode apiCode, String language) { public static <T> ApiResult<T> fail(ApiCode apiCode, String language) {
return result(apiCode, null, language); return result(apiCode, null);
} }
// public static ApiResult<String> fail(String message) {
// return result(ApiCode.FAIL, message, null);
// }
public static <T> ApiResult<T> fail(ApiCode apiCode, T data) { public static <T> ApiResult<T> fail(ApiCode apiCode, T data) {
if (ApiCode.SUCCESS == apiCode) { if (ApiCode.SUCCESS == apiCode) {
throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode()); throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode());
} }
return result(apiCode, data); return result(apiCode, data);
} }
public static ApiResult<String> fail(Integer errorCode, String message) { public static ApiResult<String> fail(Integer errorCode, String message) {
...@@ -177,4 +176,8 @@ public class ApiResult<T> implements Serializable { ...@@ -177,4 +176,8 @@ public class ApiResult<T> implements Serializable {
public static ApiResult<Boolean> fail() { public static ApiResult<Boolean> fail() {
return fail(ApiCode.FAIL); return fail(ApiCode.FAIL);
} }
public static ApiResult<Boolean> fail(String language) {
return fail(ApiCode.FAIL, language);
}
} }
\ No newline at end of file
...@@ -16,10 +16,10 @@ public enum LanguageEnum { ...@@ -16,10 +16,10 @@ public enum LanguageEnum {
*/ */
LANGUAGE_EN_US("en_US"), LANGUAGE_EN_US("en_US"),
/** // /**
* 柬埔寨 高棉语 // * 柬埔寨 高棉语
*/ // */
LANGUAGE_KH("kh"), // LANGUAGE_KH("kh"),
/** /**
* 简体中文 * 简体中文
......
...@@ -36,7 +36,7 @@ import java.util.List; ...@@ -36,7 +36,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel("可排序查询参数对象") @ApiModel("可排序查询参数对象")
public abstract class BasePageOrderParam extends BasePageParam { public abstract class BasePageOrderParam extends BasePageParam {
private static final long serialVersionUID = 57714391204790143L; private static final long serialVersionUID = 57714391204790143L;
@ApiModelProperty("排序") @ApiModelProperty("排序")
private List<OrderItem> pageSorts; private List<OrderItem> pageSorts;
......
...@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
/** /**
* 获取当前请求的HttpServletRequest对象 * 获取当前请求的HttpServletRequest对象
* http上下文对象
* *
* @author geekidea * @author geekidea
* @date 2018-11-08 * @date 2018-11-08
......
...@@ -51,7 +51,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -51,7 +51,6 @@ import org.springframework.web.bind.annotation.*;
#end #end
@RequestMapping("/${cfg.entityObjectName}") @RequestMapping("/${cfg.entityObjectName}")
#if(${cfg.operationLog}) #if(${cfg.operationLog})
@Module("${cfg.module}")
#end #end
#if(${cfg.swaggerTags}) #if(${cfg.swaggerTags})
@Api(value = "$!{table.comment}API", tags = {"$!{table.comment}"}) @Api(value = "$!{table.comment}API", tags = {"$!{table.comment}"})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment