You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.0 KiB
57 lines
2.0 KiB
package com.fr.conf.db.demo.fun.http; |
|
|
|
import com.fr.conf.db.demo.SystemConfigAccessBridge; |
|
import com.fr.conf.db.demo.fun.SystemConfigDAO; |
|
import com.fr.conf.db.demo.fun.entity.SystemConfigEntity; |
|
import com.fr.data.NetworkHelper; |
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.stable.db.action.DBAction; |
|
import com.fr.stable.db.dao.DAOContext; |
|
import com.fr.third.org.apache.commons.lang3.RandomUtils; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.third.org.apache.commons.lang3.RandomStringUtils; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.io.PrintWriter; |
|
import java.util.Date; |
|
import java.util.UUID; |
|
|
|
public class InputHttpHandler extends BaseHttpHandler { |
|
@Override |
|
public RequestMethod getMethod() { |
|
return RequestMethod.GET; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/db/input"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return false; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
|
|
|
SystemConfigEntity result = SystemConfigAccessBridge.getDbAccessor().runDMLAction(new DBAction<SystemConfigEntity>() { |
|
|
|
@Override |
|
public SystemConfigEntity run(DAOContext daoContext) throws Exception { |
|
SystemConfigEntity entity = new SystemConfigEntity(); |
|
entity.setId(UUID.randomUUID().toString()); |
|
entity.setUser(RandomStringUtils.randomAlphabetic(5)); |
|
entity.setBirth(new Date()); |
|
entity.setSalary(RandomUtils.nextDouble(10000, 50000)); |
|
daoContext.getDAO(SystemConfigDAO.class).add(entity); |
|
return entity; |
|
} |
|
}); |
|
PrintWriter writer = NetworkHelper.createPrintWriter(res); |
|
writer.println("success insert data:" + result.toString() + " to database table:fine_plugin_system_conf"); |
|
writer.flush(); |
|
writer.close(); |
|
} |
|
}
|
|
|