Compare commits

...

2 Commits

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