Unverified Commit 7ac079ce by bianxin Committed by GitHub

Update README.md

parent aff1c1ba
...@@ -96,38 +96,38 @@ public class User extends Model<User> { ...@@ -96,38 +96,38 @@ public class User extends Model<User> {
@ApiModelProperty(name = "password" , value = "登录密码") @ApiModelProperty(name = "password" , value = "登录密码")
private String password; private String password;
@ApiModelProperty(name = "nickname" , value = "用户昵称") @ApiModelProperty(name = "nickname" , value = "用户昵称")
private String nickname; private String nickname;
@ApiModelProperty(name = "type" , value = "用户类型") @ApiModelProperty(name = "type" , value = "用户类型")
private Integer type; private Integer type;
@ApiModelProperty(name = "state" , value = "用户状态") @ApiModelProperty(name = "state" , value = "用户状态")
private Integer state; private Integer state;
@ApiModelProperty(name = "note" , value = "备注") @ApiModelProperty(name = "note" , value = "备注")
private String note; private String note;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ApiModelProperty(name = "createTime" , value = "用户创建时间") @ApiModelProperty(name = "createTime" , value = "用户创建时间")
private Date createTime; private Date createTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ApiModelProperty(name = "updateTime" , value = "修改时间") @ApiModelProperty(name = "updateTime" , value = "修改时间")
private Date updateTime; private Date updateTime;
@ApiModelProperty(name = "updateUid" , value = "修改人用户ID") @ApiModelProperty(name = "updateUid" , value = "修改人用户ID")
private Long updateUid; private Long updateUid;
@ApiModelProperty(name = "loginIp" , value = "登录IP") @ApiModelProperty(name = "loginIp" , value = "登录IP")
private String loginIp; private String loginIp;
@ApiModelProperty(name = "loginIp" , value = "登录地址") @ApiModelProperty(name = "loginIp" , value = "登录地址")
private String loginAddr; private String loginAddr;
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
return this.id; return this.id;
} }
...@@ -265,98 +265,97 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -265,98 +265,97 @@ import org.springframework.beans.factory.annotation.Autowired;
@RequestMapping("/user") @RequestMapping("/user")
public class UserController { public class UserController {
Logger logger = LoggerFactory.getLogger(this.getClass()); Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired @Autowired
public UserService userServiceImpl; public UserService userServiceImpl;
/** /**
* @explain 查询用户对象 <swagger GET请求> * @explain 查询用户对象 <swagger GET请求>
* @param 对象参数:id * @param 对象参数:id
* @return user * @return user
* @author BianPeng * @author BianPeng
* @time 2019年4月9日 * @time 2019年4月9日
*/ */
@GetMapping("/getUserById/{id}") @GetMapping("/getUserById/{id}")
@ApiOperation(value = "获取用户信息", notes = "获取用户信息[user],作者:BianPeng") @ApiOperation(value = "获取用户信息", notes = "获取用户信息[user],作者:BianPeng")
@ApiImplicitParam(paramType="path", name = "id", value = "用户id", required = true, dataType = "Long") @ApiImplicitParam(paramType="path", name = "id", value = "用户id", required = true, dataType = "Long")
public JsonResult<User> getUserById(@PathVariable("id")Long id){ public JsonResult<User> getUserById(@PathVariable("id")Long id){
JsonResult<User> result=new JsonResult<User>(); JsonResult<User> result=new JsonResult<User>();
try { try {
User user=userServiceImpl.getById(id); User user=userServiceImpl.getById(id);
if (user!=null) { if (user!=null) {
result.setType("success"); result.setType("success");
result.setMessage("成功"); result.setMessage("成功");
result.setData(user); result.setData(user);
} else { } else {
logger.error("获取用户失败ID:"+id); logger.error("获取用户失败ID:"+id);
result.setType("fail"); result.setType("fail");
result.setMessage("你获取的用户不存在"); result.setMessage("你获取的用户不存在");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("获取用户执行异常:"+e.getMessage()); logger.error("获取用户执行异常:"+e.getMessage());
result=new JsonResult<User>(e); result=new JsonResult<User>(e);
} }
return result; return result;
} }
/**
/** * @explain 添加或者更新用户对象
* @explain 添加或者更新用户对象 * @param 对象参数:user
* @param 对象参数:user * @return int
* @return int * @author BianPeng
* @author BianPeng * @time 2019年4月9日
* @time 2019年4月9日 */
*/ @PostMapping("/insertSelective")
@PostMapping("/insertSelective") @ApiOperation(value = "添加用户", notes = "添加用户[user],作者:BianPeng")
@ApiOperation(value = "添加用户", notes = "添加用户[user],作者:BianPeng") public JsonResult<User> insertSelective(User user){
public JsonResult<User> insertSelective(User user){ JsonResult<User> result=new JsonResult<User>();
JsonResult<User> result=new JsonResult<User>(); try {
try { boolean rg=userServiceImpl.saveOrUpdate(user);
boolean rg=userServiceImpl.saveOrUpdate(user); if (rg) {
if (rg) { result.setType("success");
result.setType("success"); result.setMessage("成功");
result.setMessage("成功"); result.setData(user);
result.setData(user); } else {
} else { logger.error("添加用户执行失败:"+user.toString());
logger.error("添加用户执行失败:"+user.toString()); result.setType("fail");
result.setType("fail"); result.setMessage("执行失败,请稍后重试");
result.setMessage("执行失败,请稍后重试"); }
} } catch (Exception e) {
} catch (Exception e) { logger.error("添加用户执行异常:"+e.getMessage());
logger.error("添加用户执行异常:"+e.getMessage()); result=new JsonResult<User>(e);
result=new JsonResult<User>(e); }
} return result;
return result; }
}
/** /**
* @explain 删除用户对象 * @explain 删除用户对象
* @param 对象参数:id * @param 对象参数:id
* @return int * @return int
* @author BianPeng * @author BianPeng
* @time 2019年4月9日 * @time 2019年4月9日
*/ */
@PostMapping("/deleteByPrimaryKey") @PostMapping("/deleteByPrimaryKey")
@ApiOperation(value = "删除用户", notes = "删除用户,作者:BianPeng") @ApiOperation(value = "删除用户", notes = "删除用户,作者:BianPeng")
@ApiImplicitParam(paramType="query", name = "id", value = "用户id", required = true, dataType = "Long") @ApiImplicitParam(paramType="query", name = "id", value = "用户id", required = true, dataType = "Long")
public JsonResult<Object> deleteByPrimaryKey(Long id){ public JsonResult<Object> deleteByPrimaryKey(Long id){
JsonResult<Object> result=new JsonResult<Object>(); JsonResult<Object> result=new JsonResult<Object>();
try { try {
boolean reg=userServiceImpl.removeById(id); boolean reg=userServiceImpl.removeById(id);
if (reg) { if (reg) {
result.setType("success"); result.setType("success");
result.setMessage("成功"); result.setMessage("成功");
result.setData(id); result.setData(id);
} else { } else {
logger.error("删除用户失败ID:"+id); logger.error("删除用户失败ID:"+id);
result.setType("fail"); result.setType("fail");
result.setMessage("执行错误,请稍后重试"); result.setMessage("执行错误,请稍后重试");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("删除用户执行异常:"+e.getMessage()); logger.error("删除用户执行异常:"+e.getMessage());
result=new JsonResult<Object>(e); result=new JsonResult<Object>(e);
} }
return result; return result;
} }
/** /**
......
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