ajax,mybatis使用者名稱重複校驗
阿新 • • 發佈:2018-12-16
Controller層
@RestController public class StoreController { @Autowired private IStoreService storeService; @PostMapping("/editStore") public String editStore(TbStoreInfoBean store, MultipartHttpServletRequest request, HttpServletResponse response) { Map<String, Object> map = new HashMap<>(); int count =storeService.selStoreName(store); if(count > 0){ return "22222" } 。。。新增方法
Dao層
int selStoreName(TbStoreInfoBean store);
IStoreServic層
int selStoreName(TbStoreInfoBean store);
StoreServiceImpl層
@Override
public int selStoreName(TbStoreInfoBean store) {
return storeDao.selStoreName(store);
}
mapper
<select id="selStoreName" parameterType="com.bean.TbStoreInfoBean" resultType="java.lang.Integer"> SELECT COUNT(*) FROM storeInfo AS s WHERE s.store_Name =#{storeName} </select>
ajax
$.ajax({
url: xxx
type: "POST",
data: formData,
success: function (data) {
if(data == '22222'){
layer.closeAll('loading');
layer.msg("店鋪已存在!請重新填寫");
}
});