fix:时间格式化

上级 ee4bd7b4
package com.kwan.springbootkwan;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
......@@ -12,6 +13,7 @@ public class SpringBootKwanApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootKwanApplication.class, args);
System.out.println("------------------SpringBootKwan应用启动成功--------------------");
}
}
......@@ -6,6 +6,7 @@ import com.kwan.springbootkwan.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.validation.BindingResult;
......@@ -48,8 +49,8 @@ public class UserController {
}
@PostMapping(value = "/student",produces = "application/json;charset=utf-8")
public List<String> addUser(@RequestBody @Validated Student student, BindingResult result ) throws UnsupportedEncodingException {
@PostMapping(value = "/student", produces = "application/json;charset=utf-8")
public List<String> addUser(@RequestBody @Validated Student student, BindingResult result) throws UnsupportedEncodingException {
List<String> errors = new ArrayList<>();
if (result.hasErrors()) {
List<ObjectError> allErrors = result.getAllErrors();
......@@ -60,4 +61,10 @@ public class UserController {
log.info("errors={}", errors);
return errors;
}
@ApiOperation(value = "根据name获取用户信息", notes = "根据name获取用户信息")
@RequestMapping(value = "/getUserByName", method = RequestMethod.GET)
public User getUserByName(@RequestParam String sex) {
return userService.getUserByName(sex);
}
}
\ No newline at end of file
......@@ -5,13 +5,17 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@TableName(value = "user")
@ApiModel(value = "用户基本信息")
@AllArgsConstructor
@NoArgsConstructor
public class User {
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
......@@ -20,8 +24,4 @@ public class User {
private String name;
@ApiModelProperty(value = "性别")
private String sex;
@ApiModelProperty(value = "密码")
private String pwd;
@ApiModelProperty(value = "邮箱")
private String email;
}
......@@ -15,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserMapper extends BaseMapper<User> {
User getUserByName(String sex);
}
......@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
@Slf4j
public class ScheduleTest {
@Scheduled(cron = "0/10 * * * * ?")
// @Scheduled(cron = "0/10 * * * * ?")
public void execute() {
log.info("Scheduled task is running ... ...");
}
......
......@@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit;
@Component
@Slf4j
public class ScheduleTestTwo {
@Scheduled(cron = "0/10 * * * * *")
// @Scheduled(cron = "0/10 * * * * *")
public void second() throws InterruptedException {
log.info("Second scheduled task is running... ...");
TimeUnit.SECONDS.sleep(5);
......
......@@ -21,4 +21,11 @@ public interface IUserService extends IService<User> {
*/
User getUserById(Integer id);
/**
* 根据姓名查询
*
* @param sex
* @return
*/
User getUserByName(String sex);
}
......@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
......@@ -24,4 +25,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
public User getUserById(Integer id) {
return userMapper.selectById(id);
}
@Override
public User getUserByName(String sex) {
User userByName = userMapper.getUserByName(sex);
if (Objects.isNull(userByName)) {
userByName = new User();
}
return userByName;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kwan.springbootkwan.mapper.AdsDimFinancialYearWeekInfoDao">
<mapper namespace="com.kwan.springbootkwan.mapper.AdsDimFinancialYearWeekInfoMapper">
<resultMap type="com.kwan.springbootkwan.entity.AdsDimFinancialYearWeekInfo" id="AdsDimFinancialYearWeekInfoMap">
<result property="financialYear" column="financial_year" jdbcType="INTEGER"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kwan.springbootkwan.mapper.UserMapper">
<!-- <select id="getUserByName" resultType="com.kwan.springbootkwan.entity.User">-->
<!-- SELECT * from user-->
<!-- where 1=1-->
<!-- <if test="name != null and name != ''">-->
<!-- and name = #{name}-->
<!-- </if>-->
<!-- </select>-->
<select id="getUserByName" resultType="com.kwan.springbootkwan.entity.User">
SELECT *
FROM user
WHERE sex = #{sex}
</select>
</mapper>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册