package com.highdatas.srs.web; import com.highdatas.srs.entity.ProjectLog; import com.highdatas.srs.pojo.CodeMsg; import com.highdatas.srs.pojo.Result; import com.highdatas.srs.service.IProjectLogService; import com.highdatas.srs.util.DbUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.Date; /** *

* 前端控制器 *

* * @author kimi * @since 2020-01-15 */ @RestController @RequestMapping("/projectLog") public class ProjectLogController { @Autowired IProjectLogService projectLogService; @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) public Result get(@PathVariable String id) { ProjectLog projectLog = projectLogService.selectById(id); return Result.success(projectLog); } @RequestMapping(value = "/add", method = RequestMethod.GET) public Result add(HttpServletRequest request) { String detailId = request.getParameter("detailId"); if(StringUtils.isEmpty(detailId)) { return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); } String desp = request.getParameter("desp"); String userId = request.getParameter("userId"); ProjectLog projectLog = new ProjectLog(); projectLog.setCreateTime(new Date()).setId(DbUtils.getUUID()).setDesp(desp).setSchemeDeatilId(detailId).setUserId(userId).insert(); return Result.success(projectLog); } }