Commit 2f573997 by testdl

Merge branch 'master' of http://119.28.51.83/hewei/Jumeirah into dev/lanpingxiong

parents 0ea49585 ced56c6f
......@@ -13,10 +13,11 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
/**
*
* Hello World Controller
**/
@Slf4j
@Api(value = "Hello World2", tags = {"APP Hello World2"})
@Api(value = "权限测试", tags = {"APP Hello World2"})
@RestController
@RequestMapping("/app")
//@Module("api-app")
......
package com.jumeirah.api.app.controller;
import com.jumeirah.api.app.service.AppSmsService;
import com.jumeirah.api.app.vo.SmsCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
......@@ -36,10 +35,10 @@ public class AppSmsController extends BaseController {
*/
@GetMapping("/registerOrLoginCode")
@OperationLog(name = "获取注册或登陆的验证码", type = OperationLogType.INFO)
@ApiOperation(value = "获取注册或登陆的验证码", response = SmsCode.class, notes = "本地环境默认666666")
public ApiResult<Object> register(@RequestParam String phoneArea, @RequestParam String phone) throws Exception {
@ApiOperation(value = "获取注册或登陆的验证码", response = Object.class, notes = "本地环境默认666666")
public ApiResult<Object> registerOrLoginCode(@RequestParam String phoneArea, @RequestParam String phone) throws Exception {
return appSmsService.registerType(phoneArea, phone);
return appSmsService.registerOrLoginCode(phoneArea, phone);
}
}
......
package com.jumeirah.api.app.controller;
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.AppUserInfoParam;
import com.jumeirah.common.service.AppUserService;
import com.jumeirah.common.vo.AppUserQueryVo;
import com.jumeirah.common.vo.LoginSysUserTokenVo;
import com.jumeirah.common.vo.app.LoginAppUserTokenVo;
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.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.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestHeader;
......@@ -54,16 +44,16 @@ public class AppUserController extends BaseController {
* 添加APP用户
*/
@PostMapping("/updateAppUserInfo")
// @OperationLog(name = "补充或修改APP用户信息", type = OperationLogType.ADD)
@ApiOperation(value = "补充或修改APP用户信息", notes = "不需要修改的字段传入null", response = ApiResult.class)
@OperationLog(name = "补充或修改APP用户信息", type = OperationLogType.ADD)
@ApiOperation(value = "补充或修改APP用户信息", notes = "不需要修改的字段传入null或直接不传入该字段,如果传入空双引号的话会将数据置为空 ", response = ApiResult.class)
public ApiResult<Boolean> updateAppUserInfo(@RequestBody AppUserInfoParam appUserInfoParam) throws Exception {
boolean flag = appUserApiService.updateAppUser(appUserInfoParam);
return ApiResult.result(flag);
}
/**
/* *//**
* 添加APP用户
*/
*//*
@PostMapping("/add")
@OperationLog(name = "添加APP用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加APP用户", response = ApiResult.class)
......@@ -73,9 +63,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag);
}
/**
*//**
* 修改APP用户
*/
*//*
@PostMapping("/update")
@OperationLog(name = "修改APP用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改APP用户", response = ApiResult.class)
......@@ -85,9 +75,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag);
}
/**
*//**
* 删除APP用户
*/
*//*
@PostMapping("/delete/{id}")
@OperationLog(name = "删除APP用户", type = OperationLogType.DELETE)
@ApiOperation(value = "删除APP用户", response = ApiResult.class)
......@@ -97,9 +87,9 @@ public class AppUserController extends BaseController {
return ApiResult.result(flag);
}
/**
*//**
* 获取APP用户详情
*/
*//*
@GetMapping("/info/{id}")
@OperationLog(name = "APP用户详情", type = OperationLogType.INFO)
@ApiOperation(value = "APP用户详情", response = AppUserQueryVo.class)
......@@ -109,9 +99,11 @@ public class AppUserController extends BaseController {
return ApiResult.ok(appUserQueryVo);
}
*/
/**
* APP用户分页列表
*/
*//*
@PostMapping("/getPageList")
@OperationLog(name = "APP用户分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "APP用户分页列表", response = AppUserQueryVo.class)
......@@ -119,20 +111,12 @@ public class AppUserController extends BaseController {
public ApiResult<Paging<AppUserQueryVo>> getAppUserPageList(@Validated @RequestBody AppUserPageParam appUserPageParam) throws Exception {
Paging<AppUserQueryVo> paging = appUserService.getAppUserPageList(appUserPageParam);
return ApiResult.ok(paging);
}
}*/
@PostMapping("/registerOrLogin")
@ApiOperation(value = "手机号注册+登陆", notes = "app用户注册+登陆", response = LoginSysUserTokenVo.class)
@ApiOperation(value = "手机号注册+登陆", notes = "app用户注册+登陆", response = LoginAppUserTokenVo.class)
public ApiResult<LoginAppUserTokenVo> registerOrLogin(@Validated @RequestBody AppSmsRegisterParam appSmsRegisterParam, @RequestHeader(required = false) String language) throws Exception {
return appUserApiService.register(appSmsRegisterParam, language);
}
// @PostMapping("/login")
// @ApiOperation(value = "手机号登陆", notes = "app用户登录", response = LoginSysUserTokenVo.class)
// public ApiResult<LoginAppUserTokenVo> login(@Validated @RequestBody AppSmsRegisterParam loginParam, @RequestHeader(required = false) String language) throws Exception {
//// return appRegisterService.login(loginParam, language);
// return null;
// }
}
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.StrokeAddFreightVo;
import com.jumeirah.api.app.entity.vo.StrokeAddMedicalTreatmentVo;
import com.jumeirah.api.app.entity.vo.StrokeAddOneWayVo;
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 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 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.common.param.IdParam;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
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.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.swagger.annotations.Api;
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.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;
/**
* 行程表 控制器
......@@ -36,9 +38,8 @@ import org.springframework.web.bind.annotation.*;
*/
@Slf4j
@RestController
@RequestMapping("/stroke")
@Module("${cfg.module}")
@Api(value = "行程表API", tags = {"行程表"})
@RequestMapping("/app/stroke")
@Api(value = "行程API", tags = {"行程"})
public class StrokeController extends BaseController {
@Autowired
......@@ -54,8 +55,7 @@ public class StrokeController extends BaseController {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
Stroke stroke = new Stroke();
BeanUtils.copyProperties(strokeAddOneWayVo, stroke);
stroke.setType(0)
.setCreateTime(System.currentTimeMillis());
stroke.setType(0);
boolean flag = strokeService.saveStroke(stroke);
return ApiResult.result(flag);
}
......@@ -70,8 +70,7 @@ public class StrokeController extends BaseController {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
Stroke stroke = new Stroke();
BeanUtils.copyProperties(strokeAddBackAndForthVo, stroke);
stroke.setType(1)
.setCreateTime(System.currentTimeMillis());
stroke.setType(1);
boolean flag = strokeService.saveStroke(stroke);
return ApiResult.result(flag);
}
......@@ -86,8 +85,7 @@ public class StrokeController extends BaseController {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
Stroke stroke = new Stroke();
BeanUtils.copyProperties(strokeAddFreightVo, stroke);
stroke.setType(2)
.setCreateTime(System.currentTimeMillis());
stroke.setType(2);
boolean flag = strokeService.saveStroke(stroke);
return ApiResult.result(flag);
}
......@@ -103,8 +101,7 @@ public class StrokeController extends BaseController {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
Stroke stroke = new Stroke();
BeanUtils.copyProperties(strokeAddMedicalTreatmentVo, stroke);
stroke.setType(3)
.setCreateTime(System.currentTimeMillis());
stroke.setType(3);
boolean flag = strokeService.saveStroke(stroke);
return ApiResult.result(flag);
}
......@@ -137,19 +134,30 @@ public class StrokeController extends BaseController {
*/
@GetMapping("/info/{id}")
@OperationLog(name = "行程表详情", type = OperationLogType.INFO)
@ApiOperation(value = "行程表详情", response = StrokeQueryVo.class)
public ApiResult<StrokeQueryVo> getStroke(@PathVariable("id") Long id) throws Exception {
StrokeQueryVo strokeQueryVo = strokeService.getStrokeById(id);
@ApiOperation(value = "行程表详情", response = StrokeDetailVo.class)
public ApiResult<StrokeDetailVo> getStroke(@PathVariable("id") Long id) throws Exception {
StrokeDetailVo strokeQueryVo = strokeService.getStrokeById(id);
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")
@OperationLog(name = "行程分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "行程表分页列表", response = StrokeQueryVo.class)
public ApiResult<Paging<StrokeQueryVo>> getStrokePageList(@Validated @RequestBody StrokePageParam strokePageParam) throws Exception {
@PostMapping("/getMyStrokePageList")
@OperationLog(name = "行程分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "行程分页列表")
public ApiResult<Paging<StrokeQueryVo>> getMyStrokePageList(@Validated @RequestBody StrokePageParam strokePageParam) throws Exception {
Paging<StrokeQueryVo> paging = strokeService.getStrokePageList(strokePageParam);
return ApiResult.ok(paging);
}
......
......@@ -9,7 +9,7 @@ public interface AppSmsService {
/**
* 获取注册验证码
*/
ApiResult<Object> registerType(String phoneArea, String phone);
ApiResult<Object> registerOrLoginCode(String phoneArea, String phone);
/**
* 获取注册验证码
......
......@@ -15,7 +15,7 @@ public interface AppUserApiService {
* @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;
/**
* 修改或补充用户信息
......
......@@ -52,7 +52,7 @@ public class AppSmsServiceImpl implements AppSmsService {
}
@Override
public ApiResult<Object> registerType(String area, String number) {
public ApiResult<Object> registerOrLoginCode(String area, String number) {
return getSmsCodeApiResult(String.format(SMS_REGIEST, area, number), area, number);
}
......
......@@ -29,14 +29,14 @@ public class AppUserApiServiceImpl implements AppUserApiService {
// 校验验证码
boolean equalsRegisterCode = appSmsService.equalsRegisterCode(loginParam.getPhoneArea(), loginParam.getPhone(), loginParam.getSmsCode());
if (!equalsRegisterCode) {
return ApiResult.fail(ApiCode.FAIL, new LoginAppUserTokenVo());
return ApiResult.fail(ApiCode.SMS_CODE_ERROR, new LoginAppUserTokenVo());
}
// 删除已使用的验证码
appSmsService.deleteRegisterCode(loginParam.getPhoneArea(), loginParam.getPhone());
// 判断是否已经注册
if (appUserService.hasUserByPhoneNumer(loginParam.getPhoneArea(), loginParam.getPhone())) {
// 如果已经注册直接走登陆的代码
return appUserService.login(loginParam, language);
return appUserService.login(loginParam, language, true);
}
// 没注册则先保存到数据库
......@@ -45,17 +45,17 @@ public class AppUserApiServiceImpl implements AppUserApiService {
appUser.setPhone(loginParam.getPhone());
boolean isDbOk = appUserService.saveAppUser(appUser);
if (!isDbOk) {
return ApiResult.fail(ApiCode.FAIL, new LoginAppUserTokenVo());
return ApiResult.fail(ApiCode.SPRING_BOOT_PLUS_EXCEPTION, new LoginAppUserTokenVo());
}
// 走登陆的代码
return appUserService.login(loginParam, language);
return appUserService.login(loginParam, language, false);
}
@Override
public ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception {
return null;
}
// @Override
// public ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception {
// return null;
// }
@Override
public boolean updateAppUser(AppUserInfoParam appUserInfoParam) throws Exception {
......
package com.jumeirah.common.entity;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
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.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.ApiModelProperty;
import lombok.Data;
......@@ -15,8 +13,7 @@ import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import java.sql.Timestamp;
/**
* 行程表
......@@ -40,6 +37,10 @@ public class Stroke extends BaseEntity {
@ApiModelProperty("出发城市id")
private Long cityOutsetId;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
@TableLogic
private Integer deleted;
@NotBlank(message = "出发城市名称不能为空")
@ApiModelProperty("出发城市名称")
private String cityOutsetName;
......@@ -62,10 +63,10 @@ public class Stroke extends BaseEntity {
@NotNull(message = "出发时间不能为空")
@ApiModelProperty("出发时间")
private Long outsetTime;
private Timestamp outsetTime;
@ApiModelProperty("返程时间")
private Long returnTime;
private Timestamp returnTime;
@NotNull(message = "行程类型,0-单程,1-往返行程,2-货运,3-医疗不能为空")
@ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗")
......@@ -77,10 +78,10 @@ public class Stroke extends BaseEntity {
@NotNull(message = "创建时间不能为空")
@ApiModelProperty("创建时间")
private Long createTime;
private Timestamp createTime;
@ApiModelProperty("更新时间")
private Long updateTime;
private Timestamp updateTime;
@ApiModelProperty("货物名称")
private String goodsName;
......@@ -113,6 +114,26 @@ public class Stroke extends BaseEntity {
@ApiModelProperty("用户ID")
private Long userId;
@NotBlank(message = "出发机场名称不能为空")
@ApiModelProperty("出发机场名称")
private String outsetAirportName;
@NotBlank(message = "到达机场名称不能为空")
@ApiModelProperty("到达机场名称")
private String arriveAirportName;
@NotNull(message = "返程飞机型号ID为空")
@ApiModelProperty("返程飞机型号ID")
private Long arrivePlainTypeId;
@NotBlank(message = "返程出发机场名称不能为空")
@ApiModelProperty("返程出发机场名称")
private String backOutsetAirportName;
@NotBlank(message = "返程到达机场名称不能为空")
@ApiModelProperty("返程到达机场名称")
private String backArriveAirportName;
@NotNull(message = "商家id不能为空")
@ApiModelProperty("商家id")
private Long mcId;
......
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;
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.param.StrokePageParam;
import com.jumeirah.common.vo.StrokeDetailVo;
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.springframework.stereotype.Repository;
import java.io.Serializable;
......@@ -22,21 +21,21 @@ import java.io.Serializable;
@Repository
public interface StrokeMapper extends BaseMapper<Stroke> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
StrokeQueryVo getStrokeById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param strokePageParam
* @return
*/
IPage<StrokeQueryVo> getStrokePageList(@Param("page") Page page,@Param("param") StrokePageParam strokePageParam);
}
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
StrokeDetailVo getStrokeById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param strokePageParam
* @return
*/
IPage<StrokeQueryVo> getStrokePageList(@Param("page") Page page, @Param("param") StrokePageParam strokePageParam, @Param("userId") Long userId);
}
package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/**
* <pre>
......@@ -18,6 +19,10 @@ import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "行程表分页参数")
public class StrokePageParam extends BasePageOrderParam{
private static final long serialVersionUID=1L;
}
public class StrokePageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty("行程状态,-1=全部, 0-审核中,1-进行中,2-已完成")//99-取消
private Integer status;
}
......@@ -30,7 +30,7 @@ import java.io.Serializable;
* @date 2019-05-15
**/
@Data
@ApiModel("app手机验证码注册参数")
@ApiModel("app手机验证码注册参数AppSmsRegisterParam")
public class AppSmsRegisterParam implements Serializable {
@NotBlank(message = "请输入手机区号")
......
......@@ -34,8 +34,8 @@ public class AppUserInfoParam extends BaseEntity {
@ApiModelProperty("出生日期")
private String dateOfBirth;
@ApiModelProperty("昵称")
private String nickname;
// @ApiModelProperty("昵称")
// private String nickname;
@ApiModelProperty("性别,0:女,1:男,默认1")
private Integer gender;
......
......@@ -41,7 +41,7 @@ public interface AppUserService extends BaseService<AppUser> {
* @param language
* @return
*/
ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language);
ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language,Boolean hasRegister);
/**
......
......@@ -2,8 +2,9 @@ package com.jumeirah.common.service;
import com.jumeirah.common.entity.Stroke;
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 io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
......@@ -48,7 +49,7 @@ public interface StrokeService extends BaseService<Stroke> {
* @return
* @throws Exception
*/
StrokeQueryVo getStrokeById(Long id) throws Exception;
StrokeDetailVo getStrokeById(Long id) throws Exception;
/**
* 获取分页对象
......
......@@ -27,8 +27,8 @@ import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -83,7 +83,7 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser>
// }
@Override
public ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) {
public ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language, Boolean hasRegister) {
// 从数据库中获取登录用户信息
AppUser appUser = appUserMapper.selectOne(new QueryWrapper<>(
......@@ -92,13 +92,15 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser>
if (appUser == null) {
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())) {
throw new AuthenticationException("账号已禁用");
}
// throw new AuthenticationException("账号已禁用");
log.error("登录失败,账号已禁用 loginParam:{}", loginParam);
return ApiResult.fail(ApiCode.USER_NOT_FOUND, language);
// 将系统用户对象转换成登录用户对象
}
// 将系统用户对象转换成登录用户对象
LoginUserVo loginSysUserVo = new LoginUserVo();
loginSysUserVo.setId(appUser.getId());
......@@ -134,10 +136,12 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser>
redisTemplate.opsForValue().set(tokenSha256, loginSysUserVo, 1, TimeUnit.DAYS);
// 返回token和登录用户信息对象
LoginAppUserTokenVo loginSysUserTokenVo = new LoginAppUserTokenVo();
loginSysUserTokenVo.setToken(token);
loginSysUserTokenVo.setUserId(appUser.getId());
return ApiResult.ok(loginSysUserTokenVo, language);
LoginAppUserTokenVo loginAppUserTokenVo = new LoginAppUserTokenVo();
BeanUtils.copyProperties(appUser, loginAppUserTokenVo);
loginAppUserTokenVo.setToken(token);
loginAppUserTokenVo.setId(appUser.getId());
loginAppUserTokenVo.setHasRegister(hasRegister);
return ApiResult.ok(loginAppUserTokenVo);
}
......
......@@ -184,7 +184,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
// 设置token响应头
response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken());
return ApiResult.ok(loginSysUserTokenVo, language);
return ApiResult.ok(loginSysUserTokenVo);
}
......
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.mapper.StrokeMapper;
import com.jumeirah.common.service.StrokeService;
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 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 com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 行程表 服务实现类
......@@ -44,18 +47,29 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp
@Transactional(rollbackFor = Exception.class)
@Override
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);
}
@Override
public StrokeQueryVo getStrokeById(Long id) throws Exception {
public StrokeDetailVo getStrokeById(Long id) throws Exception {
return strokeMapper.getStrokeById(id);
}
@Override
public Paging<StrokeQueryVo> getStrokePageList(StrokePageParam strokePageParam) throws Exception {
Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.desc(getLambdaColumn(Stroke::getCreateTime)));
IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageList(page, strokePageParam);
Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.asc(getLambdaColumn(Stroke::getCreateTime)));
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageList(page, strokePageParam, jwtToken.getUserId());
return new Paging<StrokeQueryVo>(iPage);
}
......
......@@ -189,7 +189,7 @@ public class SysLoginServiceImpl implements SysLoginService {
// 设置token响应头
response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken());
return ApiResult.ok(loginSysUserTokenVo, language);
return ApiResult.ok(loginSysUserTokenVo);
}
@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;
import java.math.BigDecimal;
import java.sql.Timestamp;
/**
* <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 Timestamp outsetTime;
@ApiModelProperty("返程时间")
private Timestamp 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 Timestamp createTime;
@ApiModelProperty("更新时间")
private Timestamp 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 BigDecimal money;
@NotNull(message = "用户ID不能为空")
@ApiModelProperty("用户ID")
private Long userId;
@NotNull(message = "商家id不能为空")
@ApiModelProperty("商家id")
private Long mcId;
@NotNull(message = "用户选择机型不能为空")
@ApiModelProperty("用户选择机型")
private Long choosePlainType;
@NotBlank(message = "出发机场名称不能为空")
@ApiModelProperty("出发机场名称")
private String outsetAirportName;
@NotBlank(message = "到达机场名称不能为空")
@ApiModelProperty("到达机场名称")
private String arriveAirportName;
@NotNull(message = "返程飞机型号ID为空")
@ApiModelProperty("返程飞机型号ID")
private Long arrivePlainTypeId;
@NotBlank(message = "返程出发机场名称不能为空")
@ApiModelProperty("返程出发机场名称")
private String backOutsetAirportName;
@NotBlank(message = "返程到达机场名称不能为空")
@ApiModelProperty("返程到达机场名称")
private String backArriveAirportName;
@ApiModelProperty("商家名称")
private String merchantName;
}
\ No newline at end of file
package com.jumeirah.common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
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;
import java.util.Date;
import java.math.BigDecimal;
import java.sql.Timestamp;
/**
* <pre>
......@@ -18,75 +22,56 @@ import java.util.Date;
@Data
@Accessors(chain = true)
@ApiModel(value = "StrokeQueryVo对象")
public class StrokeQueryVo implements Serializable{
private static final long serialVersionUID=1L;
public class StrokeQueryVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("出发城市id")
private Long cityOutsetId;
private Long id;
@ApiModelProperty("出发城市名称")
private String cityOutsetName;
@ApiModelProperty("到达城市id")
private Long cityArriveId;
private String cityOutsetName;
@ApiModelProperty("到达城市名称")
private String cityArriveName;
@ApiModelProperty("人数")
private Integer peopleMun;
@ApiModelProperty("飞机型号ID")
private Long plainTypeId;
private String cityArriveName;
@ApiModelProperty("出发时间")
private Date outsetTime;
private Timestamp outsetTime;
@ApiModelProperty("返程时间")
private Date returnTime;
private Timestamp returnTime;
@ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗")
private Integer type;
private Integer type;
@ApiModelProperty("状态,0-审核中,1-进行中,2-已完成,99-取消")
private Integer status;
@ApiModelProperty("创建时间")
private Long createTime;
private Integer status;
@ApiModelProperty("更新时间")
private Long updateTime;
@ApiModelProperty("价格")
private BigDecimal money;
@ApiModelProperty("货物名称")
private String goodsName;
@ApiModelProperty("货物体积(长*宽*高) 单位:CM,例如:100*102*120")
private String goodsSize;
@ApiModelProperty("货物重量,单位:吨")
private Double goodsWeight;
@ApiModelProperty("病人疾病名称")
private String diseaseName;
@ApiModelProperty("用户ID")
private Long userId;
@ApiModelProperty("病人病情诊断书")
private String aegerUrl;
@ApiModelProperty("商家名称")
private String merchantName;
@ApiModelProperty("配备器械(格式:1,2,3)逗号分隔")
private String instruments;
@NotBlank(message = "出发机场名称不能为空")
@ApiModelProperty("出发机场名称")
private String outsetAirportName;
@ApiModelProperty("医护人员,0-医生,1-护士,2-护工(格式:0,1,2)逗号分隔")
private String medicalPersons;
@NotBlank(message = "到达机场名称不能为空")
@ApiModelProperty("到达机场名称")
private String arriveAirportName;
@ApiModelProperty("备注")
private String remarks;
@NotNull(message = "返程飞机型号ID为空")
@ApiModelProperty("返程飞机型号ID")
private Long arrivePlainTypeId;
@ApiModelProperty("价格,单位:分")
private Long money;
@NotBlank(message = "返程出发机场名称不能为空")
@ApiModelProperty("返程出发机场名称")
private String backOutsetAirportName;
@ApiModelProperty("用户ID")
private Long userId;
@NotBlank(message = "返程到达机场名称不能为空")
@ApiModelProperty("返程到达机场名称")
private String backArriveAirportName;
}
\ No newline at end of file
......@@ -28,23 +28,48 @@ import lombok.experimental.Accessors;
**/
@Data
@Accessors(chain = true)
@ApiModel("登录用户信息TokenVO")
@ApiModel("登录用户信息LoginAppUserTokenVo")
public class LoginAppUserTokenVo implements LoginToken {
@ApiModelProperty("token")
private String token;
@ApiModelProperty("主键")
private Long userId;
private Long id;
@ApiModelProperty("用户名")
private String username;
// @ApiModelProperty("用户名")
// private String username;
@ApiModelProperty("是否已经注册, true = 已经注册, false = 没有注册")
private Boolean hasRegister;
@ApiModelProperty("姓")
private String surname;
@ApiModelProperty("名")
private String name;
@ApiModelProperty("公司名")
private String companyName;
@ApiModelProperty("微信号")
private String wechat;
@ApiModelProperty("出生日期")
private String dateOfBirth;
// @ApiModelProperty("昵称")
// private String nickname;
// /**
// * 登录用户对象
// */
// private LoginUserVo loginSysUserVo;
@ApiModelProperty("手机号码")
private String phone;
@ApiModelProperty("手机区号")
private String phoneArea;
@ApiModelProperty("性别,0:女,1:男,默认1")
private Integer gender;
@ApiModelProperty("头像")
private String head;
}
......@@ -2,21 +2,53 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jumeirah.common.mapper.StrokeMapper">
<!-- 通用查询结果列 -->
<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
<!-- 分页列表查询结果列 -->
<sql id="Page_Column_List">
s.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,
mu.username AS merchantName
,outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name
</sql>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
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
,outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name
</sql>
<select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeQueryVo">
select
<include refid="Base_Column_List"/>
from stroke where id = #{id}
</select>
<select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeDetailVo">
select
<include refid="Base_Column_List"/>
from stroke where id = #{id}
</select>
<select id="getStrokePageList" parameterType="com.jumeirah.common.param.StrokePageParam"
resultType="com.jumeirah.common.vo.StrokeQueryVo">
select
<include refid="Page_Column_List"/>
from stroke s
INNER JOIN merchant_user mu ON mu.id = s.mc_id
<where>
and s.user_id = #{userId}
and s.deleted = 0
<select id="getStrokePageList" parameterType="com.jumeirah.common.param.StrokePageParam" resultType="com.jumeirah.common.vo.StrokeQueryVo">
select
<include refid="Base_Column_List"/>
from stroke
</select>
<if test="param.status != -1">
-- 查询全部 = -1
and s.`status` = #{param.status}
</if>
</where>
</select>
</mapper>
#/**
#* 操作成功
#**/
api.response.code.SUCCESS=SUCCESS
api.response.code.SUCCESS=success
#/**
#* 非法访问
#**/
......@@ -75,4 +75,6 @@ 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.user.PWD_OR_USERNAME_ERROR=password or phone number error
\ No newline at end of file
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
......@@ -75,4 +75,6 @@ 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.user.PWD_OR_USERNAME_ERROR=password or phone number error KH
\ No newline at end of file
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
......@@ -75,4 +75,6 @@ api.response.code.JWTDECODE_EXCEPTION=Token解析异常
#* 默认的异常处理
#*/
api.response.code.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION=默认的异常处理
api.response.code.user.PWD_OR_USERNAME_ERROR=账号或密码错误
\ No newline at end of file
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
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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 String message;
......
......@@ -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.LanguageEnum;
import io.geekidea.springbootplus.framework.util.HttpServletRequestUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
......@@ -82,25 +84,30 @@ public class ApiResult<T> implements Serializable {
return fail();
}
public static ApiResult<Boolean> result(ApiCode apiCode) {
return result(apiCode, null);
}
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) {
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;
// if (apiCode.getCode() == ApiCode.SUCCESS.getCode()) {
// success = true;
// }
// 多语言国际化,根据http上下文, 取得heard中的language语言属性,实现不用在业务代码中传递语言字段
HttpServletRequest request = HttpServletRequestUtil.getRequest();
String language = request.getHeader("language");
String success = "SUCCESS";
try {
message = I18nMessageUtil.getMessage(LanguageEnum.getLanguageType(language), apiCode.getMessage(), success);
......@@ -126,9 +133,6 @@ public class ApiResult<T> implements Serializable {
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) {
// return result(ApiCode.SUCCESS, message, data);
......@@ -145,20 +149,15 @@ public class ApiResult<T> implements Serializable {
}
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) {
if (ApiCode.SUCCESS == apiCode) {
throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode());
}
return result(apiCode, data);
}
public static ApiResult<String> fail(Integer errorCode, String message) {
......@@ -177,4 +176,8 @@ public class ApiResult<T> implements Serializable {
public static ApiResult<Boolean> 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 {
*/
LANGUAGE_EN_US("en_US"),
/**
* 柬埔寨 高棉语
*/
LANGUAGE_KH("kh"),
// /**
// * 柬埔寨 高棉语
// */
// LANGUAGE_KH("kh"),
/**
* 简体中文
......
......@@ -36,7 +36,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
@ApiModel("可排序查询参数对象")
public abstract class BasePageOrderParam extends BasePageParam {
private static final long serialVersionUID = 57714391204790143L;
private static final long serialVersionUID = 57714391204790143L;
@ApiModelProperty("排序")
private List<OrderItem> pageSorts;
......
......@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
/**
* 获取当前请求的HttpServletRequest对象
* http上下文对象
*
* @author geekidea
* @date 2018-11-08
......
......@@ -34,7 +34,7 @@ public class Jackson {
/**
* 时区
*/
private static final TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
private static final TimeZone timeZone = TimeZone.getTimeZone("GMT");
/**
* 键按自然顺序输出
......@@ -76,7 +76,6 @@ public class Jackson {
* 键按自然顺序格式化输出
*
* @param object
* @param prettyFormat
* @return
*/
public static String toJsonStringNonNull(Object object) {
......
......@@ -51,7 +51,6 @@ import org.springframework.web.bind.annotation.*;
#end
@RequestMapping("/${cfg.entityObjectName}")
#if(${cfg.operationLog})
@Module("${cfg.module}")
#end
#if(${cfg.swaggerTags})
@Api(value = "$!{table.comment}API", tags = {"$!{table.comment}"})
......@@ -82,7 +81,7 @@ private ${table.serviceName} ${cfg.serviceObjectName};
#if(${cfg.operationLog})
@OperationLog(name = "添加$!{table.comment}", type = OperationLogType.ADD)
#end
@ApiOperation(value = "添加$!{table.comment}", response = ApiResult.class)
@ApiOperation(value = "添加$!{table.comment}")
public ApiResult<Boolean> add${entity}(#if(${cfg.paramValidation})@Validated(Add.class) #end@RequestBody ${entity} ${cfg.entityObjectName})throws Exception{
boolean flag= ${cfg.serviceObjectName}.save${entity}(${cfg.entityObjectName});
return ApiResult.result(flag);
......@@ -98,7 +97,7 @@ private ${table.serviceName} ${cfg.serviceObjectName};
#if(${cfg.operationLog})
@OperationLog(name = "修改$!{table.comment}", type = OperationLogType.UPDATE)
#end
@ApiOperation(value = "修改$!{table.comment}", response = ApiResult.class)
@ApiOperation(value = "修改$!{table.comment}")
public ApiResult<Boolean> update${entity}(#if(${cfg.paramValidation})@Validated(Update.class) #end@RequestBody ${entity} ${cfg.entityObjectName})throws Exception{
boolean flag= ${cfg.serviceObjectName}.update${entity}(${cfg.entityObjectName});
return ApiResult.result(flag);
......@@ -114,7 +113,7 @@ private ${table.serviceName} ${cfg.serviceObjectName};
#if(${cfg.operationLog})
@OperationLog(name = "删除$!{table.comment}", type = OperationLogType.DELETE)
#end
@ApiOperation(value = "删除$!{table.comment}", response = ApiResult.class)
@ApiOperation(value = "删除$!{table.comment}")
public ApiResult<Boolean> delete${entity}(@PathVariable("id") Long id)throws Exception{
boolean flag= ${cfg.serviceObjectName}.delete${entity}(id);
return ApiResult.result(flag);
......@@ -130,7 +129,7 @@ private ${table.serviceName} ${cfg.serviceObjectName};
#if(${cfg.operationLog})
@OperationLog(name = "$!{table.comment}详情", type = OperationLogType.INFO)
#end
@ApiOperation(value = "$!{table.comment}详情", response = ${entity}${cfg.queryVo}.class)
@ApiOperation(value = "$!{table.comment}详情")
public ApiResult<${entity}${cfg.queryVo}> get${entity}(@PathVariable("id") Long id)throws Exception{
#if(${cfg.generatorStrategy} == 'SINGLE')
${entity}${cfg.queryVo} ${cfg.entityObjectName}${cfg.queryVo} = ${cfg.serviceObjectName}.getById(id);
......@@ -150,7 +149,7 @@ private ${table.serviceName} ${cfg.serviceObjectName};
#if(${cfg.operationLog})
@OperationLog(name = "$!{table.comment}分页列表", type = OperationLogType.PAGE)
#end
@ApiOperation(value = "$!{table.comment}分页列表", response = ${entity}${cfg.queryVo}.class)
@ApiOperation(value = "$!{table.comment}分页列表")
public ApiResult<Paging<${entity}${cfg.queryVo}>>get${entity}PageList(#if(${cfg.paramValidation})@Validated #end@RequestBody ${entity}${cfg.pageParam} ${cfg.entityObjectName}${cfg.pageParam})throws Exception{
Paging<${entity}${cfg.queryVo}> paging = ${cfg.entityObjectName}Service.get${entity}PageList(${cfg.entityObjectName}${cfg.pageParam});
return ApiResult.ok(paging);
......
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