Merge remote-tracking branch 'origin/在线访问lhj' into 在线访问lhj

在线访问lhj
李宏杰 8 months ago
commit b7192d6aad

@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.tamguo.common.utils.DateUtils; import com.tamguo.common.utils.DateUtils;
@ -29,42 +28,83 @@ import com.tamguo.config.redis.CacheService;
import com.tamguo.modules.member.service.IMemberService; import com.tamguo.modules.member.service.IMemberService;
import com.tamguo.utils.ShiroUtils; import com.tamguo.utils.ShiroUtils;
/**
* AccountController
*/
@Controller @Controller
public class AccountController { public class AccountController {
/**
*
*/
@Value("${file.storage.path}") @Value("${file.storage.path}")
String fileStoragePath; String fileStoragePath;
/**
*
*/
@Value("${tamguo.domain.name}") @Value("${tamguo.domain.name}")
String tamguoDomainName; String tamguoDomainName;
/**
*
*/
@Autowired @Autowired
IMemberService iMemberService; IMemberService iMemberService;
/**
*
*/
@Autowired @Autowired
CacheService cacheService; CacheService cacheService;
/**
*
*/
private static final String AVATOR_NO_FORMAT = "00000"; private static final String AVATOR_NO_FORMAT = "00000";
/**
*
*/
private static final String AVATOR_PREFIX = "MTX"; private static final String AVATOR_PREFIX = "MTX";
/**
* "account.html"
* @param model
* @return
*/
@RequestMapping(value = {"account.html"}, method = RequestMethod.GET) @RequestMapping(value = {"account.html"}, method = RequestMethod.GET)
public ModelAndView list(ModelAndView model) { public ModelAndView list(ModelAndView model) {
model.setViewName("account"); model.setViewName("account");
model.addObject("member", iMemberService.findByUid(ShiroUtils.getMemberId())); model.addObject("member", iMemberService.findByUid(ShiroUtils.getMemberId()));
return model; return model;
} }
/**
*
* @return
*/
@RequestMapping(value = {"getCurrentMember"}, method = RequestMethod.GET) @RequestMapping(value = {"getCurrentMember"}, method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Result getCurrentMember() { public Result getCurrentMember() {
return Result.result(0, iMemberService.findByUid(ShiroUtils.getMemberId()), "success"); return Result.result(0, iMemberService.findByUid(ShiroUtils.getMemberId()), "success");
} }
/**
*
* @param file
* @param request HTTP
* @return
* @throws IOException
*/
@RequestMapping(value = "uploadFile", method = RequestMethod.POST) @RequestMapping(value = "uploadFile", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public UploaderMessage uploadFileHandler(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws IOException { public UploaderMessage uploadFileHandler(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException {
if (!file.isEmpty()) { if (!file.isEmpty()) {
InputStream in = null; InputStream in = null;
OutputStream out = null; OutputStream out = null;
try { try {
String path = fileStoragePath + DateUtils.format(new Date(), "yyyyMMdd"); String path = fileStoragePath + DateUtils.format(new Date(), "yyyyMMdd");
File dir = new File(path); File dir = new File(path);
@ -93,12 +133,12 @@ public class AccountController {
msg.setError("File upload file"); msg.setError("File upload file");
return msg; return msg;
} finally { } finally {
if (out != null) { if (out!= null) {
out.close(); out.close();
out = null; out = null;
} }
if (in != null) { if (in!= null) {
in.close(); in.close();
in = null; in = null;
} }
@ -111,6 +151,10 @@ public class AccountController {
} }
} }
/**
*
* @return
*/
private String getAvatorNo() { private String getAvatorNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
String format = sdf.format(new Date()); String format = sdf.format(new Date());
@ -120,4 +164,4 @@ public class AccountController {
String avatorNo = AVATOR_PREFIX + df.format(incr); String avatorNo = AVATOR_PREFIX + df.format(incr);
return avatorNo; return avatorNo;
} }
} }
Loading…
Cancel
Save